public static Characteristic Create <T>(this Accessory accessory, string type, object value, string format, bool canWrite = false) { var service = accessory.Services[1]; int id = service.Characteristics[service.Characteristics.Count - 1].Id + 1; var characteristic = CharacteristicFactory.Create <T>(accessory.Services[1], type, value, id); SetCharacteristicOptions(characteristic, format, canWrite); accessory.Services[1].Characteristics.Add(characteristic); return(characteristic); }
public static Service CreateTemperatureSensor(Accessory accessory, int id, double value) { var service = new Service(accessory) { Type = TemperatureSensorType, Id = id }; var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.CurrentTemperatureType, value, 8), "float", false); state.Value = 0; service.Characteristics.Add(state); return(service); }
public static Service CreateSwitch(Accessory accessory, int id, bool value) { var service = new Service(accessory) { Type = SwitchType, Id = id }; var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool"); state.Value = false; service.Characteristics.Add(state); return(service); }
public static Service CreateContactSensor(Accessory accessory, int id, int value) { var service = new Service(accessory) { Type = ContactSensorType, Id = id }; var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.ContactSensorStateType, value, 8), "uint8", false); state.Value = 0; service.Characteristics.Add(state); return(service); }
public static Service CreateLightBulb(Accessory accessory, int id, bool value) { var service = new Service(accessory) { Type = LightBulbType, Id = id }; var bulbC = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool"); bulbC.Value = false; service.Characteristics.Add(bulbC); return(service); }
public static Service CreateOutlet(Accessory accessory, int id, bool value) { var service = new Service(accessory) { Type = OutletType, Id = id }; var on = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool"); on.Value = false; var inUse = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OutletInUseType, true, 9), "bool", false); inUse.Value = true; service.Characteristics.Add(on); service.Characteristics.Add(inUse); return(service); }