Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 108510

Help: spot the error I am making in this blueprint that checks plant soil conductivity to trigger notification

$
0
0

Automations created with this blueprint is not triggering as intended.

blueprint:
  name: Plants low fertilizer detection and notification.
  description: Regularly test all plant sensors with 'conductivity low' problem 
    and notify via Mobile App and Voice Assistants.
  domain: automation



  input:
    check_time:
      name: 'Time of the day to test on: '
      description: Test is run at this configured time
      default: '10:00:00'
      selector:
        time:

    conductivity_threshold:
      name: 'Threshold under which notification is triggered:'
      selector:
        number:
          min: 0
          max: 500
          step: 1
          unit_of_measurement: "µS/cm"
          mode: slider


    check_day:
      name: Weekday to test on
      description: 'Test is run at configured time either everyday (0) or on a given
        weekday (1: Monday ... 7: Sunday)'
      default: '0'
      selector:
        select:
          options:
            - label: Everyday
              value: '0'
            - label: Monday
              value: '1'
            - label: Tuesday
              value: '2'
            - label: Wednesday
              value: '3'
            - label: Thursday
              value: '4'
            - label: Friday
              value: '5'
            - label: Saturday
              value: '6'
            - label: Sunday
              value: '7'
          mode: list


    excluded_plants:
      name: Excluded Plants
      description: Plant entities (e.g. cactus) to exclude from detection. Only entities are supported!
      default: {entity_id: []}
      selector:
        target:
          entity:
            domain: plant
      
# variables
variables:
  day: !input 'check_day'
  excluded_plants: !input 'excluded_plants'
  threshold: !input 'conductivity_threshold'

  hungry_plants: >-

    {% set hungry = namespace( plants = [] ) %}
    {% set allplants = states.plant %}
    {% for plant in allplants if 'conductivity low' in plant.attributes.problem %}
      {% if not plant.entity_id in excluded_plants.entity_id %}
        {% if plant.attributes.conductivity | int < threshold %}
            {% set hungry.plants = hungry.plants + [plant.attributes.friendly_name] %}
        {% endif %}
      {% endif %}
    {% endfor %}

    {% if hungry.plants|length >= 2 %}
      {{ hungry.plants|join(', ') + ' have' }}
    {% elif hungry.plant|length == 1 %}
      {{ hungry.plants|join(', ') + ' has' }}
    {% else %}
      {{ '' }}
    {% endif %} 


# trigger
trigger:
- platform: time
  at: !input 'check_time'

# condition
condition:
- '{{ hungry_plants != '''' and (day | int == 0 or day | int == now().isoweekday()) }}'

# action
action:
- service: notify.all_devices
  data:
    title: Plant Conductivity Alert
    message: '{{ hungry_plants }} low conductivity, consider fertilizing!'
    data:
      group: plantfertlizer-notification-group

- service: notify.alexa_media
  data:
    data:
      type: announce
    target:
    - media_player.echo_main_bedroom
    - media_player.echo_kitchen
    message: 'Attention: {{ hungry_plants }} low conductivity, consider fertilizing!'

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 108510

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>