Howto create battery alert without creating a template for every device

Sorry about that. To find the attributes, click on the sensor you want to delete. The red box shows the attributes I’m referring to.
image

You can find MQTT Topic to Clear in the Battery Alert group on the Batteries tab.

All you have to do is copy the value of the mqtt_state_topic attribute and paste it into MQTT Topic to Clear then do the same with mqtt_config_topic. Once you do that, the sensor should be gone.

That’s a known issue. I’ll update the package as soon as I can to switch to the new method.

Yes, that’s normal.

None of those look like they were created by this package. I’m not familiar with Plant Monitor component, so I’m not sure how much I can help. I suggest creating a new post about that issue.

That being said, if you’re looking for steps to clear retained MQTT topics in general, you can do this:

  1. SSH to a machine that has mosquitto_sub and mosquitto_pub installed.
  2. Run mosquitto_sub -h MQTT_IP -u MQTT_USERNAME -P 'MQTT_PASSWORD' -v -t '#'.
  3. Look through the topics to find the one you want to clear.
  4. Run mosquitto_pub -h MQTT_IP -u MQTT_USERNAME -P 'MQTT_PASSWORD' -r -n -t 'MQTT_TOPIC_NAME' to clear the topic.

Another option, if you’re running hassio, is to remove and re-install the mosquitto addon.

1 Like

Hey thanks for that! So it’s specific to the battery package. It just seems impossible sometimes to get rid of ‘old’ devices. I had an option set in Tasmota and it created a sensor I didn’t want and after reflashing, there was just nothing I could do to get rid of the Zombie (which was showing as unavailable) The only way I could kill it was by the method I described.
Surely there is a better way but I cannot find it.

Yes, that’s a feature of the sensors created by this package. I added those attributes to make it easier to do cleanup since I’ve enabled the retain flag.

1 Like

I assumed you were aware. I added it more for it to be picked up when people search…

J

thank you so much

1 Like

Hi, can you ask for an addition to the package?
It would be nice to have a binary sensor that activates when it’s battery alarm.

And if it is possible when the mobile phone is charging change the battery icons with that battery-charging-10 20 etc., the example parameters on google tracker is “battery_charging”: false

Thank you

@NotoriousBDG I removed the script for now, but the sensors are still present. Is there any way to remove them?

Sure, I can add that.

The icons rely on the device_class: battery, which doesn’t appear to be aware of charging attributes. Adding a charging attribute to the battery sensor can be done, but making that control the icon doesn’t look straight forward.

If you temporarily reinstall the package, you can disable the “Create Battery Sensor from Attributes” automation, then follow the steps mentioned in Howto create battery alert without creating a template for every device - #573 by NotoriousBDG.

1 Like

Thank you :slight_smile:

But since update to 0.86.0b I get this error after adding the script back:

Invalid config for [automation]: [minutes] is an invalid option for [automation]. Check: automation->trigger->0->minutes. (See /config/configuration.yaml, line 174). Please check the docs at https://home-assistant.io/components/automation/ Invalid config for [automation]: [minutes] is an invalid option for [automation]. Check: automation->trigger->0->minutes. (See /config/configuration.yaml, line 174). Please check the docs at https://home-assistant.io/components/automation/ Invalid config for [automation]: [minutes] is an invalid option for [automation]. Check: automation->trigger->1->minutes. (See /config/configuration.yaml, line 174). Please check the docs at https://home-assistant.io/components/automation/ ```

So did you actually read the release notes???

Do you mean those?
https://rc–home-assistant-docs.netlify.com/blog/2019/01/16/lovelace-released/

https://rc--home-assistant-docs.netlify.com/blog/2019/01/16/release-86/

Specifically this bit:
image

1 Like

Ah ok missed that one, thanks!

Release 1.2.0 is available. This fixes the deprecation warning about json_attributes in 0.85.0.

There is a breaking change with setting up notifications. The new method should be more flexible now. You just need to enter your notifier name in the Notifier Name input text box and select the format in the Notifier Format input select. So, for Slack, I use Notifier Name = notify.slack_notify with Notifier Format = Slack. Most notifiers (except Slack) should work with Notifier Format = Default.

Full Changelog:

Breaking Changes

  • Setting up notifications have changed. Enter the name of the notifier in the Notifier Name input text box and select the notifier format using the Notifier Format input select.

Changed

  • Migrate attributes from json_attributes to json_attributes_topic
  • Remove % unit for battery level attributes that contain strings
  • Replaced mqtt_config_topic and mqtt_state_topic attributes with delete_battery_sensor attribute to make deleting battery sensors easier
  • Renamed MQTT Topic to Clear input text box to Delete a Battery Sensor

Added

  • Battery attributes containing strings now have dynamic icons that change with battery status
  • Added Notifier Name input text box to store name of the notifier to use for notifications (defaults to notify.notify)
  • Added Notifier Format input select to allow selection of notification format. Options are Default and Slack.
  • Added input_boolean.low_batteries to help with automations. True means there are low batteries.
3 Likes

It looks like making the change below should address the breaking changes in the upcoming 0.86 release. I’m not on 0.86, so I haven’t tested this. Once 0.86 is released, I’ll check in the change.

Old

    - platform: time
      minutes: '/15'
      seconds: 00

New

    - platform: time_pattern
      minutes: '/15'
1 Like

Yes that fixed the issue :slight_smile:

2 Likes

@ NotoriousBDG If would be great if you would include the https://raw.githubusercontent.com/notoriousbdg/Home-AssistantConfig/master/packages/battery_alert.yaml on top of your actual .yaml file. Not sure if it’s possible, but custom_updater might be a good idea too. Happy to help if you need.

I updated from 0.82.1 to 0.85.1 and also updated new version of the battery alert.
but i still get this in the log after restart.
do i need to do something more?

configuration variable “json_attributes” is deprecated, replace with “json_attributes_topic”

I had the same issue. I disabled the package and restarted HA. Then removed all the relevant retained MQTT messages and re enabled the package and restarted AH again.

is there a simple way to do that?