mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-17 10:00:46 -04:00
ohyeah
This commit is contained in:
@@ -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') {
|
||||||
|
|||||||
Reference in New Issue
Block a user