How to get logs for specific device

Hi all,

I do currently have problems with some INNR Light Bulbs randomly turning on for no apparent reason. They’re not part of any flow, do turn on at random times of the day and the Timeline of the Bulb only says that they were turned on by the “INNR” App. However, the INNR App does not turn on any lights. This is reported wrongly by Homey.

I already contacted Athom Support and the Developer of the INNR App. No one of them was able to help unfortunately. I’d now like to write a HomeyScript that detects when a Bulb was turned on “by the INNR App” so that I can automatically turn it off.
The Bulbs are sometimes on for the whole night because I don’t always see them turning on randomly (I have over 26 INNR Bulbs scattered in my Home).

What I tried to do was to get the Logs for each “light” class device and check the Logs for that specific Device. However, the following code doesn’t seem to work as the Filter is completely useless and returns all Logs.

const lights = Object.values(await Homey.devices.getDevices()).filter(device => device.class === 'light');

for (const light of lights) {
  const logs = await Homey.insights.getLogs({ filter: { id: `homey:device:${light.id}:onoff` }});
  console.log(logs.map(log => log.id));
}

Example Output (part of it):

'homey:device:ad249cdd-0a1b-449d-86ea-86e08fe6814c:measure_current',
  'homey:device:ad249cdd-0a1b-449d-86ea-86e08fe6814c:measure_voltage',
  'homey:device:ad249cdd-0a1b-449d-86ea-86e08fe6814c:meter_power',
  'homey:device:ad249cdd-0a1b-449d-86ea-86e08fe6814c:onoff',
  'homey:device:ae14532c-1d7e-4d64-966f-35b43b92bcf9:onoff',
  'homey:device:af2639ec-b6e9-4364-9c1f-b988a839439d:onoff',
  'homey:device:b048c0f6-24f7-4203-9c0a-0585f5815375:onoff',
  'homey:device:b1ee6bf6-edca-47cb-b198-fd7a7a1671b4:onoff',
  'homey:device:b6ed8c56-71c5-4417-890f-7aed25da29ac:onoff',
  'homey:device:c1bbc031-8b78-4afe-a1bc-57c521fc21c1:alarm_battery',
  'homey:device:c1bbc031-8b78-4afe-a1bc-57c521fc21c1:alarm_motion',
  'homey:device:c1bbc031-8b78-4afe-a1bc-57c521fc21c1:measure_battery',
  'homey:device:c1bbc031-8b78-4afe-a1bc-57c521fc21c1:measure_luminance',
  'homey:device:c1bbc031-8b78-4afe-a1bc-57c521fc21c1:measure_temperature',

So not only the Logs for my “light” class devices are returned, but all of them (luminance and temperature for example are my motion sensors).

Am I using the filter the wrong way? The Homey API SDK is kind of garbage…

You should be looking at the Web API documentation, the SDK is only used for apps.

Also, Homey does a lot of things badly, but in my experience it doesn’t make up events or turn on/off lights by itself, so there’s either still a flow (or a script) that’s causing this behaviour, or possibly you have an issue with either yourself or a neighbour having a Zigbee remote control that is inadvertently causing your lights to switch (which does happen, although it’s usually IKEA remotes with Aqara devices).

Thanks Robert for your Reply!

I did use the IntelliSense Feature of the Web-Editor for HomeyScript. It shows that I can use options for a filter:

This seems to mismatch what the linked Web API documentation says (which is without any options). Which one is the source of truth and do you know why IntelliSense shows these function parameters?

Do you know any good way to only get the Logs for a specific device? If there’s no filter then I don’t know how that could be done. The app has such a feature for each device.

By the way, I do have IKEA remotes, but shouldn’t they show as the source of the “turning on” event?
Also, for that to happen, it should be part of a flow which triggers this event when the IKEA Switch Button was pressed or not?

Here’s an example of the log for one of the bulbs. As you can see it’s not part of any flow. There can’t be a Script causing this as I just installed the HomeyScript App.

Edit: The only flow where these bulb is part of is this one. If that gets triggered all Bulbs in the Zone “Büro” should turn on, but it are always only some random ones.

I don’t know why the IntelliSense popup is mismatching the documentation, perhaps @Jero can explain?

I realise now that you don’t want Insights logs, you want notifications: ManagerNotifications - Homey Web API

No.

Also no. In fact, the remote doesn’t even have to be in the same Zigbee network.

The issue is that some remotes send broadcast messages to particular Zigbee group ID’s by default, and some devices also listen to those group ID’s by default. I don’t know about INNR, but it’s a (relatively) well-known issue between IKEA and Aqara (see this Dutch post, and there are a few more but can’t find them at the moment).

Other Zigbee implementations work around that issue by automatically “unsubscribing” such devices from those groups when they get paired (but Homey doesn’t support that AFAIK).

That’s “normal” for Homey, at least with the old Homey Pro. It cannot handle sending lots of messages.

This is kind of bad that we still did not update HomeyScript but other things had priority.

HomeyScript uses the old npm library and the docs are for the new one.

The types though are for the old one.

I know its a mess.

1 Like