Alternative Plant problem notification

This Blueprint for each configured plant, checks its status and notifies if there are any problems.
This blueprint works in conjunction with “Alternative plants component for Home Assistant”.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Alternative Plant problem notification
  description: |
    For each configured plant, checks its status and notifies if there are any problems.
    This blueprint works in conjunction with "Alternative plants component for Home Assistant".
     * https://github.com/Olen/homeassistant-plant
  domain: automation
  author: Alex Soto Aguilera
  source_url: https://gist.github.com/alexsotoaguilera/462e40dcbc40a0fa0dd460755ef3defa
  homeassistant:
    min_version: 2022.4.0

  input:
    notification_time:
      name: Time to check all plant sensors
      description: The verification of the plant sensors takes place within the configured time.
      default: '10:00:00'
      selector:
        time: {}
    exclude:
      name: Excluded plants
      description: Plants to exclude from report.
      default:
        entity_id: []
      selector:
        target:
          entity:
          - device_class:
            - plant
    devices_to_notify:
      name: Devices to notify
      description: Device needs to run the official Home Assistant app to receive notifications.
      default: []
      selector:
        device:
          filter:
            - integration: mobile_app
          multiple: true

variables:
  exclude_plant_entities: !input exclude
  notify_plant_entities: |
    {% set plant_entities = states.plant | map(attribute='entity_id') | select('is_state', 'problem') | list %}
    {% set data = namespace(notify_entities=[]) %}
    {% for plant_entity in plant_entities %}
      {% if plant_entity not in exclude_plant_entities %}
         {% set data.notify_entities = data.notify_entities + [plant_entity] %}
      {% endif %}
    {% endfor %}
    {{ data.notify_entities }}

trigger:
- platform: time
  at: !input 'notification_time'

action:
  - repeat:
      for_each: !input 'devices_to_notify'
      sequence:
        - variables:
            device_to_notify: "{{ repeat.item }}"
        - repeat:
            for_each: "{{ notify_plant_entities }}"
            sequence:
              - service: "notify.mobile_app_{{ device_attr(device_to_notify, 'name') | slugify }}"
                data:
                  title: "Plant WARNING: {{ state_attr(repeat.item, 'friendly_name') }}."
                  message: |
                      {% set plant_sensors = device_entities(device_id(repeat.item)) | select('is_state_attr', 'state_class', 'measurement') | list -%}
                      {% for sensor in plant_sensors -%}
                        {% if not is_state(sensor, 'unknown') -%}
                          - {{ state_attr(sensor, 'device_class') }} {{ states(sensor) }}{{ state_attr(sensor, 'unit_of_measurement') }}
                        {% endif -%}
                      {% endfor -%}
mode: single

Changelog

  • November 2, 2024: Initial release
  • November 10, 2024: Fixed truncation in notification splitting in one notification per plant

Would it be possible to be able to specify our own notify service beside mobile one?

I would love to, but I still don’t know how to make a selectable notification service.

I’m still researching

Hi lynks,

Nice job, very interesting!
Another enhancement might be Something TTS. I’d rather my speaker just tell me the status.
I have a script blueprint that could be called, for instance, so that part would not need to be built if you want to colab and refer to that. Here you would just need to (assuming my script blueprint is installed) call the action from your BP with the information you generate.
HA_Blueprints/Scripts/tts_All_Message_Script_Blueprint.md at d1c15d75a7b5fa3042d60f7eee2d7633ea8a27a3 · SirGoodenough/HA_Blueprints · GitHub.

EDIT…
just had another thought. This could be as simple as you have the user generate a text helper, and you populate the text helper with your information. Then the user has the information in an entity and they can send that to their TTS or to their own Notification service or paste it in their Dashboard or whatever…
That solves a lot of problems…
Otherwise you will have an endless string of
I want the information this way or that way...

1 Like