From 6244f5bd6d0283d8567019e567526f742e2d65f4 Mon Sep 17 00:00:00 2001 From: Apher Date: Fri, 24 Jul 2026 05:03:06 +0000 Subject: [PATCH] Add specific device control --- src/server.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) 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);