Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homematic IP Devices with Battery Levels are not recognized #24

Open
pschneider87 opened this issue Mar 16, 2020 · 3 comments
Open

Homematic IP Devices with Battery Levels are not recognized #24

pschneider87 opened this issue Mar 16, 2020 · 3 comments

Comments

@pschneider87
Copy link

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
Copy link
Author

Polite bump

@OzGav
Copy link

OzGav commented Jul 2, 2020

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 -%}
################################################################

@ThomDietrich
Copy link

ThomDietrich commented Mar 20, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants