This commit is contained in:
legop3
2026-04-29 19:22:21 -04:00
parent 943fa11f7e
commit 91a3272780
+10 -5
View File
@@ -9,7 +9,7 @@ const { isVerified } = require('../verificationService');
const { const {
homeAssistantEvents, homeAssistantEvents,
getRawEntitySnapshot, getRawEntitySnapshot,
setEntityState, callHomeAssistantService,
isConnected: isHomeAssistantConnected, isConnected: isHomeAssistantConnected,
enabled: homeAssistantEnabled, enabled: homeAssistantEnabled,
} = require('../homeAssistantService'); } = require('../homeAssistantService');
@@ -102,15 +102,20 @@ function assertReady() {
} }
async function applyPosition(target) { async function applyPosition(target) {
async function setSwitch(entityId, desiredState) {
const service = desiredState === 'on' ? 'turn_on' : 'turn_off';
await callHomeAssistantService('switch', service, { entity_id: entityId });
}
if (target === 'up') { if (target === 'up') {
await setEntityState(downSwitchId, 'off'); await setSwitch(downSwitchId, 'off');
await sleep(interlockMs); await sleep(interlockMs);
await setEntityState(upSwitchId, 'on'); await setSwitch(upSwitchId, 'on');
return; return;
} }
await setEntityState(upSwitchId, 'off'); await setSwitch(upSwitchId, 'off');
await sleep(interlockMs); await sleep(interlockMs);
await setEntityState(downSwitchId, 'on'); await setSwitch(downSwitchId, 'on');
} }
async function requestPosition(target, actor = 'unknown') { async function requestPosition(target, actor = 'unknown') {