đŸȘ« Low Battery Notifications & Actions

@IdiotTryingToFindWay

It is not broken you just need to know what to do.

  1. Why are you using a Custom Group? Looks like you are including all of your batteries. Custom group is if you have a few to check or you would like a different % to monitor.
  2. In your custom action you need to do it correctly and it will work. Look in the text were I got the “” and you may have to define your response don’t push the run action to test. I don’t use AI but you could try something like this.
    custom_actions:
      - if:
          - condition: template
            value_template: "{{ not sensors_names_custom_group == '' }}"
        then:
          - action: media_player.volume_mute
            metadata: {}
            target:
              entity_id: media_player.arc_ultra
            data:
              is_volume_muted: true
          - action: conversation.process
            metadata: {}
            data:
              text: >-
                "You seem to have low batteries, here they are
                {{sensors_names_custom_group}}"
            response_variable: response1
          - variables:
              ai_message: >-
                {{ response1.data if response1 is defined else
                'Batteries require attention, sir.' }}
          - action: assist_satellite.announce
            metadata: {}
            target:
              entity_id: assist_satellite.voice_pe_assist_satellite
            data:
              message: "{{ ai_message.response.speech.plain.speech}}"
              preannounce: false
      - if:
          - condition: template
            value_template: "{{ sensors_names_custom_group == '' }}"
        then:
          - action: media_player.volume_mute
            metadata: {}
            target:
              entity_id: media_player.arc_ultra
            data:
              is_volume_muted: true
          - action: conversation.process
            metadata: {}
            data:
              text: Im not seeing any low batteries, your all good to go
            response_variable: response2
          - action: assist_satellite.announce
            metadata: {}
            target:
              entity_id: assist_satellite.voice_pe_assist_satellite
            data:
              message: "{{ response2.response.speech.plain.speech}}"
              preannounce: false

I don’t use AI so you will need to know what your doing in your custom action.

I don’t think this is correct but your call

message: "{{ ai_message.response.speech.plain.speech}}"

HA documentation click here

Blacky :grinning:

“{{ ai_message.response.speech.plain.speech}}” was my fault in posting. i was messing with the code and forgot to post the updated. but i was using the correct response variable from the conversation process into the assist satellite action, should have checked that before posting.

i use custom group because i have a lot of zwave sensors and really theres only certain ones that need to be checked. that list isn’t all of my batteries, just the ones i want notified for. i currently have the automation working using standard tts. However i have spotted another problem.

If i send a tts and a phone notification, only the tts sends. if i disable custom actions, then the phone notification sends. it’s not sending both. Would it be better to just send the phone notification in the custom action as well?

alias: Low Batteries
description: ""
use_blueprint:
  path: Blackshome/low-battery-notifications-and-actions.yaml
  input:
    weekday_options:
      - wed
      - mon
      - fri
      - sun
    time: "09:49:00"
    include_time: time_enabled
    custom_group:
      entity_id:
        - sensor.front_door_battery_level
        - sensor.fold_7_battery_level
        - sensor.node_19_battery_level
        - sensor.foyer_smoke_battery_level
        - sensor.galaxy_watch_ultra_battery_level
        - sensor.guest_smoke_battery_level
        - sensor.guest_window_battery_level
        - sensor.zcombo_g_smoke_co_alarm_battery_level
        - sensor.keypad_v2_battery_level
        - sensor.kitchen_door_battery_level
        - sensor.kitchen_window_battery_level
        - sensor.laura_s_iphone_battery_level
        - sensor.left_master_battery_level
        - sensor.master_smoke_battery_level
        - sensor.right_master_battery_level_2
        - sensor.left_office_battery_level
        - sensor.middle_office_battery_level
        - sensor.office_smoke_battery_level
        - sensor.right_office_battery_level
        - sensor.barn_door_battery_level
        - sensor.left_window_battery_level
        - sensor.middle_window_battery_level
        - sensor.right_window_battery_level
        - sensor.open_close_xs_sensor_battery_level_5
        - sensor.ac_drain_battery
        - sensor.hue_motion_sensor_1_battery
        - sensor.hue_dimmer_switch_1_battery
        - sensor.guest_bathroom_sink_battery
        - sensor.guest_bathroom_toilet_battery
        - sensor.blind_tilt_5a0e_battery
        - sensor.curtain_3_52b1_battery
        - sensor.curtain_3_216e_battery
        - sensor.dishwasher_battery
        - sensor.kitchen_sink_battery
        - sensor.refrigerator_battery
        - sensor.washing_machine_battery
        - sensor.master_bath_sink_battery
        - sensor.master_bath_toilet_battery
        - sensor.blind_tilt_53c1_battery
        - sensor.blind_tilt_bda4_battery
        - sensor.hue_dimmer_switch_2_battery
        - sensor.master_bedroom_battery
        - sensor.office_battery
        - sensor.cutoff_valve_battery
        - sensor.drain_down_valve_battery
        - sensor.laura_s_iphone_watch_battery_level
    include_easy_notify: enable_easy_notify
    sensor_selection: enable_battery_sensors_custom_group
    notify_device:
      - 3227ffd8fc39183b377ab061201ddf5a
    notify_message: sensors
    notify_interruption_level: critical
    notify_data:
      - high_priority
    include_custom_actions: enable_custom_actions
    custom_actions:
      - if:
          - condition: template
            value_template: "{{ all_sensors == '' }}"
        then:
          - action: media_player.volume_mute
            metadata: {}
            target:
              entity_id: media_player.arc_ultra
            data:
              is_volume_muted: true
          - action: assist_satellite.announce
            metadata: {}
            data:
              message: I'm not detecting any low batteries. You're good to go human.
              preannounce: false
            target:
              entity_id:
                - assist_satellite.voice_pe_assist_satellite
          - wait_for_trigger:
              - trigger: state
                entity_id:
                  - assist_satellite.voice_pe_assist_satellite
                to:
                  - idle
          - action: media_player.volume_mute
            metadata: {}
            target:
              entity_id: media_player.arc_ultra
            data:
              is_volume_muted: false
        else:
          - action: media_player.volume_mute
            metadata: {}
            target:
              entity_id: media_player.arc_ultra
            data:
              is_volume_muted: true
          - action: assist_satellite.announce
            metadata: {}
            data:
              message: >-
                I've detected low batteries, i'll also send you a list of them
                as well to each device. Here they are,
                "{{sensors_custom_group}}"
              preannounce: false
            target:
              entity_id:
                - assist_satellite.voice_pe_assist_satellite
          - wait_for_trigger:
              - trigger: state
                entity_id:
                  - assist_satellite.voice_pe_assist_satellite
                to:
                  - idle
          - action: media_player.volume_mute
            metadata: {}
            target:
              entity_id: media_player.arc_ultra
            data:
              is_volume_muted: false
    battery_sensor_report_fields:
      - friendly_name
    notify_okay_message: You have NO low batteries! :)
    notify_title: đŸȘ«Low Battery NotificationđŸȘ«

@IdiotTryingToFindWay

The custom actions are the first thing that happens in the action. If there is something wrong with the custom action it will fail and the automation will stop so the rest of the actions (phone notification) will be stopped.

You shouldn’t have to and it easier to use the blueprint UI. I do have a idea were I will run the custom action in parallel with the rest of the actions. This should resolve your bug in your custom action.

New update out for this.

Blacky :grinning:

New Update 3.4

Stay Charged, Stay Smart! Customize it your way and let’s automate your battery maintenance! :battery::zap:

:toolbox: Maintenance

Custom actions now run in parallel to prevent the entire automation from failing if a custom action is misconfigured.


If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

2 Likes

Missed your reply! Yeah, the notify groups have to be right now. configuration.yaml

notify:
  - name: notify-person1-phone
    platform: group
    services:
      - service: mobile_app_person1_pixel_10
  - name: notify-person2-phone
    platform: group
    services:
      - service: mobile_app_person2_pixel_9
  - name: notify-person1-watch
    platform: group
    services:
      - service: mobile_app_person1_pixel_watch_3

And then each of those names is available as a notification option in automations. So I have a crap-tonne of automations to send notifications using them. Get a new phone or watch, and I just have to change the device in configuration.yaml rather than each automation.

It would be way cooler if this was made available in the gui instead of having to do this, but for now it’s not