/// <summary> /// Cycles living room lights between two scenes while a v-switch is turned on /// </summary> /// <param name="evt"></param> /// <param name="token"></param> protected override async Task Handle() { TimeSpan timeBetweenCycles = TimeSpan.FromMinutes(5); if (_evt.IsOnEvent) { SwitchRelay LivingRoomXmas1 = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoomXmasScene1"); SwitchRelay LivingRoomXmas2 = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoomXmasScene2"); while (true) { await LivingRoomXmas1.On(); await WaitForCancellationAsync(timeBetweenCycles); await LivingRoomXmas2.On(); await WaitForCancellationAsync(timeBetweenCycles); } } else { SwitchRelay DefaultLivingRoomScene = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoomNormalScene"); await DefaultLivingRoomScene.On(); return; } }
public void OpenCloseRelay(bool b, string name, string channel) { name = name.ToLower(); SwitchRelay curRelay = null; switch (name) { case "r1": curRelay = relayR1; break; case "r2": curRelay = relayR2; break; case "r3": curRelay = relayR3; break; case "r4": curRelay = relayR4; break; case "r5": curRelay = relayR5; break; case "r6": curRelay = relayR6; break; case "r7": curRelay = relayR7; break; case "r8": curRelay = relayR8; break; default: return; } //curRelay.ChangeRelayState(b, "k"+channel); try { curRelay.ChangeRelayState(b, "ch" + channel); } catch { } }
/// <summary> /// Cycles living room lights between two scenes while a vswitch is turned on /// </summary> /// <param name="evt"></param> /// <param name="token"></param> public override async Task Handle(CancellationToken token) { TimeSpan timeBetweenCycles = TimeSpan.FromMinutes(5); if (_evt.IsOnEvent) { SwitchRelay LivingRoomXmas1 = _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoomXmasScene1") as SwitchRelay; SwitchRelay LivingRoomXmas2 = _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoomXmasScene2") as SwitchRelay; while (true) { LivingRoomXmas1.On(); await Task.Delay(timeBetweenCycles, token); LivingRoomXmas2.On(); await Task.Delay(timeBetweenCycles, token); } } else { SwitchRelay DefaultLivingRoomScene = _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoomNormalScene") as SwitchRelay; DefaultLivingRoomScene.On(); return; } }
public PantryLightAutomation(HomeAutomationPlatform hub, HubEvent evt) : base(hub, evt) { _pantryLight = _hub.GetDeviceByMappedName <SwitchRelay>("Switch.PantryLight") as SwitchRelay; _kitchenSpeaker = _hub.GetDeviceByMappedName <Speaker>("Speaker.KitchenSpeaker") as Speaker; }
protected override async Task InitDevices() { _sampleLight = await _hub.GetDeviceByMappedName <SwitchRelay>("SampleDevices.SampleLight"); _sampleSpeaker = await _hub.GetDeviceByMappedName <Speaker>("SampleDevices.SampleSpeaker"); }
protected override async Task InitDevices() { _basementFurnace = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.BasementFurnace"); _basementWasher = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.BasementWasher"); }
protected override async Task InitDevices() { _pantryLight = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.PantryLight"); _kitchenSpeaker = await _hub.GetDeviceByMappedName <Speaker>("Speaker.KitchenSpeaker"); }
public override async Task Handle(CancellationToken token) { if (_evt.IsOnEvent) { await Task.Delay(HowLong, token); SwitchRelay relay = _hub.GetDeviceById <SwitchRelay>(_evt.DeviceId) as SwitchRelay; relay.Off(); } }
void InitSwitch() { relayR1 = new SwitchRelay("R1"); relayR2 = new SwitchRelay("R2"); relayR3 = new SwitchRelay("R3"); relayR4 = new SwitchRelay("R4"); relayR5 = new SwitchRelay("R5"); relayR6 = new SwitchRelay("R6"); relayR7 = new SwitchRelay("R7"); relayR8 = new SwitchRelay("R8"); }
protected override async Task Handle() { if (_evt.IsOnEvent) { await WaitForCancellationAsync(HowLong); SwitchRelay relay = await _hub.GetDeviceById <SwitchRelay>(_evt.DeviceId); await relay.Off(); } }
protected override async Task InitDevices() { _doors = new List <ContactSensor> { await _hub.GetDeviceByMappedName <ContactSensor>("Contact.FrontDoor"), await _hub.GetDeviceByMappedName <ContactSensor>("Contact.GarageDoor1"), await _hub.GetDeviceByMappedName <ContactSensor>("Contact.GarageDoor2") }; _frontLights = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.FrontLightsPower"); }
protected override async Task InitDevices() { _barOutlet = await _hub.GetDeviceByMappedName <SwitchRelay>("Outlet.Bar"); }
protected override async Task InitDevices() { _floodlights = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.Floodlights"); }
protected override async Task InitDevices() { _livingRoom2 = await _hub.GetDeviceByMappedName <SwitchRelay>("Switch.LivingRoom2"); }