Offline Zigbee device notifications in Zigbee2MQTT

Поделиться
HTML-код
  • Опубликовано: 5 апр 2024
  • Sometimes Zigbee devices drop off the network. How do you know that this has happened without waiting for an automation to fail?
    ❤️ Found this video useful and want to support the channel? I'd love a donation at paypal.me/homeautomationguy
    Links:
    Full article for this video: www.homeautomationguy.io/blog...
    Improving your Zigbee network reliability (Rock Solid Zigbee): • Improve Zigbee network...
  • ХоббиХобби

Комментарии • 93

  • @yousaf.saleem
    @yousaf.saleem Месяц назад +11

    how to do the same in zha? currently, I have only one zigbee device and I am using zha will migrate to z2m when I am using more devices

  • @StevenMackenzie
    @StevenMackenzie Месяц назад +1

    Great to see you sharing some Zigbee2MQTT content - I'd been looking at the disabled Last Seen attributes in HA and wondering what useful things I could do with them

  • @waynenocton
    @waynenocton Месяц назад +2

    This video is absolute gold!

  • @gregthetiger3441
    @gregthetiger3441 Месяц назад

    Your videos are useful, simple and to the point. Thank you, well done for your work 👍

  • @bobellison2547
    @bobellison2547 Месяц назад

    I found this really useful. Thanks very much!

  • @eduardosaavedra2413
    @eduardosaavedra2413 Месяц назад +2

    Thanks a lot Alan, very helpful :).
    BTW if by any chance activating the last_seen flag doesn't work for you by modifying z2mqtt config file, you can always do that by going to the settings -> entities menu, and the filter by "last_seen" and integation = MQTT. Then you can just select all, and enable the entity ;).
    Keep up the good work!

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Thanks for the tip! I didn't know that!

    • @colincheng6674
      @colincheng6674 6 дней назад

      I wish I had read this earlier. The config file did not work for me and so I tediously enabled the last_seen entity 56 times.

  • @KeithConley
    @KeithConley Месяц назад

    This is a timely video as I've even troubleshooting some Zigbee availability issues on my network. I'll be checking out your article for sure.

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Check out the other video I made, linked in the description, which gives more tips on how to make your network more stable and reliable.

  • @gerryf7015
    @gerryf7015 Месяц назад

    Excellent video, presentation, and documentation. Really upped the game. Thanks.

  • @Joseph-ko2kl
    @Joseph-ko2kl Месяц назад

    What a great Idea! This is super helpful.

  • @davidgeorge4
    @davidgeorge4 Месяц назад +2

    Great video, been looking for something to help track possible issues with my network and this is what I needed! Especially the template sensor, really useful.
    Two suggested alterations to the final line of the template are to new line separate the list and truncate the output: {{ result.sensors | join('
    ') | truncate(254, True) }}
    The first is more cosmetic to make each zigbee device show on its own line, the second is fixes an issue where if the output is longer than 255 chars the sensor errors to 'unknown' instead of showing anything. This would likely happen if 5+ devices are offline.
    I also edited the final automation to send a positive notification if everything is online using an if condition on the template sensor, if no devices are offline the template is empty:
    {% if not states('sensor.offline_zigbee_devices') %}
    All Zigbee Devices Online!
    {% else %}
    The following Zigbee Devices are offline:
    {{ states('sensor.offline_zigbee_devices') }}
    {% endif %}

    • @xbmcnut
      @xbmcnut Месяц назад

      Do you have that full code online anywhere David?

    • @davidgeorge4
      @davidgeorge4 Месяц назад

      @@xbmcnut If you mean the template sensor, its identical to what is in the video (and can be copied in the blog post), except the final line, which is replaced by {{ result.sensors | join('
      ') | truncate(254, True) }}
      As for the automation, that is also identical to the video and blog post except for what I posted in my original comment. My full automation is below, just change sensor.offline_zigbee_devices to whatever your template sensor is called, and notify.phone to whatever device you want to send the notificaiton to.
      alias: Notify Change in Offline Zigbee Devices
      description: >-
      Send a notification to a device when 1 or more zigbee devices are deemed to
      be offline, or all come back online.
      trigger:
      - platform: state
      entity_id:
      - sensor.offline_zigbee_devices
      condition: []
      action:
      - service: notify.phone
      metadata: {}
      data:
      message: |-
      {% if not states('sensor.offline_zigbee_devices') %}
      All Zigbee Devices Online!
      {% else %}
      The following Zigbee Devices are offline:
      {{ states('sensor.offline_zigbee_devices') }}
      {% endif %}
      mode: single

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Those are really great additions to the template sensors. I'm gonna steal those and update my article! (With full credit to you of course) ❤️

  • @peterwurst45346
    @peterwurst45346 Месяц назад

    Thanks for the great content, this is something I have already missed in my smart home. Sad it's no default but with this video easy to achieve

  • @CheaperSmartHomes
    @CheaperSmartHomes Месяц назад

    Love your work

  • @the_smart_home_maker
    @the_smart_home_maker Месяц назад

    Nice video! Would be great to extend this to ZHA

  • @heiaheiaheiahei
    @heiaheiaheiahei Месяц назад

    Thanks!

  • @Novation681
    @Novation681 15 дней назад

    This is really great and works fine, thanks! Any chance you can filter out sensors in your script, in the similar fashion that you do in the blueprint?

  • @StevenMackenzie
    @StevenMackenzie Месяц назад

    It's very frustrating when devices drop off the network for no obvious reason (like Aqara THP sensors - where do they keep going?) - I have a theory that I might have one or two unreliable router devices on my network, or compatibility between end devices and particular routers. I'd love to replace the unreliable routers in my network - if I could tell what they were! It would be really cool to see how to add "last connected router device" in your notifications? If I keep seeing the same router in the missing device notifications then I know something's not right with it.

  • @emms-place
    @emms-place Месяц назад

    Awesome video. Now I don't have to check every morning if there are any offline devices

  • @Ellghee
    @Ellghee Месяц назад

    Thanks

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад +1

      Thank you so much for your donation! I really appreciate the support 🙏

  • @EsotericArctos
    @EsotericArctos Месяц назад +1

    The 10 minute ping is only activated if the Zigbee device doesn't check in during that time. Most powered devices checkin more regularly than that, so it would only be for odd devices that the ping would be triggered for. It would't really affect bandwidth much. Powered devices just sending their current status is classed as a checkin. 🙂

  • @colincheng6674
    @colincheng6674 Месяц назад +1

    I couldn't agree with you more - there is absolutely no reason to regress back to caveman behaviour! We need to reclaim our right to be pathetically lazy! All joking aside, this is a great resource for knowing when our devices go offline. I had previously been obsessively checking on a daily basis to see what devices are offline - this will help address these issues immediately. Perhaps you might create a separate video on why ZigBee devices go offline and how to prevent this?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Take a look at the "Creating a rock solid Zigbee network" video which is linked in the description. It mentions the top reasons why they go offline.

  • @deansiddall3729
    @deansiddall3729 Месяц назад

    How has the aqara h1 been performing. Also how did you get around the 2 switching, was it software only?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      They've been performing great! I have to use Home Assistant to "Simulate" the two way switching with Automations, and that is a pain. But I honestly never use the switches, all the lights are triggered by automations. I left the two way switching cables in the walls in case I move out or want to replace the switches in future.

    • @deansiddall3729
      @deansiddall3729 Месяц назад

      @@HomeAutomationGuy Thanks for the reply. i have the switches but the 2 way situation is really annoying and would like dumb switches to work still for WAF. Also had to get a hub because HA didn't want to play ball, decoupled mode seems to just make them not work.
      love your videos, keep them coming.

  • @Kliptrech26Rg001
    @Kliptrech26Rg001 Месяц назад

    your video helped me a lot, I appreciate a lot for privacy on the mobile device and try to avoid data collection from Google other Bigtechs, I saw that you use the Pixel 6, in the case of Home Assistant we know that it has some trackers the official version, the, which version of the mobile APP do you use Home Assistant to avoid trackers and data collection from bigtechs (type google, amazon, etc) ? Or do you use the standard version of Home Assistant on mobile ?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      I use the standard version of the app on my mobile. I am sure it tracks some of my usage, but I use so many Google products that this is unavoidable for me. I'm trying to limit the amount that I am tracked, rather than try to eliminate it entirely.

  • @MrCBRXX1100
    @MrCBRXX1100 Месяц назад

    Nice tip and video. The automation works as expected. But it notifies me, when devices go offline. Is it possible to make an automation, which says - hey - "Bedroom lamp" went online again - or something similar?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад +1

      You can add this to your notification automation to alert you when all devices come back online, but not each one individually without doing way more code magic:
      {% if not states('sensor.offline_zigbee_devices') %}
      All Zigbee Devices Online!
      {% else %}
      The following Zigbee Devices are offline:
      {{ states('sensor.offline_zigbee_devices') }}
      {% endif %}
      Props to @davidgeorge4 for this extra piece of logic elsewhere in the comments.

  • @dinth
    @dinth 12 дней назад

    Sorry but does changing timeout from 10 to 20 min in advanced Availability settings actually changes the frequency the devices are being pinged?

    • @HomeAutomationGuy
      @HomeAutomationGuy  11 дней назад

      I think so? The Zigbee2mqtt documentation seems to suggest that

  • @Ellghee
    @Ellghee Месяц назад

    I do not get your helper to work, I cut and past from your blog. It shows unavailable. Is the issue that I run 24 hrs clock? If so how do I modify it?

    • @Ellghee
      @Ellghee Месяц назад

      @@HomeAutomationGuy This ended up under my question, I dont´t think it was intended as an answer to me??

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад +1

      Nope! I typed into the wrong box sorry 🤦‍♂️
      I don't think a 24 hour clock should cause any problems. I'm sorry I don't know why it's not working

    • @Ellghee
      @Ellghee 27 дней назад

      @@HomeAutomationGuy Whe I stated adding the units one by one, they showed up!

  • @Warhoon
    @Warhoon Месяц назад

    For some reason the template sensor isn't working for me. Z2MQTT shows all the "last seen" attributes. When I paste your code into the new template sensor it seems to parse ok. The preview in the template sensor yaml box shows "Domain: sensor" then two entities that don't make sense to me: "sensor.node_5_last_seen" and a second item "sensor.plug_in_appliance_module_last_seen" which is a Z-Wave device. Does anyone have any suggestions?

    • @Warhoon
      @Warhoon Месяц назад

      More info: z2MQTT reports nothing offline. When I deliberately unplug a router device, it shows up as unavailable in z2MQTT but not in the template sensor preview.

  • @trevsweb
    @trevsweb Месяц назад

    instead of comma seperation in the list how can I set it as separated lines? can I use html?

    • @B-a_s-H
      @B-a_s-H Месяц назад +1

      I think you can use join('
      ') to get seperate lines. Also HTML should be possible, but I think Jinja auto-escapes HTML (check the docs on that). Answering from phone, so not able to test atm.

    • @mariopalma3802
      @mariopalma3802 Месяц назад +1

      try this in the notify, w/o changing anything else:
      message: >-
      "The following Zigbee Device(s) are Offline:
      - " {{
      states('sensor.z2m_offline_devices') |replace(", ","
      - ") }}

  • @RichDurso
    @RichDurso Месяц назад

    Script is working fine, I get notifications. However, upon HA restart I get some ugly stack traces from the script. Too long to cut & paste here, but they look like"2024-04-17 14:02:06.341 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('ValueError: Template error: as_timestamp got invalid input 'unknown' when rendering template '{% set result = namespace(sensors=[]) %}" script need a bit more filtering? or default timestamp value?

    • @RichDurso
      @RichDurso Месяц назад

      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2047, in forgiving_as_timestamp
      raise_no_default("as_timestamp", value)
      File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1849, in raise_no_default
      raise ValueError(
      ValueError: Template error: as_timestamp got invalid input 'unknown' when rendering template '{% set result = namespace(sensors=[]) %}

  • @JamesMyatt1
    @JamesMyatt1 Месяц назад

    I assume that the new entity labels will help with these sorts of automations and templates (soon)

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Possibly! I'm still learning the best way to play with these.

  • @Girbie1973
    @Girbie1973 Месяц назад

    I ran into an interesting issue: I created the template helper as per your instructions. However, I have currently quite a number of devices unavailable (I know the cause, so that itself is not an issue). The template gives now the following error: Invalid state with length 1181. State max length is 255 characters. Clearly it is time to repair my zigbee network...

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад +1

      I recently updated the article with some feedback from another commenter on my video to fix this. If you change the last line you can truncate it to fit. You should see this updated on the linked article too.
      {{ result.sensors | join('
      ') | truncate(254, True) }}

  • @samueldaniels5223
    @samueldaniels5223 Месяц назад

    My template sensor isn’t showing anything, and I have devices offline. What have I done wrong?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Unfortunately that's hard for me to help with since I'm not able to see your environment or devices. I'd try playing with the template in Developer Tools in Home Assistant and seeing if you can get results in there. Sorry I can't be more helpful!

    • @samueldaniels5223
      @samueldaniels5223 Месяц назад

      @@HomeAutomationGuy I figured it out. Apparently over the last couple of years both the last seen entity and link quality of ZigBee devices has been disabled by default in HA, so you need to enable them in your entities list by filtering it by disabled and then using those search options. Works like a charm now. Thanks!

    • @samueldaniels5223
      @samueldaniels5223 Месяц назад

      @@HomeAutomationGuy - I’ve got the sensor working but any idea why I get bombarded every couple of days with the notification? I get a bunch of devices saying they’re unavailable all at once. What might be happening within might network to cause that? They don’t go offline, they just say they’re unavailable but that changes once they triggered again.

  • @mrxmry3264
    @mrxmry3264 Месяц назад

    I have a weird problem: every 3 hours 2 of my zigbee sensors become unavailable and then come back about an hour later, and I have no idea why they're doing that. I've ruled out EM interference because a) they don't drop out at the same time and b) this problem does not affect any other zigbee devices. Low batteries can be ruled out too because both of them report 100% battery.

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      That's frustrating! I would be careful about ruling out battery, because I often have things report 100%, and then the next day report 2%, and then 20% etc. Try replacing the battery in one of them to see if that fixes it.
      Otherwise I'd see if you can add a router device nearby, like a smart bulb or something else that is mains powered, to see if strengthening the network makes it more reliable.

    • @mrxmry3264
      @mrxmry3264 Месяц назад

      @@HomeAutomationGuy i found out what it was. i set the timeout for battery powered devices to 2 hours but if nothing changes the sensors only report in every 3 hours. so after 2 hours home assistant considered them unavailable even though they were just doing their normal thing. now i've set the timeout to 4 hours, and they work normally again.
      but this doesn't explain why my synology add-on keeps reporting its entities as unavailable (and this one doesn't come back by itself).

  • @Matte_olo
    @Matte_olo Месяц назад

    In Diagnostic I don't have "Last Seen" why?

    • @spug68
      @spug68 Месяц назад +1

      I noticed in Mr. Groch Blueprint, needed to set to ISO8601_Local, and then I needed to double check when I added the yaml lines to the Configuration.yaml for zigbee2mgtt that it was saved. Restarted Zigbee2mqtt and the sensor is now there :) Hope that helps!

    • @Matte_olo
      @Matte_olo Месяц назад

      It works thanks

  • @edcoppen
    @edcoppen Месяц назад

    Awesome video! Can the code on the Z2MQTT yaml file go anywhere within it please?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      Almost. It has to be indented correctly and not nested under another important thing. I'd try and stick it right at the end to be safe.

  • @louisviciedo
    @louisviciedo Месяц назад +2

    Great video only MQTT not ZHA?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      I am unfortunately not sure how to make it work with ZHA as I don't use it in my smart home. If someone knows how hopefully they share it in the comments!

  • @rodrigomarins273
    @rodrigomarins273 Месяц назад

    Hi! Very nice. I tried but cant conclude. The action message is giving error. Any tips?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      What's the error?

    • @rodrigomarins273
      @rodrigomarins273 Месяц назад +1

      @@HomeAutomationGuy I tried to follow your video and blog but got confused in the "Then" part of your automation. I didn't understand how to do this part.
      I tried to copy the code you put in the video (replacing the name of the ID). However, some kind of syntax error occurred: "template value should be a string for dictionary value @ data['message']. Got None". Could you explain this part again, please?

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад +1

      @@rodrigomarins273 Sorry about that, I've edited the post to try and make it clearer. You’ll need to select the right service from the list for your Home Assistant mobile app notification service to send the notification, and then in the message part you’ll need to make sure you edit the {{ states(‘sensor.z2m_offline_devices’) }} part to use the sensor you created earlier. I hope this helps

    • @rodrigomarins273
      @rodrigomarins273 Месяц назад

      @@HomeAutomationGuy Thanks so much! 😀🙏

  • @Whoop0
    @Whoop0 Месяц назад

    That's a loooot of zigbee devices. I'd be interested in how you've resolved the problem with Zigbee lights, where upon turning them on they revert to their previous state (temperature/brightness) before transitioning to their new state so you get some dodgy flashing lights initially.

    • @BeardAndCap
      @BeardAndCap Месяц назад

      Not entirely sure if I understand what you are running into, but I use the HACS integration "adaptive lighting" to automatically change the color temperature of my lights. I both wifi and Zigbee lights from multiple vendors (wled, Philips, ikea, Aqara, MiBoxer), and so far have not run into any major issues.

    • @Whoop0
      @Whoop0 Месяц назад

      @@BeardAndCap I use adaptive lighting too, that works awesome if you leave your lights on through the day. However if you turn them off, then on again hours later they will start with the previous colour before adaptive lighting kicks in and changes to the new

    • @BeardAndCap
      @BeardAndCap Месяц назад

      @@Whoop0 Ahh, yes that is true. However for me the "old state" always transitions to the new state quite smooth without any flashes. On occasion I do run into a unresponsive light where the light won't turn off (forcing me to do a "turn off", "turn on") before the light is responsive again.

    • @Whoop0
      @Whoop0 Месяц назад

      @@BeardAndCap even if smooth it’s pretty horrible if you for example turn on at 7am then next 11pm, blinded before it transitions. Wish I could work out how to fix, native Hue doesn’t have this problem.

    • @HomeAutomationGuy
      @HomeAutomationGuy  Месяц назад

      My Hue lights and Candeo zigbee dimmers don't seem to do that. I use the light.turn_on service in Home Assistant, and assign a brightness level in that.