moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

Battery monitoring #117

Closed Bolten88 closed 3 years ago

Bolten88 commented 3 years ago

Hi Moroen,

since the newer version of the plugin the battery monitoring has been changed. I like to see the history of the battery levels. Is this something that can be improved? Something like check the battery each hour and log in the charts?

battery

Tinus016 commented 3 years ago

What version off the plugin do you use?

I have the same issue, it only happens when I not use te remote, if I use the remote it works fine

Plugin version 0.9.11

Bolten88 commented 3 years ago

What version off the plugin do you use?

I have the same issue, it only happens when I not use te remote, if I use the remote it works fine

Plugin version 0.9.11

Yes, i'm aware of that. I do not use the remote all the time. Most of the time i use automations (scripts) to switch the lights. In fact i rarely use the remotes. So it would be nice that i can see the history in that case.

I'm using the current last version 0.9.13

moroen commented 3 years ago

You need to enable polling. The value will be updated when the battery value actually has changed. If you need/want datapoint even if the value hasn't changed, I can make the needed changes to the plugin.

Tinus016 commented 3 years ago

I have polling activeded.

The strange thing is, on Saturday the battery level was 75% after a few days of not using the remote, the battery become 60% after one switch use at that moment domoticz saw the change in battery level. Are u sure that polling works or miss I something?

Edit: is it true, domoticz sees only a change in battery level at te moment the remote is used?

moroen commented 3 years ago

The plugin can only see the value recorded in the gateway. How exactly that value is updated, I'm not sure, but I suspect that it's only updated when the remote is actually used. I'm pretty sure the same goes for the battery status of the blinds, that the value is updated when the blind is operated.

The plugin polls the gateway, and if the value in the gateway has changed, the value in domoticz is updated as well. The only thing that can be changed, is that the plugin records the value on every poll, but as long as the remote hasn't been used, that value will probably be the same.

Bolten88 commented 3 years ago

I have polling activated as well. And sometimes i see the behavior as @Tinus016 describes. Of course it could be a weak battery or something between the HUB and the remote. To address this it would be nice to have battery status readings in domoticz more often. Not only when the battery status is updated. And it gives smoother graphs ;-).

moroen commented 3 years ago

The plugin can only display what the gateway provides. The underlying problem here, is in the way that the gateway updates the battery-levels, as noted above. A long intervall between two updates is because the value has been the same during whole of the interval, the plugin reads the value from the gateway on every poll.

Of course there is nothing wrong with updating the domoticz device on every poll, then you'll still get the same value on every poll until the value actually in the gateway actually has changed, but a datapoint will be generated in the graph every time a poll is performed. I've changed the development-version to do exactly that, try the development-branch and see if that's more in line with what you want! :)

moroen commented 3 years ago

I've taken this a bit further. Is now possible to select whether the domoticz device for batteries is updated when the value actually has changed or on every poll. Available in the development branch. Update the IKEA hardware page in Domoticz to enable.

Tinus016 commented 3 years ago

@moroen how do I get the development branch? i would like to test it

moroen commented 3 years ago

@Tinus016

Stop domoticz and go into the IKEA-Tradfri directory, then:

$ git checkout development
$ git pull

and restart domoticz. To go back to master, just substitute development with master:

$ git checkout master
$ git pull
Tinus016 commented 3 years ago

Thanks!

Tinus016 commented 3 years ago

I've tried it a few days and works fine! I activated the pol on every call option. You can see when i've used the remote, the battery level drops after a while it wil resume back.

Schermafbeelding 2020-10-13 om 20 17 23
Bolten88 commented 3 years ago

I moved to the development version. When i choose to update bateries on every poll i see this error in the log:

2020-10-14 11:39:46.210 Error: (IKEA Tradfri) onPoll

But the updates do work after that.

moroen commented 3 years ago

Just a debug message that should've been removed, I'll fix it in the next development version... :)

Bolten88 commented 3 years ago

That is what i thought. Thank you. I like this feature allready.

But i do see that the batteries are updated every 5 minutes while i have the poll interval on 3 minutes. Doesn't matter to me but you might want that better ;-).

moroen commented 3 years ago

@Bolten88

I would guess you're talking about the graph? The value is actually updated on every poll, as can be seen if you look at the last seen date and time on the domoticz device, but the graph's minimal resolution is 5 minutes, this is a restriction in domoticz, not the plugin...

moroen commented 3 years ago

Merged into the current master, closing issue.