ZHA Zigbee Tested Devices...Please add your device results

@ptdalen I have some devices that are reporting 90% and I never changed the battery. I had a Iris Motion Sensor that died in 1 week stayed at 100% dropped to 30% and died soon after. It all depends on the device and the battery. Just know that all that code does is read a value sent from the device itself and it just interprets that. Its really all we can do. These will be as accurate as zwave devices are which really depends on the device and batteries used. Also there is now a zha entity created (after 0.80 I think?) that will tell you if a device is online or offline that can also be helpful.

https://github.com/dshokouhi/Home-AssistantConfig/blob/master/custom_components/sensor/zha.py#L212

Keep in mind zigbee and zwave devices are meant to last several years as well.

As for why it has never been merged I am not sure.

Interesting, so I have not really paid attention to the new entriy options of online/offline. Is that a state I can right an automation to? I looked and could not find any info on this, can you point me in the right direction. Thanks

Go to the states tab and look for zha. entities you will have one for each ZHA device. This was added in 0.79 these entities will have online or offline as the state.

Nice! never noticed until now. Now just to figure out which device is which, haha. Definitely nice to know if they are offline. I occasionaly lose a motion or open close sensor, so this will be very useful. Thanks!

Yea I had to use the entity registry file to match up the IEEE addresses, look in .storage and the entity registry file in there should help you out.

1 Like

Good deal, Just sharing for others who may want to use the zha domain to report offline devices.

 - platform: template
   sensors:
     zigbee_offline:
       value_template: >
         {% set zigbee = [ states.zha.motion_sensor_garage, states.zha.motion_sensor_hallway, states.zha.motion_sensor_kitchen, states.zha.motion_sensor_office, states.zha.motion_sensor_sensor_living_room, states.zha.office_lamp_one, states.zha.open_close_sensor_back_door, states.zha.open_close_sensor_front_door, states.zha.open_close_sensor_garage_door, states.zha.open_close_sensor_garage_fridge, states.zha.open_close_sensor_mailbox, states.zha.water_sensor_kitchen, states.zha.zigbee_plug_one ] %}
         {% set offline = zigbee | selectattr('state','eq','offline') | list %}
         {{ offline | length >= 1 }}
       friendly_name: 'Zigbee Devices Offline?'

These are my zigbee devices, so change names as needed.

Then this automation

- alias: Zigbee Device Offline
  trigger:
  - platform: state
    entity_id: binary_sensor.zigbee_offline
    to: 'on'
    for:
      minutes: 15
  action:
  - service: script.sms_notify_with_images
    data_template:
      service: notify.sms_me
      title: Zigbee Devices Offline
      message: >
          {% set offline = states | selectattr('entity_id', 'in', state_attr('group.all_zigbee','entity_id')) | selectattr('state','eq','offline') | map(attribute='name') | join(', ') %}
          The following zigbee devices are offline: {{ offline }}

Of course replace with your notifyer of choice
Oh, and I created a group as well

all_zigbee:
  name: Zigbee Devices
  view: no
  icon: mdi:lock-outline
  entities:
    - zha.motion_sensor_garage
    - zha.motion_sensor_hallway
    - zha.motion_sensor_kitchen
    - zha.motion_sensor_office
    - zha.motion_sensor_sensor_living_room
    - zha.office_lamp_one
    - zha.open_close_sensor_back_door
    - zha.open_close_sensor_front_door
    - zha.open_close_sensor_garage_door
    - zha.open_close_sensor_garage_fridge
    - zha.open_close_sensor_mailbox
    - zha.water_sensor_kitchen
    - zha.zigbee_plug_one

I will say, I removed the battery from one device to test and itā€™s been 30+ minutes with no change. Makes sense though, as I would not expect reguluar updates due to saving battery life.

@ptdalen what happens if you restart while the device is offline? does it update then? I know some devices donā€™t report until they need to report action like a contact sensor so removing battery may not do anything in that case.

Good call, when I restarted all devices were offline, after a few minutes all came back online, even without having to be open/closed, motion, etc. All except the one without the battery. So, I think this would still all work, but, really only after a restart. Might be wrong, maybe it would eventually show as offline if the battery died, but as of this point not sure. I changed the trigger to

  - platform: state
    entity_id: binary_sensor.zigbee_offline
    to: 'on'
    for:
      minutes: 15

I figure if I restart and everything has not reported as online in 15 minutes, then something is probably wrong. Overall Iā€™m still pretty happy with this, I feel like this will be good for those less used sensors you might not realize were having issues.

I added this under sensor in custom_components folder, seems to have loaded, but I donā€™t see any new entities or attributes on my existing ZHA entities, how do you make it work?

Also like the idea of an alert for offline, good thinking there, between the two should be good.

Iā€™m running .82, seems like ZHA devices still work, just no battery entities showed up. Iā€™m running the container. I saw others mention changing some other config file, but I could not easily do that in the container

I also tried to put it into sub folder ā€œbinary_sensorā€ as thatā€™s what my door and motion sensors show up as, made no differenceā€¦

I see itā€™s loading in the log file

I just realized I forgot to mention one more file I had to modify but it is in the file system.

on my system I need to modify the following file, it may be slightly different on yours just depends on where exactly HA is installed

/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/zha/const.py

and add the following at line #53

zcl.clusters.general.PowerConfiguration: 'sensor',

Then restart HA. You do need to make sure this file is updated with each HA release. I think you could probably run the code as a custom component but you will want to keep it all updated with the latest changes. This change here is fairly small so I donā€™t mind doing it after each update.

not sure I can edit that, I run the container, that would most likely be inside the container?

I can execute bash in container, no editors there, but I found file and cat it out and line line 53 is in the middle of all the CONF paramters, so that is CONF_CUSTOMIZE = ā€˜customizeā€™

You just add zcl.clusters.general.PowerConfiguration: ā€˜sensorā€™, before that? Also the comma doesnā€™t fit the pattern of this file, maybe Iā€™m looking at the wrong file

nevermind, was looking at main const.py, not the zha one

So I made them show up, or some, I assume others will come as things come onlineā€¦

I think this is against all best practices for docker

docker exec -it home-assistant /bin/bash

then you are in

apt-get update
apt-get install vim

You will start in the folder /usr/src/app

Go to /usr/src/app/homeassistant/components/zha

vim const.py

Make the change, save, and type exit and restart the container

So I have a Samsung Button and a Moisture sensor, they showed up, but status ā€˜Unknownā€™.

I then had 3 devices show up, so 6 because of duplication, but I have 7 motion sensors, all the same Iris brand, and I have 6 Iris door sensors of the same brand, so I should have seen 13 devices, duplicated, so 26. They are all online and working.

I also canā€™t figure out which devices they are, I have renamed all my zha devices, so not sure how to map the number to rename these

you can map devices uses the hex values on the zha devices ieee

So tracked them down, it added 2 motion sensors and 1 door. Maybe the others have to report battery before they get added?

I renamed them, will that persist if I update the container and the zha.py file or will I have to rename the sensors each time?

can I force an update to get all the levels to show up?

wonder why these changes never got merged, they make sense

also, the two devices that show up and donā€™t work, have an eye icon, not battery

Itā€™s

Samjin button
SmartThings moisturev4

They probably report the same way, just an ID issue maybe?