Howto create battery alert without creating a template for every device

Just updated to 0.85, now getting these errors at startup, which i believe are due to the battery package…

2019-01-10 16:30:50 WARNING (MainThread) [homeassistant.components.sensor.mqtt] configuration variable "json_attributes" is deprecated, replace with "json_attributes_topic"

and

It’s ok status unknown?

group.battery_status unknown

Hey Dave, if you’re using the plant: monitor, be sure to hash this out in your config. I had to do this with mine.

there is no mqtt topic for these entities…

yeah, the plant monitor was also renamed to the new entity so I literally have zero reference to this ‘bog_arum’ plant anywhere in my code. I dont know why HA thinks it needs to look for it still…

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