[Custom Component] Battery Notes

Hi, for 2 you can use the event data to know what battery type/quantity was used
If you look at this example you can see there are data elements for the type and quantity and you would have to work out your appropriate input_number based on the {{ trigger.event.data.battery_type }}
1 is more tricky as you would have to create an automation for each battery note device on the button press, I think this would be more effort than it was worth to achieve this.

2 Likes

Yeah, thank you, I understand your suggestion, and will try to do that (for option 2). Although I think that this may fail, because sometimes battery values are not consistent.
Early this morning I had a sensor reporting 10%, and after a few hours returned to 50%, without battery changingā€¦
Would it be possible to include in your integration an event ā€˜battery_replacedā€™, triggered by the button press, with the same attributes?
Thanks!!!

That should be possible to add by both the button and the action. Iā€™ll look into it, thanks for the suggestion.

2 Likes

Hello,
I checked many threads referring to your integration but was not able to trace solution to what I encounter. I have multiple fibaro battery devices managed through fibaro integration and none of these devices is detected as battery device. I can add them manually but as a result they only have 3 information in diagnostic. there is no battery level or battery + sensor.
image
even thought they have batterly_level attribute.
image
Iā€™m not sure where to look for solution. As no one is mentioning fibaro anywhere Iā€™m getting to conclusion that issue is due to my devices being added through a fibaro integration not somehow directly.

Hi guys,
How do you track none-Home Assistant devices? I would love to use Battery Notes to track ā€œvirtualā€ devices such as car keys, TV remote etc

That does not even make sense. How do you track something in HA that is not tracked in HA???

Just saying we have to be realistic about what can be done here.

I meant adding such devices as virtual entities in HA that donā€™t do much other than the ability to track battery changes. Itā€™s like creating a virtual device that represents these devices which wouldnā€™t actually control in HA.

1 Like

The battery plus and battery low indicators will only show if Battery Notes can detect a battery, it would seem the Fibaro devices donā€™t present a proper battery so thereā€™s little I can do about these ones Iā€™m afraid.

This isnā€™t something Battery Notes will do but if someone were to create a virtual device integration for setting these up thereā€™s no reason you couldnā€™t add a battery note to it.
Fairly simple integration to write but Iā€™m afraid Iā€™m not interested in developing it myself.

Hello,

Thank you for reply. I just wonder if there is battery_level attribute of the device present maybe it would be somehow possible for your integration to detect such device as battery device ?
as I mentioned all these devices have this attribute and value assign so following other instances at least sensor.device_battery_level could be created :slight_smile:

Batteries should have the appropriate device class and unit of measurement to be a proper battery, I cannot start adding exceptions for devices that donā€™t implement batteries properly.

entity.device_class == SensorDeviceClass.BATTERY
and entity.unit_of_measurement == PERCENTAGE

You can implement the battery low sensor with a template like this

Hello,

fair enough :slight_smile:

thank you for suggestion.

Hey @codechimp.

First, youĀ“ve doing a damn good job with your integration, it make something easier for me. But, i donĀ“t know if i making a mistake or the integration doesnĀ“t work correctly ā€¦

I`ve many HM-IP devices, and as you know they donĀ“t show the voltage in percent. Yeah, i know, i can use the low_bat entity but i donĀ“t want that ;o) A while back iĀ“ve found a solution somewhere in the web to calculate the percentage from the voltage.

The MAX bat-level voltage for the HM-IP devices are 3 volt. So iā€™m using this template to convert the voltage:

{{ ((states(ā€˜sensor.climate_flur_eg_battery_levelā€™)|float(0) - 2.2) / ((3 - 2.2) / 100))|round(0) }}

2.2 volt is the level that is reported in raspberrymatic as a low battery level.

In my example the radiator bat level voltage is 2.8 V. IĀ“m pasting the template in the template editor and it shows me this:

But in your integration it shows me this:
entity_fail_battery_plus_bat_level

Explanation: If iĀ“m using a template it doesnĀ“t show me the ā€œbattery_plusā€ entity. For other devices where i donĀ“t use a template, everything is working correctly

This is by design the Battery Plus will only appear on devices with a ā€œproperā€ battery percentage, not the levels since different devices implement this very differently, from voltages, boolean, strings and also the entity names vary as well making the config very complex.
I havenā€™t found a solution I like for this yet, so hence thereā€™s no battery plus shown.

Thanks for the fast answer. I understand that, but isnā€™t a value transferred that Battery Plus can process? The integration receives a valid percentage value. IĀ“m not a coder nor a mathematik genie, but isnā€™t that basically the same principle? :slight_smile:

For Battery Notes to determine a battery plus it has to look at the available entities and determine if any meet the criteria (itā€™s device class is battery and unit of measurement is a percentage).
The template you created isnā€™t part of the device, itā€™s an associated entity, much like the battery notes entities themselves so Battery Notes wonā€™t find it.

Ahhh all right, now Iā€™ve understood :slight_smile: Then I have to continue using my sensor templates for the HM-IP devices for the percentage.

Thanks for the answer and keep up the good work :slight_smile:

1 Like

So Iā€™ve been experimenting with ideas around this and it turns out without any code changes you can create a Template Helper and have Battery Notes pick it up and create a Battery+ sensor.

Iā€™ve documented how to do this here, feedback appreciated if you have issues.

https://andrew-codechimp.github.io/HA-Battery-Notes/entities/#adding-a-battery-percentage

3 Likes

Thx for this, it works like a charme with the template helper :slight_smile: Now i have the percent values for the HM-IP devices too.

1 Like

Great work on the template approach. Works like a charm for all my Homematic devices :smiley:.

Would it be possible as well with this approach to recalculate an existing entity? Iā€™m using some battery driven shades with the Motionblinds integration. Unfortunately, the provided percentages by the ā€œsensor.rollo_innen_rechts_batterieā€ are not fully correct. Seems they are calculated as well by voltage, but voltage is not available by a sensor. As of today, 100% is calculated as 86% and 0% is calculated as 26%: