This commit is contained in:
legop3
2026-04-26 21:09:11 -04:00
parent c28cb4bb20
commit 304c984423
9 changed files with 196 additions and 150 deletions
+22
View File
@@ -34,6 +34,7 @@ const ENTITY_IDS = {
start: entityId('button', 'house_clean'),
sendHome: entityId('button', 'send_to_base'),
locate: entityId('button', 'locate_robot'),
clearErrors: entityId('button', 'clear_errors'),
},
sensors: {
batteryPercent: entityId('sensor', 'fuel_percent'),
@@ -92,6 +93,10 @@ function buildState() {
entityId: ENTITY_IDS.buttons.locate,
available: hasEntity(ENTITY_IDS.buttons.locate),
},
clearErrors: {
entityId: ENTITY_IDS.buttons.clearErrors,
available: hasEntity(ENTITY_IDS.buttons.clearErrors),
},
};
const batteryPercentValue = parseNumber(readState(ENTITY_IDS.sensors.batteryPercent));
@@ -179,6 +184,10 @@ async function locateRobot() {
await pressButton(ENTITY_IDS.buttons.locate, 'locate');
}
async function clearErrors() {
await pressButton(ENTITY_IDS.buttons.clearErrors, 'clear_errors');
}
function getState() {
cachedState = buildState();
return cachedState;
@@ -220,6 +229,18 @@ io.on('connection', (socket) => {
cb({ error: err.message });
}
});
socket.on('neato:clearErrors', async (_, cb = () => {}) => {
try {
if (!isVerified(socket)) {
throw new Error('VIP verification required');
}
await clearErrors();
cb({ success: true });
} catch (err) {
cb({ error: err.message });
}
});
});
emitUpdate();
@@ -229,5 +250,6 @@ module.exports = {
startCleaning,
sendHome,
locateRobot,
clearErrors,
neatoEvents: events,
};