diff --git a/src/server.js b/src/server.js index f51aed8..90c0ce5 100644 --- a/src/server.js +++ b/src/server.js @@ -158,9 +158,19 @@ async function processor(group, consumer, streamKey) { break; case "light_on": - await playAudio("Turning on light."); + if (msg.message.argument) { + await playAudio("Turning on " + msg.message.argument + " light.") + await ha.client.post("/api/services/homeassistant/turn_on", { + entity_id: "light." + msg.message.argument + "_" + msg.message.argument + }).catch(async (err) => { + await playAudio("I have failed you father."); + console.error(err); + }); + break; + } + await playAudio("Turning on lights."); await ha.client.post("/api/services/homeassistant/turn_on", { - entity_id: "light.living_room_living_room" + entity_id: "light.home_home" }).catch(async (err) => { await playAudio("I have failed you father."); console.error(err); @@ -168,9 +178,19 @@ async function processor(group, consumer, streamKey) { break; case "light_off": - await playAudio("Turning off light."); + if (msg.message.argument) { + await playAudio("Turning off " + msg.message.argument + " light.") + await ha.client.post("/api/services/homeassistant/turn_off", { + entity_id: "light." + msg.message.argument + "_" + msg.message.argument + }).catch(async (err) => { + await playAudio("I have failed you father."); + console.error(err); + }); + break; + } + await playAudio("Turning off lights."); await ha.client.post("/api/services/homeassistant/turn_off", { - entity_id: "light.living_room_living_room" + entity_id: "light.home_home" }).catch(async (err) => { await playAudio("I have failed you father."); console.error(err);