Exemplo n.º 1
0
        protected virtual void OnDeviceStateChanged(DeviceStatusChangedEvent e)
        {
            EventHandler <DeviceStatusChangedEvent> handler = DeviceStateChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemplo n.º 2
0
        public async void DeviceStateChanged(object sender, DeviceStatusChangedEvent e)
        {
            var device = _hcClient.GetDeviceByUuid(uuid: e.DeviceId);

            if (device.Model == "light")
            {
                // HC changed the state of a device
                await SetStateOfLight(e.DeviceId, e.NewState);
            }
            else
            {
                await SetStateOfSwitch(e.DeviceId, e.NewState);
            }
        }