joba-1 / Tasmoticz

Domoticz MQTT autodiscovery plugin for Tasmota devices
MIT License
25 stars 18 forks source link

Create device for LWT messages. #40

Open Reidid92 opened 1 year ago

Reidid92 commented 1 year ago

It would be useful to create a device to process LWT messages. The "Last Will and Testament" feature of MQTT is used by Tasmota to signal when the IOT is online, and MQTT automatically reports when the IOT is offline, for any reason (intentional or not). Creating a Text or Alarm device would be appropriate.

joba-1 commented 1 year ago

Domoticz already has a feature like this:

Sensor Timeout If the device is not seen for a long time (timed out), the highlight color will be Red. Set timeout time it in minutes This setting only checks Sensors (temperature, humidity, lux etc), not Switches/Lights. Also a notification can be set on sensors through the device notification button.

Reidid92 commented 1 year ago

What you are talking about is an indirect strategy, deducing accessibility to the IOT from the non-reception of unrelated cyclic messages. It's not exactly the same thing. LWT offers a direct, immediate and independent expression of the accessibility status, uncorrelated from the frequency of emission of sensors values. We can then adapt the sensors status period to application needs using the Tasmota "Teleperiod" parameter, without impacting the detection of loss of accessibility. Then, there may be faster or slower POWER emission period, or even infinite (messages sent only when values change). We know independently of that and without delay whether the IOT is accessible or not. And this, with a minimum of messages exchanges (only when online/ofline transitions). All of this being intentionaly provided by Tasmota, why not exploit it.

joba-1 commented 1 year ago

I think I understand your point, but I must admit it has very low prio for me: I don’t need or want to know if a tasmota device is online or not. I am only interested if I get the sensor values I expect (which already includes tasmota device and network problems). Still, if you provide a PR it is likely I‘ll accept it.

Reidid92 commented 1 year ago

I understand your priorities. I am working on a patch for that. When done I will submit it to you. I am working by reusing your updateXXXDevice, createXXXDevice code and what I understand of it. But I am not very familiar with python so my code will probably not be the best way and it will need your informed criticism.