Poll state every 30s

This commit is contained in:
Adrian Jagielak 2025-07-23 23:23:29 +02:00
parent 2fc61ead25
commit 3a65e11948
No known key found for this signature in database
GPG Key ID: 0818CF7AF6C62BFB
2 changed files with 14 additions and 9 deletions

View File

@ -31,7 +31,7 @@ Devices commonly consist of multiple services: for example, a presence sensor mi
Some services are more common than others. Some are deprecated entirely.
todo periodical refresh of devices
todo periodical refresh of state
todo links to the .ts service implementations below
| Service | Example device | Implementation status |
| --- | --- | --- |

View File

@ -175,15 +175,20 @@ import { delay } from "./utils";
}
});
const pollState = () => {
sendFimpMsg({
address: '/rt:app/rn:vinculum/ad:1',
service: 'vinculum',
cmd: 'cmd.pd7.request',
val: { cmd: "get", component: null, param: { components: ['state'] } },
val_t: 'object',
timeoutMs: 30000,
}).catch(e => log.warn("Failed to request state", e));
};
// Request initial state
await sendFimpMsg({
address: '/rt:app/rn:vinculum/ad:1',
service: 'vinculum',
cmd: 'cmd.pd7.request',
val: { cmd: "get", component: null, param: { components: ['state'] } },
val_t: 'object',
timeoutMs: 30000,
});
pollState();
// Then poll every 30 seconds
setInterval(pollState, 30000);
ha.on('message', (topic, buf) => {
// Handle Home Assistant command messages