Low battery level detection & notification for all battery sensors

Yes, template for sensor ? how do i use that ?
This is my action:

All you have to do is insert {{ sensors }} into your message so itā€™ll be replaced with the actual list of low battery entities. So change ā€œlow batteryā€ to, say, ā€œlow battery: {{ sensors}}ā€.

Thanks, works like a charm.

regards

/MIcke

hi Guys,

anyone have problems with a notify by xiaomi Devices?

Thanks for the blueprint, a good kind of catch-all of my devices. However I needed to be able to have it trigger multiple times per day (every 1/2hr or there about), so I took a fork of your code & swapped out the ā€˜timeā€™ for ā€˜time_patternā€™ to allow for my specific case.

Home Assistant Blueprint: Low battery level detection & notification for all battery sensors with Time Pattern (github.com)

@lymbada, Nice adoption! Thanks for this. A question regarding wording for minutes and second settings Descriptions for these settings read in part "When to trigger, ā€˜*ā€™ for any hour, 0-59 for the specific ". In the case of minutes, should the word hour not be replaced with minute, and in the case of seconds, should it not be replaced with seconds?

EDIT: Just noticed an issue that needs to be addresses. Iā€™ve set the attributes to perform a check on the 55 minute mark. The automation (Blueprint) discovered a device with a low battery. It performed as it should have, sending a message to my cellphone. Problem is, it continued to send the same message every two seconds until the time passed 55 minutes. I received 30 messages on my cell. Each, 2 seconds apart. Is this the intended behavior of the blueprint? If yes, how do I configure the automation such that this behavior doesnā€™t occur?

Okay, figured out the problem! With hours and seconds set to ā€œ*ā€, the action is fired every other second. To get around this I set the seconds to 1. Now the message is sent once, 1 second after the specified minutes.

Hey rclackwell
I had indeed done both of those updates for the description, and also set the default for second to ā€˜1ā€™ (as I found the exact same thing, I guess time-patterns is not the same as typical cron).
I guess you had an earlier downloadā€¦ or I forgot to publish the changes? Iā€™ll check now.
Matt

@lymbada Hi Matt,

The blueprint Iā€™m using came from git yesterday. It matches what I see posted today. I see there is a default of 1 for seconds. Perhaps the blueprint shouldnā€™t allow ā€œ*ā€ to be utilized for seconds? Only allow 0-59. Now that I understand how time works, I donā€™t see a situation where the wildcard would/could be used. Eliminating the wildcard choice would eliminate the problem I (and you) saw earlier.

As for descriptions; the minutes and second description still read in part "When to trigger, ā€˜*ā€™ for any hour , 0-59 for the specific ". In the case of minutes, should the word hour not be replaced with minute , and in the case of seconds , should it not be replaced with seconds ?

Great blueprint, thanks for sharing.

If I trigger the automation manually, I get a message without any sensor. Makes sense because all batteries are good. But in that cases I donā€™t want a message. Can I do this?

Manually triggering the automation is always going to do that. Itā€™s designed to only send a notification if there is something to send when it runs normally. However, when you run it manually HA will skip all the trigger conditions and youā€™ll end up with empty sets and so it just sends you an empty message, essentially validating that your notification setup is correct.

3 Likes

with the newest core update, this blueprint not working anymore :frowning:

Logger: homeassistant.components.automation.low_battery_level_detection_notification_for_all_battery_sensors
Source: components/automation/__init__.py:519
Integration: Automatisierung (documentation, issues)
First occurred: 08:26:23 (1 occurrences)
Last logged: 08:26:23

Error while executing automation automation.low_battery_level_detection_notification_for_all_battery_sensors: Unable to find notify service for webhook ID
Logger: homeassistant.components.automation.low_battery_level_detection_notification_for_all_battery_sensors
Source: helpers/script.py:1397
Integration: Automatisierung (documentation, issues)
First occurred: 08:26:23 (2 occurrences)
Last logged: 08:26:23

Low battery level detection & notification for all battery sensors: Choose at step 1: default: Error executing script. Error for device at pos 1: Unable to find notify service for webhook ID
Low battery level detection & notification for all battery sensors: Error executing script. Error for choose at pos 1: Unable to find notify service for webhook ID

Sorry, the blueprint works. I have use another service to notify my device, now it works perfectly

Hi.

I have setup your BluePrint and when i click the run actions button I see the below pop up on my iPhone.

A couple of questions \ issues. I donā€™t see all devices in the pop up message. Also clicking on the alert does nothing other than take me in to HA. Is there any way of it taking to me a page I have setup with all my batteries?

I think It is possible to provide a url to link to. Sometimes long press will give you more information as well?

I get unknown error when importing this. Anyone else? Logs complaining about sliderā€¦

Logger: homeassistant.components.websocket_api.http.connection
Source: util/yaml/dumper.py:40
Integration: Home Assistant WebSocket API([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 23:05:49 (8 occurrences)
Last logged: 23:13:58

* [547281134016] Error handling message: Unknown error (unknown_error)
* [546877843584] Error handling message: Unknown error (unknown_error)
* [547193437200] Error handling message: Unknown error (unknown_error)
* [547294874448] Error handling message: Unknown error (unknown_error)
* [545782480656] Error handling message: Unknown error (unknown_error)

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/blueprint/websocket_api.py", line 125, in ws_save_blueprint await domain_blueprints[domain].async_add_blueprint(blueprint, path) File "/usr/src/homeassistant/homeassistant/components/blueprint/models.py", line 327, in async_add_blueprint await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/blueprint/models.py", line 318, in _create_file path.write_text(blueprint.yaml(), encoding="utf-8") File "/usr/src/homeassistant/homeassistant/components/blueprint/models.py", line 107, in yaml return yaml.dump(self.data) File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 13, in dump return yaml.safe_dump( File "/usr/local/lib/python3.9/site-packages/yaml/__init__.py", line 269, in safe_dump return dump_all([data], stream, Dumper=SafeDumper, **kwds) File "/usr/local/lib/python3.9/site-packages/yaml/__init__.py", line 241, in dump_all dumper.represent(data) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 27, in represent node = self.represent_data(data) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data node = self.yaml_representers[data_types[0]](self, data) File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda> lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value), File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict node_value = dumper.represent_data(item_value) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data node = self.yaml_representers[data_types[0]](self, data) File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda> lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value), File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict node_value = dumper.represent_data(item_value) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data node = self.yaml_representers[data_types[0]](self, data) File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda> lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value), File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict node_value = dumper.represent_data(item_value) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data node = self.yaml_representers[data_types[0]](self, data) File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda> lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value), File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict node_value = dumper.represent_data(item_value) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data node = self.yaml_representers[data_types[0]](self, data) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 207, in represent_dict return self.represent_mapping('tag:yaml.org,2002:map', data) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 118, in represent_mapping node_value = self.represent_data(item_value) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data node = self.yaml_representers[data_types[0]](self, data) File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda> lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value), File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict node_value = dumper.represent_data(item_value) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 58, in represent_data node = self.yaml_representers[None](self, data) File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 231, in represent_undefined raise RepresenterError("cannot represent an object", data) yaml.representer.RepresenterError: ('cannot represent an object', <NumberSelectorMode.SLIDER: 'slider'>)

Iā€™m also getting this error when I attempt to import this blueprint.

HA Core: 2022.5.0
HA Supervisor: 2022.05.0
HA OS 7.6

2022-05-07T05:00:00Z

Logger: homeassistant.components.websocket_api.http.connection
Source: util/yaml/dumper.py:40
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: May 6, 2022, 9:07:09 PM (3 occurrences)
Last logged: 9:25:38 AM

[547883345904] Error handling message: Unknown error (unknown_error)
[547881153152] Error handling message: Unknown error (unknown_error)
[548112264208] Error handling message: Unknown error (unknown_error)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/blueprint/websocket_api.py", line 125, in ws_save_blueprint
    await domain_blueprints[domain].async_add_blueprint(blueprint, path)
  File "/usr/src/homeassistant/homeassistant/components/blueprint/models.py", line 327, in async_add_blueprint
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/blueprint/models.py", line 318, in _create_file
    path.write_text(blueprint.yaml(), encoding="utf-8")
  File "/usr/src/homeassistant/homeassistant/components/blueprint/models.py", line 107, in yaml
    return yaml.dump(self.data)
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 13, in dump
    return yaml.safe_dump(
  File "/usr/local/lib/python3.9/site-packages/yaml/__init__.py", line 269, in safe_dump
    return dump_all([data], stream, Dumper=SafeDumper, **kwds)
  File "/usr/local/lib/python3.9/site-packages/yaml/__init__.py", line 241, in dump_all
    dumper.represent(data)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 27, in represent
    node = self.represent_data(data)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda>
    lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value),
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict
    node_value = dumper.represent_data(item_value)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda>
    lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value),
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict
    node_value = dumper.represent_data(item_value)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda>
    lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value),
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict
    node_value = dumper.represent_data(item_value)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda>
    lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value),
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict
    node_value = dumper.represent_data(item_value)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 207, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 56, in <lambda>
    lambda dumper, value: represent_odict(dumper, "tag:yaml.org,2002:map", value),
  File "/usr/src/homeassistant/homeassistant/util/yaml/dumper.py", line 40, in represent_odict
    node_value = dumper.represent_data(item_value)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 58, in represent_data
    node = self.yaml_representers[None](self, data)
  File "/usr/local/lib/python3.9/site-packages/yaml/representer.py", line 231, in represent_undefined
    raise RepresenterError("cannot represent an object", data)
yaml.representer.RepresenterError: ('cannot represent an object', <NumberSelectorMode.SLIDER: 'slider'>)

If I try to add {{sensors}} I get this error:
Visual editor is not supported for this configuration

  • Templates not supported in visual editor
    You can still edit your config in YAML.

At the moment I get a notification, but I dont have any batteries that are low. And Iā€™m trying get the automation to show what entity is low

I received the same warning. Overcame it by opening the yaml editor and adding code there. Hereā€™s my code for notify.

service: notify.notify
data:
  message: >-
    A battery in the sensor named {{sensors|replace("_"," ")}} is reporting a low state.
  title: Low Battery Warning

I only get this as a notification:
A battery in the sensor named is reporting a low state

No Entity in the notification

1 Like