Xiaomi wireless switch (WXKG02LM) does not show battery level

Hello,

I have a few Xiaomi devices connected to HA via zigbee2mqtt. All devices connected in auto-discovery mode. I can set up automations for all of the devices, but there is one issue: I can’t read batter level for my 2-button wireless switch.

Interestingly, I see batter level data in the MQTT message:

zigbee2mqtt/extra_switch: b'{"battery":97,"voltage":2995,"linkquality":99}'

Unfortunately I can’t see batter level on an auto-generated sensor.extra_switch_battery. What could go wrong? I see batter level for other battery-powered devices no problem.

Looks like it may be an attribute.

Hmmmm, after some time it started to show the battery level. I did not change anything.
Strange, maybe that was a bug.

Anyhow the question is no longer actual.

It may not show up until the device publishes the battery level, which it will probably only do when the level changes.

Thank you for the info. Though not sure this is a case - the switch publishes battery level on easy keypress. Moreover it was reporting 97% before I started this thread, and then same 97% appeared on the dashboard next day,

There might be a similar case happenning right now with all the temperature sensors I have. In the MQTT log there are sensor reports with different temperature and humidity data. These values are actual on the corresponding value page, but at the same time wrong (stale) on tha graph.

I am pretty sure there were values changes this morning. Here is a log:

info  2020-01-27 05:27:31: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.3,"humidity":60.24,"pressure":997,"linkquality":86}'
info  2020-01-27 06:03:11: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.33,"humidity":60.2,"pressure":997,"linkquality":92}'
info  2020-01-27 06:16:33: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.29,"humidity":60.2,"pressure":997,"linkquality":92}'
info  2020-01-27 06:16:33: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.29,"humidity":60.09,"pressure":997,"linkquality":89}'
info  2020-01-27 06:16:33: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.29,"humidity":60.09,"pressure":996,"linkquality":86}'
info  2020-01-27 06:58:27: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.23,"humidity":58.64,"pressure":996.8,"linkquality":92}'
info  2020-01-27 07:52:52: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.28,"humidity":58.23,"pressure":996.6,"linkquality":89}'
info  2020-01-27 08:05:54: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.39,"humidity":58.23,"pressure":996.6,"linkquality":92}'
info  2020-01-27 08:05:54: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.39,"humidity":58.24,"pressure":996.6,"linkquality":92}'
info  2020-01-27 08:05:54: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.39,"humidity":58.24,"pressure":996,"linkquality":89}'
info  2020-01-27 08:47:18: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.3,"humidity":61.74,"pressure":996.5,"linkquality":94}'
info  2020-01-27 09:28:22: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.46,"humidity":61.74,"pressure":996.5,"linkquality":97}'
info  2020-01-27 09:28:22: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.46,"humidity":58.34,"pressure":996.5,"linkquality":94}'
info  2020-01-27 09:28:22: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.46,"humidity":58.34,"pressure":996,"linkquality":94}'
info  2020-01-27 09:44:46: MQTT publish: topic 'zigbee2mqtt/livingroom_climate_sensor', payload '{"battery":100,"voltage":3135,"temperature":21.6,"humidity":59.11,"pressure":996.2,"linkquality":97}'

Any ideas how to refresh the graph?

Nevermind.
I added a ‘recorder’, and did not include any of the climate sensors.
I removed the recorder and it started to show new values on the graph