This commit is contained in:
legop3
2026-09-16 13:11:16 -04:00
parent f3e3b6a803
commit 318cad1846
23 changed files with 813 additions and 186 deletions
@@ -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