NorthernMan54 / homebridge-tasmota

Plugin for Tasmota devices leveraging Home Assistant auto discovery
Apache License 2.0
35 stars 9 forks source link

Frequency of Sensor information updates / refresh rate #10

Closed NorthernMan54 closed 3 years ago

NorthernMan54 commented 4 years ago

From @StumbleNOLA

The refresh rate in the lux sensor is averaging about once every 3 minutes. Is there any way to increase the refresh rate?

StumbleNOLA commented 4 years ago

Tested by putting the light sensor in a dark room (reading 2 LUX), then turned on the lights (~60 LUX). It then took about 3 minutes to populate thru HomeKit, the Tasmota UI updated almost instantly.

NorthernMan54 commented 4 years ago

Frequency of data updates is controlled by the Tasmota device itself and not the plugin itself. The plugin does not poll the device for status, but processes telemetry updates as they are received. The plugin watches for telemetry updates on the tele/SENSOR topic ie 'tasmota-5042/tele/SENSOR'.

During initialization of the plugin, it sets the teleperiod option to 300 seconds ( 5 minutes ). This is done to force the device to refresh status immediately after plugin startup. And then further updates are published every 5 minutes by the accessory.

To drive realtime updates of sensor value changes a rule would need to be created on the device to publish the new data on the appropriate tele/SENSOR topic for the device whenever a sensor changes value, something like this from the Tasmota rule cookbook.

https://tasmota.github.io/docs/Rules/#transmit-sensor-value-only-when-a-delta-is-reached

Rule1
  ON SI7021#temperature>%var1% DO Backlog var1 %value%; publish stat/mqttTopic/temp %value%; var2 %value%; add1 2; sub2 2 ENDON
  ON SI7021#temperature<%var2% DO Backlog var2 %value%; publish stat/mqttTopic/temp %value%; var1 %value%; add1 2; sub2 2 ENDON

This is discussed in detail in this Tasmota issue https://github.com/arendst/Tasmota/issues/2567

StumbleNOLA commented 4 years ago

Welp... That answers that. Might as well close this, as operator error... Due to the operator not knowing how to use his toys very well.

NorthernMan54 commented 4 years ago

PS This is not a issue for Lights, Switches etc due to this option

setoption59 - send telemetry message for State/Power

NorthernMan54 commented 4 years ago

@StumbleNOLA I had exactly the same thought last night when doing testing, so I figured a lot of other people are going to ask the same question, hence my detailed answer. If you do come up with a rule, adding it here would help others.

StumbleNOLA commented 4 years ago

I will try to get something working, and assuming I can post it.

Also since I have zero coding background, I am writing up everything that I am doing as a users guide. Something of an idiots guide to the plugin/Tasmota environment for people who's eye's glaze over when they look at a json file. If it gets to a reasonable level I may share that as well.

NorthernMan54 commented 4 years ago

This may work for you

Rule1 ON BH1750#Illuminance!=%var1% DO Backlog var1 %value%; teleperiod 300; ENDON
Rule1 1

To disable, rule1 0

Post these lines into the Tasmota console for the device

StumbleNOLA commented 4 years ago

I didn't get your rule suggestion to work... I am not sure I entered it correctly though, I just copied and pasted it it into the terminal on one line.

However what is working reasonably well is to lower to teleperiod to 10 seconds (the lowest it will go) by enter ing "Telepresence 10". It likely ends up costing a lot of wifi traffic, but the response time is now reasonably snappy.

NorthernMan54 commented 4 years ago

Try pasting this

Rule1 ON BH1750#Illuminance!=%var1% DO Backlog var1 %value%; teleperiod 300; ENDON

then

rule1 1
StumbleNOLA commented 4 years ago

I changed the telepresence back to 300, then input your rule.

Everything seems to be working as expected. The refresh rate seems to be about 3 seconds at the fastest, which is perfectly reasonable.

NorthernMan54 commented 4 years ago

Awesome

Closing this