mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-18 10:30:47 -04:00
slorp
This commit is contained in:
@@ -21,6 +21,7 @@ const actions = createActions({ getConfig: () => config, ha: {
|
||||
get enabled() { return ha.enabled; },
|
||||
isConnected: () => snapshotReady && ha.isConnected(),
|
||||
getRawEntitySnapshot: ha.getRawEntitySnapshot,
|
||||
getServiceDescriptions: ha.getServiceDescriptions,
|
||||
callHomeAssistantService: ha.callHomeAssistantService,
|
||||
}, locks });
|
||||
|
||||
@@ -28,7 +29,8 @@ function getState() {
|
||||
return {
|
||||
enabled: config.enabled,
|
||||
connected: ha.enabled && snapshotReady && ha.isConnected(),
|
||||
items: config.enabled ? config.items.map((item) => buildEntity(item, ha.getRawEntitySnapshot(item.id), locks.isLocked(item.id))) : [],
|
||||
controlsReady: Boolean(ha.getServiceDescriptions()),
|
||||
items: config.enabled ? config.items.map((item) => buildEntity(item, ha.getRawEntitySnapshot(item.id), ha.getServiceDescriptions(), locks.isLocked(item.id))) : [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -50,6 +52,8 @@ function setLocked(query, locked) {
|
||||
return item;
|
||||
}
|
||||
|
||||
// Newly loaded/reloaded integrations can change controls without state changes.
|
||||
ha.homeAssistantEvents.on('services', emitUpdate);
|
||||
ha.homeAssistantEvents.on('snapshot', () => {
|
||||
snapshotReady = true;
|
||||
emitUpdate();
|
||||
@@ -66,7 +70,7 @@ registerConfigurationHandler('homeAssistantActivities', (next) => {
|
||||
io.on('connection', (socket) => {
|
||||
socket.on('homeAssistantActivities:act', async (payload) => {
|
||||
try {
|
||||
await actions.act(payload?.id, payload?.value, { role: getRole(socket), mode: getMode() });
|
||||
await actions.act(payload?.id, payload?.action, payload?.values, { role: getRole(socket), mode: getMode() });
|
||||
} catch (error) {
|
||||
// No acknowledgement state is sent to the browser: actual entity
|
||||
// changes arrive through the shared snapshot stream. Keep failures in
|
||||
|
||||
Reference in New Issue
Block a user