MQTT Retained Messages - The Love Hate Relationship - Tasmota Tips Episode 1

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2024
  • In the first installment of our Tasmota Tips series we show examples of when you don't want a retained message and when you do utilizing a 5 relay Teckin Power Strip. Also learn how to clear your previous retained messages with ease!
    Teckin Power Strip - amzn.to/2RfsBS6 (RTL based now and not ESP8266..do not buy)
    Teckin Outdoor Dual Relay - amzn.to/2FcirwV
    Products I use and recommend - www.amazon.com...
    Tasmota Device Templates - blakadder.gith...
    Come chat with us!
    -=-=-=-=-=-=-=-=-=
    Discord - / discord
    Patreon - / digiblurdiy
    MQTT Explorer - mqtt-explorer.com/
    Tasmota MQTT Sample Configs - github.com/dig...
    Home Assistant Automation
    -=-=-=-=-=-=-=-=-=
    - alias: "Tasmota State on HA Restart"
    trigger:
    platform: homeassistant
    event: start
    action:
    - service: mqtt.publish
    data:
    topic: "cmnd/sonoffs/backlog"
    payload: "power1 ;power2 ;power3 ;power4 ;power5; dimmer; state " Please note, the product links above could be affiliate links, using them could earn digiblurDIY a small commission of purchases potentially helping with future video projects. Thank you! As an Amazon Associate I earn from qualifying purchases. Please note, the product links above could be affiliate links, using them could earn digiblurDIY a small commission of most purchases and helps with future video projects. Thank you! As an Amazon Associate I earn from qualifying purchases.

ความคิดเห็น • 101

  • @iot_enthusiast
    @iot_enthusiast 5 ปีที่แล้ว +1

    Retain is a subtle, mostly misunderstood mqtt concept, until I saw this explanation. As I look forward to more tips and tricks, this one , is brilliantly done.

  • @dannewcomb8810
    @dannewcomb8810 5 ปีที่แล้ว +1

    The timeliness of this video is uncanny. I was just experiencing this issue on that exact same model power strip. I had flipped some flags, but hadn't figured the rest out yet. Thanks for the great videos, and keep it up.

  • @jimbrewer5821
    @jimbrewer5821 5 ปีที่แล้ว +1

    Travis, thanks! How timely! This has been driving me CRAZY! (as well as worried that a reboot or reconnect would inadvertently open my garage doors while I was away from home). Great video (as usual). I think I am finally beginning to understand MQTT with helpful well-explained videos like this. When people (and I also include myself) first start off in Home Assistant, it's easy to overlook developing a fundamental understanding of MQTT and go right to "making stuff work". This ultimately comes back to bite you 6 months down the road when you're trying to figure out why certain devices behave differently than others. I'm looking forward to more of your Tasmota Tips videos. Thanks again - well done!

  • @dadrad
    @dadrad 5 ปีที่แล้ว +1

    This is a great explanation of MQTT retain. I found that I had it enabled on three of my Sonoffs, but only really needed it on one of them. Thanks Travis!

  • @snowchaser75
    @snowchaser75 5 ปีที่แล้ว +1

    Thanks mate. I knew I had a retain issue, thanks to The Hookup video, but his method to clear it didn't work. This way worked perfectly.

  • @stang70man
    @stang70man 5 ปีที่แล้ว +1

    Thank you so much for the great video! I watched this the day it came out. Last night at 12:38am, our bedroom lights came on. Sure enough, retain was set and it lost wifi for a moment and came on. You saved me!

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว +1

      Thanks for the feedback and real life scenario! Makes this hobby enjoying and time to teach this all worth it!

  • @bulldog3494
    @bulldog3494 5 ปีที่แล้ว +2

    Thanks Travis, you answered a couple of problems I was dealing with. I think you should change your name to Dr. Tasmota!

  • @cleberam
    @cleberam 5 ปีที่แล้ว +1

    Really good and informative, excellent job, thanks! Those 20 minutes save hours of troubleshooting and frustration.

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว +2

      Thanks! I had plans for a 10 minute or less video but then I wanted to show the problem, the why, the fix and then the show it solved so it got kinda long.

  • @1binlids
    @1binlids 5 ปีที่แล้ว +1

    What a fantastic explanation of retained messages Travis, easiest way to check & clear out I have seen, keep up the great videos.

  • @AnoNymous-lp5tb
    @AnoNymous-lp5tb 5 ปีที่แล้ว +1

    Holy shit! You always gave us enlightenment! I should call you budha for tasmota! I had inching switch flash with tasmota and i used it as a garage opener but I found my garage wide open one day so i disconnected it and never put it back again. You might solved my problem. Will mess with it later this afternoon and will see if that's the problem.

  • @paulmurphy3735
    @paulmurphy3735 3 ปีที่แล้ว +1

    Just love both of your mqtt videos. So clear and packed with really helpful tips and advice. Just keep learning watching your tutorials. Many thanks again 🙏

  • @shaunwhiteley3544
    @shaunwhiteley3544 5 ปีที่แล้ว +1

    Excellent, just excellent! Thank you so much for this! Cheers

  • @imike964
    @imike964 4 ปีที่แล้ว +4

    Dude, you are awesome!

  • @crazywux
    @crazywux 5 ปีที่แล้ว +1

    very helpful, you mention esphome. For those that wish to dodge MQTT can you follow up video how retains work with esphomes native API.

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว

      I use MQTT with Esphome myself as I skip going through home assistant to control my devices. I don't think there are any retain issues with the way the API is designed. That does raise a question now though if I flashed a switch with Esphome does it have its own powerretain option and not have the retain command message issues.

  • @laurentmathivet1214
    @laurentmathivet1214 3 ปีที่แล้ว +1

    Really nice video ! You're a naturally born teacher :D ! Merry Christmas to all

  • @lmamakos
    @lmamakos 5 ปีที่แล้ว

    One reason why you'd want to have Home Assistant send MQTT messages with the RETAIN option is to arrange to have the device you're controlling restore its state when it reboots. Say you have a power switch or a light bulb that doesn't have any local storage that remembers if it's "ON" or "OFF". And then power in your house glitches and the device reboots. Would you like it to come back up with the same state as before (e.g., the light is turned back on?) That's when you'd like the last command that was sent to the device have the RETAIN option set. Then the broker will keep the last retained message to the topic stored and when a device connects and subscribes to the topic, it will get that retained message sent it. And that will restore it to the last commanded state.
    It really has little to do with an interruption in network connectivity; I'm not sure what exactly that was trying to provoke.

    • @JimDumser
      @JimDumser 5 ปีที่แล้ว

      If the retained message was TOGGLE, it still wouldn't work as desired. Only if you could ensure that ON or OFF were retained would it work as desired.

    • @lmamakos
      @lmamakos 5 ปีที่แล้ว

      @@JimDumser There is no TOGGLE message to the MQTT command topic for a light or switch. TOGGLE is a local concept that inverts the current state and commands the device to the inverse. If you look at, for example, www.home-assistant.io/components/switch.mqtt/ you'll see that you can specify the payload for "ON" and "OFF" and there is no notion of a toggle operation at this level.

  • @ufootje
    @ufootje 3 ปีที่แล้ว +1

    very good. this was a real eye opener for me!

  • @squalazzo
    @squalazzo 5 ปีที่แล้ว +1

    excellent, very clear, thanks Travis! :)

  • @Rickr522
    @Rickr522 5 ปีที่แล้ว +1

    Super helpful and another video well done. Thanks!

  • @jc-zh9kl
    @jc-zh9kl 3 ปีที่แล้ว

    awesome thanks youre the man, worked perfect! Rob needs to put a link to this video in his video so people are bashing their heads trying to figure out why it aint workin haha

    • @digiblurDIY
      @digiblurDIY  3 ปีที่แล้ว +1

      I had to show the why and the how on this one to show the issue as that is my way of things. The various guides out there that do nothing except randomly copy and paste some commands is quite laughable as the creator of said guide doesn't even understand it him/herself so how can they teach it? Hmmm...

  • @reiserx
    @reiserx 11 หลายเดือนก่อน

    I have a similar issue of an esp32 hooked to my old alarm box to use as a door and window sensor switch. It doesn't use the power cmnd because it's used for 11 switches. I have rules to make it output as a switch. i.e. "Rule1 on Switch1#State do Publish2 stat/door_sensor/1 %value% endon on Switch2#State do Publish2 stat/door_sensor/2 %value% endon" etc. Any idea on the difference in the yaml automation to make that work. I tried switch1 ;switch2 ; instead of power1; power2 ; . didn't work. Upon restart they are always unknown until opened or closed.

  • @kevincostner8536
    @kevincostner8536 5 ปีที่แล้ว +1

    Nice video, man! Thanks!

  • @ilducedimas
    @ilducedimas 3 ปีที่แล้ว +1

    You rock ! Thanks so much

  • @aliaghil1
    @aliaghil1 5 ปีที่แล้ว +1

    well done, thanks for your good video.

  •  5 ปีที่แล้ว +1

    You're a life saver!

  • @madrian_hello
    @madrian_hello 5 ปีที่แล้ว +1

    Very nice guide. 👍

  • @gmaclean1
    @gmaclean1 3 ปีที่แล้ว +1

    With more recent versions (9.4 currently) is there any benefit to retain now? It looks like my states are kept through reboot by default now :)

    • @digiblurDIY
      @digiblurDIY  3 ปีที่แล้ว +1

      Depends on how you are doing integrations and such. MQTT retains will always be a thing even if automatically done for you.

  • @nigelholland24
    @nigelholland24 5 ปีที่แล้ว +1

    Another great video thanks

  • @mikebusch9307
    @mikebusch9307 4 ปีที่แล้ว

    Brilliant ;0))) best explanation heard until now ;0))) and it works ;0))))

  • @vaughanza
    @vaughanza 4 ปีที่แล้ว

    Thanks for another great video. I am trying this with my Sonoff Bridge and the door sensors but unable to get it to work. My door sensors ( on & off sensor ) shows a closed-door after a restart. Please can you do a video on the RF Bridge and be able to get the correct state of the door after a restart. Would really appreciate it.

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว

      I have one on the Sonoff RF bridge and the publish2 command should accomplish that.

  • @waynenocton
    @waynenocton 3 ปีที่แล้ว +1

    Oh man this is a good one!

    • @waynenocton
      @waynenocton 3 ปีที่แล้ว

      My switches are now correct, all the time as far as I can tell, love it! You're the best!

  • @nvdwalt
    @nvdwalt 3 ปีที่แล้ว +1

    I love this one awesome bud

  • @stephennutt2565
    @stephennutt2565 4 ปีที่แล้ว +1

    I swear I saw a video of you flashing this Teckin power strip but I cannot find it. Am I crazy? I even remember a discussion that the Ground Tx Rx and Power are mis-labeled on some.

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว

      Hmm... maybe a live stream or something? I don't recall the RX/TX being backwards though, thought was a sonoff thing on some of their devices.

  • @johnathanwee6334
    @johnathanwee6334 5 ปีที่แล้ว

    This clears up the frustrating mystery whenever I restart my openhab. Can anyone help with an openhab rule that does the same for the HA automation?

  • @rvfortwo5565
    @rvfortwo5565 5 ปีที่แล้ว +1

    Hey, Travis. Thanks for the helpful video. Can you share the Tasmota template for the strip you are using? I have the same strip, but the button only turns on outlet 1 and I can't figure out how to configure the module for the USB off/on. Thanks.

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว

      That can get to be more of something with rules. What do you want to turn on and off with the button?

    • @rvfortwo5565
      @rvfortwo5565 5 ปีที่แล้ว

      @@digiblurDIY I found your post about the module settings on GITHUB. I think I have it figured out. Thanks for the fast response.

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว

      Good deal. The Tasmota template site is great for device configs.

  • @johnbrumfield6212
    @johnbrumfield6212 2 ปีที่แล้ว

    Awesome!!! Awesome! Regarding retain, I did the shelly 1 garage project. Under the use-case when the shelly loses power when the door is down, before it is powered up, the door is put up manually. After it is powered up how do you obtain the initial state of the sensor contact (open) when it was (closed) before it lose power?

    • @digiblurDIY
      @digiblurDIY  2 ปีที่แล้ว +1

      You'd need a rule to fire on boot/mqtt connect the state of the reed switch.

    • @johnbrumfield6212
      @johnbrumfield6212 2 ปีที่แล้ว

      @@digiblurDIY Thank you!!!

  • @StePhanMckillen
    @StePhanMckillen 5 ปีที่แล้ว +1

    10 out 10

  • @shaunwhiteley3544
    @shaunwhiteley3544 5 ปีที่แล้ว

    On this series, could you show how to run 2 separate Hassio sessions on one MQTT broker, I really want a dev setup so I’m not annoying my partner when I’m experimenting 😢. Cheers

  • @drreality1
    @drreality1 5 ปีที่แล้ว

    Great video again thanks so much.
    I wonder how esphome handle power and state changes during WiFi and restart scenario?
    Cheers man

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว +1

      Not really sure on that one as all of my esphome installs are mainly sensor based and don't have power states.

  • @tota5
    @tota5 5 ปีที่แล้ว

    hey, great video!
    Ive been having some serious problems with my espurna lights with mqtt! From time to time, when a reboot happens, when it gets back up, those lights just stop being responsive to the mqtt commands.
    I opened the mqtt explorer to see whats going on, and hooked up into the espurna debug to see what might be happening, and as it seems, its like the lights didnt get connected again after the broker rebooted.
    That does not happen with my tasmotized sonoffs, ever...they are always responsive.
    Do you have an idea on how to start tackling this? This problem is making the smartlights unusable as a true alternative to regular lights, as my wife is not happy at all about having the lights completelly stop working once a week...
    Thank you!

  • @rabidbunny3025
    @rabidbunny3025 ปีที่แล้ว

    Very informative, I have an issue with some of the newer Tasmota Builds though. On the later versions (12+) it seems that the Sonoff 4ch Pro R3 - always powers ON Channel 4 Relay, but when looking at HA, it shows the Channel 4 Relay is OFF, this is also true when being connected to the device through the Tasmota WebUI, but on the actual device it shows that Channel 4 is powered ON, and testing the relay it is actually ON.
    I have checked logs and there are no retain messages, how will I go about to raise this issue with the guys over at Tasmota?
    (previous firmware versions did not do this) ... thanks for you help!
    PS: you can easily simulate the scenario, just power the 4CH Pro R3 wait for a successful network connection, then disconnect the power and return power after a minute or two and you will also note the same on the newer Tasmota firmware versions.
    Side-note: SO0 = OFF (so even on software level / firmware level the state should not be "remembered")

    • @digiblurDIY
      @digiblurDIY  ปีที่แล้ว

      I would try their github issues or discussions section if you want to raise something over there. I don't have the Pro model to try this out myself. I assume you are using the HA Tasmota integration?

    • @rabidbunny3025
      @rabidbunny3025 ปีที่แล้ว

      @@digiblurDIY ... yes, using Tasmota HA integration. I'll try raise an issue there. Oddly it used to work on previous firmware versions ... :)
      And It's an issue on 5 x of those units always Channel 4 Relay being turned ON after a power failure restore.
      I can't replicate the issue with stock Sonoff firmware though.

  • @PersonXes
    @PersonXes 3 ปีที่แล้ว

    Very helpful video. Your automation to get the states of the devices after a reboot in case a device sent a message during the reboot isn't necessary when you set QOS to level 2 right? The device would keep trying to send the message untill the MQTT broker in home assistant has rebooted and is ready to receive the message.

    • @digiblurDIY
      @digiblurDIY  3 ปีที่แล้ว

      That issue isn't due to QOS.

  • @alex10pty
    @alex10pty 4 ปีที่แล้ว

    Hi thanks for the video it was really helpfull. In that power strip (or any other) is possible to read the power comsumption of each induvidual plug or it reports the total of all the devices connected?

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว

      No power monitoring on that strip.

  • @olegafanasiev9959
    @olegafanasiev9959 5 ปีที่แล้ว +1

    Хорошее видео. ! )

  • @abbv2x
    @abbv2x 4 ปีที่แล้ว

    Howdy Travis, I've recently purchased one of these power strips and started to go through the OTA flashing process (which has worked well for me with Gosund plugs and some other switches). This guy refused to work so I figured it was OTA blocked. No worries, your vid's are awesome for showing how to manually flash devices which I've also done with great success. When I pulled this guy apart I noticed they have drastically changed up the design and I would like to share that to the community/tasmota group however I'm not sure of the best way to do this. any suggestions? Thanks!

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว

      Do you have a discord account? You can come share stuff in there. Is that the new model they changed the design and switched to RTL?

  • @rubenhackar
    @rubenhackar 3 ปีที่แล้ว

    hiiii, how can i put the correct percentage of my covers when the wifi goes down and back again? HA keeps the old percentage.

  • @tuinjie
    @tuinjie 4 ปีที่แล้ว

    Hi Travis, brilliant video thank you, I'm a noob to HA, just installed 4 weeks ago, frantically watched many hours of TH-cam videos/read docs to get me up to speed. I think I have fixed 'most' of my issues regarding the retain status, but I have this particular problem on 2 Lohas E27 lamps. Have few others Lohas B22's same Tasmota firmware (7.0.0.3) and those work perfectly. Each time you toggle switch in HA to 'ON' within

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว +1

      Did you turn on setoption59?

    • @tuinjie
      @tuinjie 4 ปีที่แล้ว +1

      @@digiblurDIY Absolutely brilliant Travis, thought I had, clearly not. Love your channel and thank you.

  • @georgelza
    @georgelza 3 ปีที่แล้ว

    I checked my grouptopic is still sonoffs.
    but I did change all my devices a bit... of course I did ;)
    they either */home/light// or */home/plug/
    the command did not do anything, so I pushed it via Tasmota admin the HA plug in. so mission accomplished, just wondering what should my publish command be?

    • @digiblurDIY
      @digiblurDIY  3 ปีที่แล้ว

      Which publish command?

    • @georgelza
      @georgelza 3 ปีที่แล้ว

      @@digiblurDIY publish cmd/sonoff/powerretain 1

    • @georgelza
      @georgelza 3 ปีที่แล้ว

      @@digiblurDIY ... once we get the publish working, then I need to move onto the automation, will ping you on discord tomorrow, easier there.

    • @digiblurDIY
      @digiblurDIY  3 ปีที่แล้ว

      It's cmnd not cmd

    • @georgelza
      @georgelza 3 ปีที่แล้ว

      @@digiblurDIY that was just a type/auto correct here, it was correct when I entered the command in the console.

  • @waynenocton
    @waynenocton 2 ปีที่แล้ว

    I'm having an issue where one tasmota device, always turns on when I restart my Home Assistant Supervised, suggestions anyone?

    • @digiblurDIY
      @digiblurDIY  2 ปีที่แล้ว +1

      Retained mqtt command? Turn on weblog 4 on the console of the device. Watch the console of it and restart HA. Look for the SRC

  • @keithc397
    @keithc397 4 ปีที่แล้ว

    Hi, do i use my duck dns for mqtt-explore or my local IP when adding a connection?

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว +2

      Your local mqtt IP.

  • @JordanReese
    @JordanReese 5 ปีที่แล้ว

    Why use retain if you're just going to poll all the states on reboot anyway?

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว

      To retain all the power states for any reads of MQTT from any application without the need to have HA rebooted.

  • @DrDrewsAdventures
    @DrDrewsAdventures 5 ปีที่แล้ว

    I have my living room light and fan configured with setoption19 but would like to switch to manually entered in my config file. Is there a way to remove an auto discovered device through this method and later re-add it?

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว

      Type setoption19 0 and it removes it.

  • @jayare7750
    @jayare7750 4 ปีที่แล้ว

    So I'm confused, is setoption19 1 bad or good?

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว +1

      That really depends on your setup. SetOption19 is easier but you lose some flexibility and possibly some reliability of staying put. The other method it will always be that name/topic but of course more work and you lose some advanced tunability features you might need on some switches like 3 ways. Try both and pick what works for you.

    • @jayare7750
      @jayare7750 4 ปีที่แล้ว

      @@digiblurDIY Thanks, mostly a complete noob, but I was able to get Tuya-Convert working and currently have about 18 TreatLife SS01S wall switches 2 Treatlife DS01 dimmers and 4 Teckin wall plugs on tasmota.
      I had read that setoption19 1 would help with the auto-discovery, but that was only true with the dimmers. none of my other wall switches were discovered even with setoption19 1.
      I'm thinking of setting it back to 0 through a group topic, but I don't know what affect that will have on my dimmers. if it does, I'll just enable it on the dimmers only.
      As a noob, I really have no idea what setoption19 1 does, even after reading the setoption list a few times.

    • @digiblurDIY
      @digiblurDIY  4 ปีที่แล้ว

      Are you running the full Sonoff build or the one right after tuya-convert? Setoption19 might not be built into that bin file you are running. Come jump into discord and a few of us can help. Don't worry, everyone was a noob at one point. discord.gg/bNtTF2v

  • @onkel_joerg
    @onkel_joerg 4 ปีที่แล้ว +2

    Tasmot AAAAAAA

  • @stoneobscurity
    @stoneobscurity 5 ปีที่แล้ว +1

    BECAUSE you are using "toggle", of course it's gonna get out of sync. using retained is fine as long as you use ON/OFF in the retained.

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว +1

      Right I used toggle on purpose as it would get toggled every time instead of half the time. With an ON or OFF retain it only fails you half the time.

    • @lmamakos
      @lmamakos 5 ปีที่แล้ว

      But there is no "TOGGLE" command ever sent to a device. "Toggle" is an operation that Home Assistant implements, referencing its local state for the device. It then sends a payload_on or payload_off command to the device (as you've configured) to switch it to the other state. See www.home-assistant.io/components/switch.mqtt/

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว

      This was a mock up to cause it to shift each disconnect. Otherwise I would have had to put a retained ON then go toggle it off every time then force the reconnect and that would have made the video longer than it already needed to be.

    • @jobarjo78
      @jobarjo78 5 ปีที่แล้ว

      I don't understand why the switch toggles with the retained message. If the retained message is the previous state, then it shouldn't switch. Can someone explain please?

    • @digiblurDIY
      @digiblurDIY  5 ปีที่แล้ว +1

      Right. It would only switch 50 percent of the time. Only when it differs. Something being broke half the time is better than all the time but still not a good thing.