No battery information
Hello, I succesfully installed the custom component and it's working great except I don't have the battery sensor. I don't find it in the entity list. Is it a bug or something I miss ?
It's not a sensor, it's an attribute of the temperature and humidity sensor (see battery_level at the bottom). You can see it if you click on the temperature sensor or humidity sensor.

You can use a template sensor if you want this displayed as a sensor in Home Assistant
https://www.home-assistant.io/integrations/template/
@Ernst79, how long have you been using the sensor in your screenshot? I collect statistics on battery consumption, but my sensors are now only 3 months old (85% of the charge on average). At the beginning there were experiments, and not all these 3 months used a passive scanning mode. But while it turns out about 5% per month approximately.
Mine is of 11 months old now, but I started with the original home assistant component in the beginning. Not sure when I changed to your custom_component.
Thanks for you answer. My config if someone don't know how to do it :
- platform: template
sensors:
mi_b_582d3435cfeb:
friendly_name: "Niveau de batterie"
unit_of_measurement: "%"
value_template: "{{ state_attr('sensor.mi_t_582d3435cfeb', 'battery_level') }}"
You mixed the first to lines. Try this:
sensor:
- platform: template
mi_b_582d3435cfeb:
friendly_name: "Niveau de batterie"
unit_of_measurement: "%"
value_template: "{{ state_attr('sensor.mi_t_582d3435cfeb', 'battery_level') }}"
Do not forget to device_class. Correct config is:
sensor:
- platform: template
sensors:
mi_b_582d34339449:
friendly_name: "Baterie"
unit_of_measurement: "%"
value_template: "{{ state_attr('sensor.mi_t_582d34339449', 'battery_level') }}"
device_class: "battery"
@Magalex2x14 regarding the battery life, it died yesterday. The display was still working, but Bluetooth didn’t make it from the bedroom to the basement below 35%. I first thought bluetooth on my raspberry was not working anymore, but it worked fine, but no more messages from my device. A new battery was the solution -:) . So, about 1 year battery life. Luckily it’s a cheap AAA battery.
@Magalex2x14 any plans on adding a battery sensor automatically like temperature and humidity?
Do you mean for miFlora? It's hard to say now. I will answer that there is, but before that a lot needs to be done (the principle of receiving data must be completely changed #9). Therefore, if this happens, then not very soon, because I have to learn a lot... The only thing I can please now is that I am going to force the transition to a new principle, since this should solve a lot of problems with HASS.io (HassOS).
No, I mean for the temperature sensors. At the moment battery is only available as an attribute. Therefore we have to create template sensors manually (e.g. to monitor low battery states to replace them etc.).
My question was if it is planned to add this battery sensors automatically? Than it's not necessary to create battery sensors manually via template.
No, there were no such plans... Nobody has requested so far ) and the attribute is needed anyway. I might think of such an option, but it will be in low priority...
Should I create a new ticket to keep this feature request on track?
Please, add your suggestion to #3