Example #1
0
        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);
        }
Example #2
0
        public static Service CreateTemperatureSensor(Accessory accessory, double value)
        {
            var service = new Service(accessory)
            {
                Type = TemperatureSensorType,
                Id   = 7
            };

            var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.CurrentTemperatureType, value, 8), "float", false);

            state.Value = 0;

            service.Characteristics.Add(state);

            return(service);
        }
Example #3
0
        public static Service CreateSwitch(Accessory accessory, bool value)
        {
            var service = new Service(accessory)
            {
                Type = SwitchType,
                Id   = 7
            };

            var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool");

            state.Value = false;

            service.Characteristics.Add(state);

            return(service);
        }
Example #4
0
        public static Service CreateContactSensor(Accessory accessory, int value)
        {
            var service = new Service(accessory)
            {
                Type = ContactSensorType,
                Id   = 7
            };

            var state = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.ContactSensorStateType, value, 8), "uint8", false);

            state.Value = 0;

            service.Characteristics.Add(state);

            return(service);
        }
Example #5
0
        public static Service CreateLightBulb(Accessory accessory, bool value)
        {
            var service = new Service(accessory)
            {
                Type = LightBulbType,
                Id   = 7
            };

            var bulbC = SetCharacteristicOptions(CharacteristicFactory.Create <bool>(service, CharacteristicBase.OnType, value, 8), "bool");

            bulbC.Value = false;


            service.Characteristics.Add(bulbC);

            return(service);
        }
Example #6
0
        public static Service CreateOutlet(Accessory accessory, bool value)
        {
            var service = new Service(accessory)
            {
                Type = OutletType,
                Id   = 7
            };

            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);
        }