Howto create battery alert without creating a template for every device

Thanks I’m blind :stuck_out_tongue: all working properly once again.

1 Like

I’ve found the issue and released a new version with the fix. I also added the battery group helper jinja to the install doc. Can you give it another try with this version?

2 Likes

wrong post

That doesn’t look related to this package. Perhaps you should start a new thread on that?

thanks @NotoriousBDG, I post in the wrong thread.
I will remove it asap

Hey, this is awesome!!

I’ve added this to my HA, and it’s working well in the frontend, but the notification seems to be not working correctly. I change the notify.slack_notify to notify my iphone notify.ios_chriss_iphone, but the message I get on my phone just says “Low Battery Levels”. That is it. There is not devices and their battery levels listed.

Having a look at the automation, it seems the data component is not being sent. Just the message. Any ideas?

Also, while I’m here, is it possible to add a line break between devices on the notification in the frontend? (and in the notification to ios or slack or wherever) I find it easier to read with each device on it’s own line.

Hey,
nice work. have some small issues with a bunch of 433mhz temperature/humidity sensors though(They’re naming faults rly)
Alle the battery levels are named sensor.xxx_bat …
e.g.:

sensor.tunex_6201_bat low
sensor.xiron_6201_bat low
sensor.inovalley_8e02_bat ok

these aren’t found by your script it seems.

Any easy way to fix this?

I suspect the notification component you’re using requires a data structure than Slack does. Which notify component are you using?

I believe I already tried that and ran into an issue. I’ll see what I can do.

Yeah, it looks like an issue with how the sensors are named. Which component is creating these sensors? Can you post a screenshot of those sensors from the http://hassio.local:8123/dev-state page so I can see all of their attributes?

I’ve updated the package to implement your suggestion. It seems a lot easier to read in this new format. Thanks for the suggestion!

I’ve also made it so entities with device_class of battery are considered to be a battery and no longer requires battery in the friendly name. This gives you an option of using customize to enable monitoring of entities that don’t contain battery in their friendly name.

@NotoriousBDG

Thanks for continue developing this package, awesome!

One thing I noticed for my system.
I have set the friendly names for several water sensors and smoke sensor to “Water sensor” and “Smoke sensor.” This because when sensors are in in a group with the room name, I dont wantt the room name twice (“Bedroom Smoke sensor” in group “Bedroom”).

When using ## 10. The jinja-code, I´ll only get one Smoke sensor and Water sensor, not a list with all smoke sensor and water sensors in my system.

Thereby I am not able to get a separate group with all the sensors with battery level.

Can you provide some screenshots of the issue? The jinja code from step 10 should list each entity_id regardless of its name. Even if you have multiple devices named “Water Sensor Battery”, they should all be listed because each one should have different entity_id.

I realized that I missed adding device_class to the battery_status group jinja code. I’ve updated the code on github to catch those entities. I don’t think this will help with your issue though.

I do foresee an issue with notifications when you have multiple entities with the same friendly name. I’ve updated notifications to include object_id to help with disambiguation when you have multiple sensors with the same friendly name.

Installed version 1.0.6.

I have three smoke sensors (brannalarm) and the Jinja2 code gives:

“vannsensor” is a water sensor.

Do you have more than 1 entity listed on the http://hassio.local:8123/dev-state page for the batteries? What are the entity_ids of the brannalarm smoke sensors? A screenshot of those would be helpful to see too.

The tunex/xiron/inovalley temp sensors were coming in over an rflink gateway.


Just wondering if this is the fault of the naming conventions in the rflink component or ?

All sensors are in the same format as the screenshot of the inovalley below.

Sorry for the late reply

It looks like the “_bat” is coming from the python-rflink library that’s used by the rflink component. I see 2 different ways to identify those entities. The first is to check to see if the name ends with “_bat” and the second is to look for an icon of “mdi:battery”. The icon check might catch even more edge cases than rflink. I’ll work on adding both features to the package.

entity_ids:
zwave.fib_smoke_sensor1
zwave.fib_smoke_sensor2
zwave.fib_smoke_sensor3
zwave._fib_flood_sensor1
zwave._fib_flood_sensor2

snokevan

I am really interested to this project, but i am very newbie at mqtt and jinia template… What i would like to know specifically is how to handle jinia template, where to put inside the package as the docs about it for me are very difficult to understand.
Thanks in advance for any help…

The entity_id of those battery sensors don’t have the entity_id that I expect to see. They should be sensor.fib_smoke_sensor1_battery, sensor.fib_smoke_sensor2_battery, sensor.fib_smoke_sensor3_battery, etc. I only have 1 zwave device on a z-stick, and it’s not exhibiting this behavior. I’m suspecting that has something to do with the object_id being different than what I see on my system.

@Tomahawk, can you run this automation on your system then trigger a state change on your smoke sensors? This automation should create a persistent notification for each smoke sensor showing the entity_id and the object_id from the event. If my theory is correct, you’ll see an object_id of brannalarm for all 3 of them.

- alias: object_id_notification
  trigger:
    - platform: event
      event_type: state_changed
  condition:
    - condition: template
      value_template: "{{ trigger.event.data is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.new_state.attributes is not none }}"
    - condition: template
      value_template: "{{ trigger.event.data.old_state is not none }}"
    - condition: template
      value_template: "{{ 'fib_smoke_sensor' in trigger.event.data.entity_id }}"
  action:
    - service: persistent_notification.create
      data_template:
        title: "{{ trigger.event.data.entity_id }}"
        notification_id: "{{ trigger.event.data.entity_id }}"
        message: >
          entity_id = {{ trigger.event.data.entity_id }} 
          object_id = {{ trigger.event.data.new_state.object_id }}

If you’re referring to the jinja template in step 10 of the install instructions, you paste that in http://hassio.local:8123/dev-template. The right hand side will show yaml code that you can use to create a group (Group - Home Assistant). The group yaml goes in your Home Assistant config and not in the package.

Ok i did it, but i added the group to the package and not to the groups.yaml… is this an error?