Bug report
Updates. I tried this steps:
After this, I restarted home assistant and mosquitto. No sensor in ha, perfect.
I started npm after that, and it created all the entities (with alfanumeric names).
Sensor started getting battery values, but door sensors were still without battery.
I can see battery values getting pushed out for door sensors from the npm service, so why they are not appearing in home assistant entities?
If you want a device's battery value to appear as its own entity in Home Assistant, you must create it yourself. Here's what I did for my Xiaomi door sensor.
'0x00158d000232c0c5':
friendly_name: the_name_you_want
retain: false
state_topic is whatever you named your device above, and the name is whatever name you want for your battery value entity:- platform: mqtt
name: the_battery_entity_name_you_want
state_topic: "zigbee2mqtt/the_name_you_want"
unit_of_measurement: "%"
value_template: "{{ value_json.battery }}"
I will try that, but why it is properly creating and updating values for everything apart door sensors?
I am using zigbee2mqtt because it autocreate everything, it defeats the purpose having to create everything manually.
Paired with a little plugin that autocreate the battery sensor it's very confortable to use:
https://github.com/notoriousbdg/Home-AssistantConfig/blob/master/packages/battery_alert.yaml
Does it work for "sensor" and not "binary_sensor"? So far for me all sensors are working but my water leak sensor shows up as "binary_sensor" and it does not work.
@nerdosity You'll need to check with the battery_alert add-on's dev, but it sounds like its not creating battery entries for devices that are binary_sensors.
@bbrendon If you're talking about the HA entries I listed above, it works for all the devices I've linked through zigbee2mqtt. FYI, the battery entity is always sensor.something, even if the device's main attribute is listed as binary_senor.something. E.g. the entries in HA above created 2 entities for the same device, binary_sensor.the_name_you_want and sensor.the_battery_entity_name_you_want.
Hi All
This is a Home Assistant bug/feature that binary sensors do not have JSON attributes.
@ciotlosm worked on it here https://github.com/Koenkk/zigbee2mqtt/issues/106 and https://github.com/home-assistant/home-assistant/pull/14912 and https://github.com/home-assistant/home-assistant/pull/14957 but it didn't get merged.
Thanks @ryanbeaton, it makes sense.
Fixed in the dev branch. Battery will now be a separate sensor in homeassistant.
@Koenkk Thanks for adding a stop-gap until HASS gets json attribute support. And thank you @ryanbeaton for explaining the root cause of this mess.
Most helpful comment
Hi All
This is a Home Assistant bug/feature that binary sensors do not have JSON attributes.
@ciotlosm worked on it here https://github.com/Koenkk/zigbee2mqtt/issues/106 and https://github.com/home-assistant/home-assistant/pull/14912 and https://github.com/home-assistant/home-assistant/pull/14957 but it didn't get merged.