Offline Zigbee device notifications in Zigbee2MQTT

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

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

  • @StevenMackenzie
    @StevenMackenzie 8 หลายเดือนก่อน +3

    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

  • @eduardosaavedra2413
    @eduardosaavedra2413 8 หลายเดือนก่อน +4

    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  8 หลายเดือนก่อน

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

    • @colincheng6674
      @colincheng6674 7 หลายเดือนก่อน

      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.

    • @techRoom429
      @techRoom429 4 หลายเดือนก่อน

      Thank you for the tip! I had the same issue with the z2m config file not working (or not working fast enough for my patience). I almost started clicking each one automatically, your tip saved a TON of time!

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

      @@HomeAutomationGuy : I have the same issue
      device_options:
      homeassistant:
      last_seen:
      enabled_by_default: true
      does not work. I restarted Z2M and also Home Assistant. What could be the reason? Of course, I can bulk edit all devices, but I would need to edit all new devices manually.

  • @waynenocton
    @waynenocton 8 หลายเดือนก่อน +2

    This video is absolute gold!

  • @davidgeorge4
    @davidgeorge4 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน

      Do you have that full code online anywhere David?

    • @davidgeorge4
      @davidgeorge4 8 หลายเดือนก่อน

      @@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  8 หลายเดือนก่อน

      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) ❤️

  • @KeithConley
    @KeithConley 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน

      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.

  • @MrNickRout
    @MrNickRout 3 หลายเดือนก่อน

    Thank you, this video and the blog post helped me enormously. One comment though, i think the template sensor would better fit in with the way home assistant does things if the state was the number of offline devices, and the list of devices was an attribute. This would eliminate the 254 char limit on state, as that limit does not apply to attributes.

  • @heiaheiaheiahei
    @heiaheiaheiahei 8 หลายเดือนก่อน

    Thanks!

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      Wow! Thank you so much for your support 🙏

  • @speedygreg007
    @speedygreg007 8 หลายเดือนก่อน

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

  • @yousaf.saleem
    @yousaf.saleem 8 หลายเดือนก่อน +12

    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

  • @emms-place
    @emms-place 8 หลายเดือนก่อน

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

  • @Ellghee
    @Ellghee 8 หลายเดือนก่อน

    Thanks

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน +1

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

  • @EsotericArctos
    @EsotericArctos 8 หลายเดือนก่อน +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. 🙂

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      Thanks for the clarification! 🙏

  • @Joseph-ko2kl
    @Joseph-ko2kl 8 หลายเดือนก่อน

    What a great Idea! This is super helpful.

  • @gerryf7015
    @gerryf7015 8 หลายเดือนก่อน

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

  • @bobellison2547
    @bobellison2547 8 หลายเดือนก่อน

    I found this really useful. Thanks very much!

  • @peterwurst45346
    @peterwurst45346 8 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

    Love your work

  • @the_smart_home_maker
    @the_smart_home_maker 8 หลายเดือนก่อน

    Nice video! Would be great to extend this to ZHA

  • @Novation681
    @Novation681 7 หลายเดือนก่อน

    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?

  • @colincheng6674
    @colincheng6674 8 หลายเดือนก่อน +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  8 หลายเดือนก่อน

      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.

  • @JamesMyatt1
    @JamesMyatt1 8 หลายเดือนก่อน

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

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

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

  • @RichDurso
    @RichDurso 8 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      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=[]) %}

  • @StevenMackenzie
    @StevenMackenzie 8 หลายเดือนก่อน

    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.

  • @louisviciedo
    @louisviciedo 8 หลายเดือนก่อน +2

    Great video only MQTT not ZHA?

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      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!

  • @Ellghee
    @Ellghee 8 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

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

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน +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 7 หลายเดือนก่อน

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

  • @Kliptrech26Rg001
    @Kliptrech26Rg001 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน +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.

  • @deansiddall3729
    @deansiddall3729 8 หลายเดือนก่อน

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

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@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.

  • @dinth
    @dinth 7 หลายเดือนก่อน

    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  7 หลายเดือนก่อน

      I think so? The Zigbee2mqtt documentation seems to suggest that

  • @Warhoon
    @Warhoon 8 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

      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.

  • @Girbie1973
    @Girbie1973 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน +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) }}

  • @Whoop0
    @Whoop0 8 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@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 8 หลายเดือนก่อน

      @@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 8 หลายเดือนก่อน

      @@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  8 หลายเดือนก่อน

      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.

  • @samueldaniels5223
    @samueldaniels5223 8 หลายเดือนก่อน

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

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@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 8 หลายเดือนก่อน

      @@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.

  • @nigelnigel.
    @nigelnigel. 2 หลายเดือนก่อน

    Is it really worth all the stress.

  • @mrxmry3264
    @mrxmry3264 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน

      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 8 หลายเดือนก่อน

      @@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).

  • @trevsweb
    @trevsweb 8 หลายเดือนก่อน

    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 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน +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(", ","
      - ") }}

  • @edcoppen
    @edcoppen 8 หลายเดือนก่อน

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

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      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.

  • @Matte_olo
    @Matte_olo 8 หลายเดือนก่อน

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

    • @spug68
      @spug68 8 หลายเดือนก่อน +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 8 หลายเดือนก่อน

      It works thanks

  • @ryanbell85
    @ryanbell85 5 หลายเดือนก่อน

    Do you have a favorite zigbee repeater?

    • @HomeAutomationGuy
      @HomeAutomationGuy  5 หลายเดือนก่อน

      All my powered Zigbee devices work as repeaters, I don't use a specific device as a repeater.

  • @rodrigomarins273
    @rodrigomarins273 8 หลายเดือนก่อน

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

    • @HomeAutomationGuy
      @HomeAutomationGuy  8 หลายเดือนก่อน

      What's the error?

    • @rodrigomarins273
      @rodrigomarins273 8 หลายเดือนก่อน +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  8 หลายเดือนก่อน +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 8 หลายเดือนก่อน

      @@HomeAutomationGuy Thanks so much! 😀🙏