示例#1
0
        protected virtual void OnDeviceStateChanged(DeviceStatusChangedEvent e)
        {
            EventHandler <DeviceStatusChangedEvent> handler = DeviceStateChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
示例#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);
            }
        }