Home-AssistantConfig icon indicating copy to clipboard operation
Home-AssistantConfig copied to clipboard

Homematic IP Devices with Battery Levels are not recognized

Open pschneider87 opened this issue 5 years ago • 3 comments

First: awesome work, it's the best battery alert solution I found on the internet.

My issue: I have a bunch of Homematic IP Devices with Battery Info.

At the Moment, all of them report "Normal" as state, but no integer that's why I believe they are not recognized by the script and hidden in the UI And I think they won't trigger an alert.

How could I solve this?

pschneider87 avatar Mar 16 '20 19:03 pschneider87

Polite bump

pschneider87 avatar Jun 24 '20 17:06 pschneider87

You might be able to use this info from the help

## 12. If a battery attribute requires a template to convert it into a usable percent, use customize
##     to add `battery_template` with the necessary template. The template result must be a number
##     that represents a percentage.
##
##     This example will create a battery sensor with the value of battery_level * 2
##
##     homeassistant:
##       customize:
##         sensor.sensor_with_battery_attibute_template:
##           battery_template: "{{ value_json.value | int * 2 }}"
##
## 13. If a battery attribute requires a template to convert it into a string, use customize to add
##     `battery_template_string` with the necessary template. The template result must be a string.
##     For example, "Low" will trigger low battery notification).
##
##     This example will create a battery sensor that contains "Low" if battery_level
##     is less than 2
##
##     homeassistant:
##       customize:
##         sensor.sensor_with_battery_attibute_template:
##           battery_template_string: >-
##             {%- if value_json.value < 2 -%}
##             Low
##             {%- else -%}
##             Full
##             {%- endif -%}
################################################################

OzGav avatar Jul 02 '20 13:07 OzGav

@pschneider87 did you ever get this working? I had a similar challenge with Homematic components reporting the voltage of their batteries. My customization seems to take effect but the value never changes.

Pay attention to the battery_template on the right side and the 2 in the middle...

image

battery value is 2.7 for the second entity, so value should evaluate to 5.4 instead of 2?

~~Any help would be appreciated!~~

After looking at the source code I understood that I have to write these rules for the source entity, not the generated one. @notoriousbdg maybe you want to rephrase the description in your script.

So for who else is dealing with this, here is what works for me:

packages/battery_alert_customize.yaml

homeassistant:
  customize:
    climate.bad_heizstellglied:
      battery_template: "{{ ((value_json.value | float - 2.2) / (3.1-2.2) * 100) | int }}"
    climate.schlafzimmer_heizstellglied:
      battery_template: "{{ ((value_json.value | float - 2.2) / (3.1-2.2) * 100) | int }}"
    climate.wohnzimmer_wandthermostat:
      battery_template: "{{ ((value_json.value | float - 2.2) / (3.1-2.2) * 100) | int }}"

    sensor.wohnzimmer_wandthermostat_humidity:
      battery_sensor_creation_disabled: true
    sensor.wohnzimmer_wandthermostat_temperature:
      battery_sensor_creation_disabled: true

Be aware that these templates are not immediately evaluated. It can take some time till the source entity sends a new battery value and thereby triggers the rule.

ThomDietrich avatar Mar 20 '21 23:03 ThomDietrich