Closed hive closed 2 months ago
The insights event listeners never fire meaning its not possible to be aware of insight changes.
try { this.api = await HomeyAPI.createAppAPI({ homey: this.homey, }); // POC for zones - works console.log('--- Zones ---') // works await api.zones.connect() // works let zones = await api.zones.getZones() // works console.log(zones) // works api.zones.on('zone.update', (data: any) => console.log(data)) // works // POC for insights - never fires console.log('--- Insights ---') // works await api.insights.connect() // works let insights = await api.insights.getLogs() // works console.log(insights) // works api.insights.on('log.update', (data: any) => console.log(data)) // never fires for (let x in values) { insights[x].on('update', async (data: any) => { console.log(data) // never fires }); } } catch (e) { this.error(e); }
When do you expect it to fire?
I would assume that when an insight is updated or created that it would fire along with information about the insights information which has updated, perhaps when a log entry is created in the log?
Note that there is also no way to listen to the logEntries in order to provide information about any insights - the only approach is to poll constantly.
It's correct that there is no event when a log entry is created. Polling is the way forward, that's why there's a property that tells you when the next value is expected.
log.update
does fire when the Insight's title, units etc. changes, which is of course almost never.
The insights event listeners never fire meaning its not possible to be aware of insight changes.