xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.98k stars 637 forks source link

MQTT group sync documentation #362

Closed xoseperez closed 6 years ago

xoseperez commented 6 years ago

Originally reported by: Ian Cunningham (Bitbucket: iancun, GitHub: iancun)


I've got 3 LED strips now running from an H801, and I've set them to use the same MQTT root topic so that they will receive identical commands from Home Assistant. It works, but they change colour at slightly different times.

I note that there is a MQTT group sync option - would this mean that all lights change colour at the same instant? If so, how does it work, as I can't find anything on this setting? :)

xoseperez commented 6 years ago

Removing milestone: 1.11.4 (automated comment)

xoseperez commented 6 years ago

Released with 1.11.4

xoseperez commented 6 years ago

Original comment by Ian Cunningham (Bitbucket: iancun, GitHub: iancun):


Oh, good idea! I've not heard of ESPNow, so I'll have a read of this technology now.

xoseperez commented 6 years ago

One solution I can think of is to sync times between them too. That should be done outside MQTT but maybe NTP feature already provides an accurate timing. Then the message should contain the action to perform ("change color to ...") and the time to perform it ("19:23:34"). The sender of the message with set that time to a few seconds in the future (2, 3 seconds).

Another option would be to perform the sync by other means (not MQTT). UDP or ESPNow come to mind.

xoseperez commented 6 years ago

Original comment by Ian Cunningham (Bitbucket: iancun, GitHub: iancun):


Many thanks :).

Is it possible to sync the moment that the changes happen (i.e. all controllers initiate changes at the exact instant), or will there always be some variability with changes? At the moment, the controllers initiate changes within around 1 second of eachother, but out of sync. Perhaps this is more complex than I realise ;).

xoseperez commented 6 years ago

You can now sync colors too. The code is in the dev branch and will be released soon.

xoseperez commented 6 years ago

At the moment only status is sync'd between devices, not colors, but I'll try to add this option soon. Anyway if you are concerned about timing it won't solve the issue since it will depend on when the device receives and processes the message.

chryss44 commented 6 years ago

Hi Xose, Yesterday i used Group MQTT on my Sonoff and have a strange reaction on my broker (Jeedom). I have permanently this message : [2018-02-02 13:07:21][DEBUG] : 16 : Client jeedom received PUBLISH (d0, q0, r1, m0, 'ESPURNA_TEST/status', ... (1 bytes)) [2018-02-02 13:07:21][DEBUG] : Message 0 sur ESPURNA_TEST/status [2018-02-02 13:07:21][INFO] : Message texte : 0 pour information : status sur : ESPURNA_TEST [2018-02-02 13:07:21][DEBUG] : 16 : Client jeedom received PUBLISH (d0, q0, r1, m0, 'jardin', ... (1 bytes)) [2018-02-02 13:07:21][DEBUG] : Message 0 sur jardin [2018-02-02 13:07:21][INFO] : Message texte : 0 pour information : jardin sur : [2018-02-02 13:07:21][INFO] : Saving device [2018-02-02 13:07:21][ERROR] : Le nom de l'équipement ne peut pas être vide : MQTT Object ( [id:protected] => [name:protected] => [logicalId:protected] => [object_id:protected] => [eqType_name:protected] => MQTT [eqReal_id:protected] => [isVisible:protected] => 0 [isEnable:protected] => 0 [configuration:protected] => {"topic":"","type":"topic"} [timeout:protected] => 0 [category:protected] => [display:protected] => [order:protected] => [comment:protected] => [_debug:protected] => [_object:protected] => [_needRefreshWidget:protected] => [_timeoutUpdated:protected] => [_batteryUpdated:protected] => [_cmds:protected] => Array ( ) ) [2018-02-02 13:07:21][DEBUG] : 16 : Client jeedom sending DISCONNECT

Can-you help me ?

chryss44 commented 6 years ago

Hello, I have found solution to clean the message, i put front my group. I Explain, If you just put a single word (like jardin for me) on the name of group, mosquitto don't like it and you have a ERROR message every second :-((((. If you don't want have a ERROR message, put another word and "/" front of your first word (like sonoff/jardin) and the ERROR message desappear. If this help everybody ;-).