protected virtual void OnDeviceStateChanged(DeviceStatusChangedEvent e) { EventHandler <DeviceStatusChangedEvent> handler = DeviceStateChanged; if (handler != null) { handler(this, e); } }
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); } }