Is it correct, that the package should create new sensors for the battery levels? Because there are no new sensors available on the state page
There are no alerts shown for any sensor with a battery_level attribute unless I put battery in the friendly name of the sensor. But then the script assumes that the main value of the sensor (e.g the temperature) is the battery level, right? So is the issue, that no new sensors are created and therefore no sensors with battery in the name are found? How can I fix that?
I’ve been using this for a while and at the weekend I had 2 Fibaro sensors go from 100% to not working, battery’s were totally flat. Plus I have another that always say 0% even with a new battery.
I just find their reporting far too flaky to be of any use for battery levels.
Is the battery_alert.yaml file stored in the folder named packages?
It will create a new sensor for entities that have attributes named battery_level, battery, and battery numeric. If the entity has battery in it’s name, it will not create a new sensor from it.
Correct, the alert will be for the battery sensor which are automatically created for entities that have battery attributes.
Is there any way to store the min & max alert threshold value thats set from the input_number persistent in mqtt, to not have the value reset to initial value after reboot?
With the release of Home Assistant 0.66, it’s now possible to set the icon for a sensor via MQTT Discovery. I’ve updated the package so it sets the icon to a battery icon. I was hoping to make the icon change based on battery level, but Home Assistant only sets the icon when the sensor is initially discovered and on startup, which doesn’t make that feasible yet.
Once you update the package on your system, the icons won’t change immediately. There needs to be a state change or poll for each device first, then Home Assistant will need to be restarted. After that’s done you should now have battery icons.
First with the bad news. With the upcoming 0.69 release of Home Assistant, there is a breaking change where this package will cause problems with MQTT component in Home Assistant.
Now for the good news. To prevent an issue with the upgrade, you must update the package to the latest version then wait long enough for every battery device to report it’s latest battery level before you upgrade to Home Assistant 0.69**.
For some even better news, with 0.69, it’s finally possible to dynamically set the icon based on battery levels. The latest version of the package enables that feature so once you upgrade, you’ll have dynamic battery icons.
Lastly, for anyone that’s too impatient to wait for the package to fix the issue before upgrading. You accelerate things by installing the new package, restarting Home Assistant, uninstalling and reinstalling the MQTT addon (to purge retained data), then proceed to upgrade Home Assistant. Your battery sensors will automatically get recreated as they report in.
Thank you very much. Mine keep reporting the old memories of battery.
example.
Yesterday my battery is 44% report.
Today my actual battery is 90% but still keep reporting that it is 44%
Can you paste a screenshot of the /dev-state page showing the attributes of the sensor that’s having issues as well as the battery sensor that’s related to it?
I am trying to import your package and I get this error checking configuration:
Invalid config for [automation]: required key not provided @ data['action']. Got None
required key not provided @ data['trigger']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/
I am pretty sure that I have copied correctly the yaml file from your repository.
Thanks for the kind words. I’m glad that it’s helpful.
I don’t know of a way to make the group membership dynamic, but there is a way to make creating the group easier. Navigate to the /dev-template page then paste the template code below into the editor section. The right hand side will have the yaml needed to create a group that contains all of your battery sensors, which you can just copy/paste into your config.
battery_status:
name: Battery Status
icon: mdi:battery-charging
entities:
{%- for item in states.sensor if (
"battery" in item.name | lower
and not "voltage" in item.name | lower
and not "runtime" in item.name | lower
and not "setpoint" in item.name | lower
and not "charge" in item.name | lower
) %}
- {{ item.entity_id }}
{%- endfor -%}
That’s all you should need to do. Did you clear both the config and state topics? They should be homeassistant/sensor/illumination_158b0001e67306_battery/state and homeassistant/sensor/illumination_158b0001e67306_battery/config for your sensor with entity_id of sensor.illumination_158b0001e67306. You’ll have to restart Home Assistant after clearing those topics to complete the removal.
I did indeed. I actually deleted the entire mosquito database as there was a lot of old historical junk I there from testing etc but the sensors still created. I’ll try it again maybe I missed something.