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

Area of a trigger

$
0
0

I have an automation to look if it’s outside hotter/colder than inside.
I would like to make in generic as possible to be able to use it for all rooms.

I tested in the developer tools, but it looks like the trigger don’t work as axpected.
e.g
{{ area_name('sensor.thermostat_kuche_simon_temperature')}} {{floor_name('sensor.thermostat_kuche_simon_temperature')}}

result: Küche 1. Stock
Perfect!

Okay thought let’s implement it:

data:
  message: >-
    Fenster auf! - Draußen ist es Wärmer als in {{
    area_name('trigger.entity_id')}} {{floor_name('trigger.entity_id')}} 
action: notify.matrix_harms_vorhop

Result:
Fenster auf! - Draußen ist es Wärmer als in None None

Why?

The complete automation:

alias: Test - Temperatur indoor vs outdoor
description: ""
triggers:
  - entity_id:
      - sensor.thermostat_kuche_simon_temperature
    id: kaelter
    trigger: numeric_state
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: sensor.ems_esp_boiler_outdoortemp
  - entity_id:
      - sensor.thermostat_kuche_simon_temperature
    id: waermer
    trigger: numeric_state
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: sensor.ems_esp_boiler_outdoortemp
  - entity_id:
      - sensor.schlafzimmer_shellytrv_simon_temperature
    id: kaelter
    trigger: numeric_state
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: sensor.ems_esp_boiler_outdoortemp
  - entity_id:
      - sensor.schlafzimmer_shellytrv_simon_temperature
    id: waermer
    trigger: numeric_state
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: sensor.ems_esp_boiler_outdoortemp
conditions: []
actions:
  - alias: Test mehr als 2 Fenster
    if:
      - condition: template
        value_template: |-
          {{ area_entities(area_name('trigger.entity_id'))
            | select('match', 'binary_sensor.*fenster*') | list | count > 1 }}
    then:
      - action: matrix.send_message
        metadata: {}
        data:
          target: "!kieWnhLSTvrErkkdlP:matrix.org"
          message: Mehr als 1 Fenster
  - choose:
      - conditions:
          - condition: trigger
            id:
              - kaelter
        sequence:
          - if:
              - condition: state
                entity_id: input_text.vorhop_weather_forecast
                state: warm
            then:
              - alias: Genau ein Fenster vorhanden? - warm
                if:
                  - condition: template
                    value_template: |-
                      {{ area_entities(area_name('trigger.entity_id'))
                        | select('match', 'binary_sensor.*fenster*') | list | count == 1 }}
                    alias: Genau ein Fenster vorhanden?
                then:
                  - alias: Fenster geschlossen?
                    if:
                      - condition: template
                        value_template: |2-
                           {{ states((area_entities(area_name('trigger.entity_id'))
                            | select('match', 'binary_sensor.*fenster*') | list)[0]) == "off" }}
                        alias: Fenster geschlossen?
                    then:
                      - data:
                          message: >-
                            Fenster geschlossen halten! - Draußen ist es Wärmer
                            als in {{ area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}
                        action: notify.matrix_harms_vorhop
                    else:
                      - data:
                          message: >-
                            Fenster zu! - Draußen ist es Wärmer als in {{
                            area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}
                        action: notify.matrix_harms_vorhop
                else:
                  - data:
                      message: >-
                        Fenster zu! - Draußen ist es Wärmer als in {{
                        area_name('trigger.entity_id')}}
                        {{floor_name('trigger.entity_id')}}
                    action: notify.matrix_harms_vorhop
            else:
              - alias: Genau ein Fenster vorhanden? - nicht-warm
                if:
                  - condition: template
                    value_template: |-
                      {{ area_entities(area_name('trigger.entity_id'))
                        | select('match', 'binary_sensor.*fenster*') | list | count == 1 }}
                    alias: Genau ein Fenster vorhanden?
                then:
                  - alias: Fenster offen?
                    if:
                      - alias: Fenster offen?
                        condition: template
                        value_template: |2-
                           {{ states((area_entities(area_name('trigger.entity_id'))
                            | select('match', 'binary_sensor.*fenster*') | list)[0]) == "on" }}
                    then:
                      - data:
                          message: >-
                            Fenster offen lassen! - Draußen ist es Wärmer als in
                            {{ area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}
                        action: notify.matrix_harms_vorhop
                    else:
                      - data:
                          message: >-
                            Fenster auf! - Draußen ist es Wärmer als in {{
                            area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}
                        action: notify.matrix_harms_vorhop
                else:
                  - data:
                      message: >-
                        Fenster auf! - Draußen ist es Wärmer als in {{
                        area_name('trigger.entity_id')}}
                        {{floor_name('trigger.entity_id')}}
                    action: notify.matrix_harms_vorhop
      - conditions:
          - condition: trigger
            id:
              - waermer
        sequence:
          - if:
              - condition: state
                entity_id: input_text.vorhop_weather_forecast
                state: warm
            then:
              - alias: Genau ein Fenster vorhanden? - warm
                if:
                  - condition: template
                    value_template: |-
                      {{ area_entities(area_name('trigger.entity_id'))
                        | select('match', 'binary_sensor.*fenster*') | list | count == 1 }}
                    alias: Genau ein Fenster vorhanden?
                then:
                  - alias: Fenster offen?
                    if:
                      - alias: Fenster offen?
                        condition: template
                        value_template: |2-
                           {{ states((area_entities(area_name('trigger.entity_id'))
                            | select('match', 'binary_sensor.*fenster*') | list)[0]) == "on" }}
                    then:
                      - data:
                          message: >-
                            Fenster offen lassen! - Draußen ist es kälter als in
                            {{ area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}  
                        action: notify.matrix_harms_vorhop
                    else:
                      - data:
                          message: >-
                            Fenster auf! - Draußen ist es kälter als in {{
                            area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}  
                        action: notify.matrix_harms_vorhop
                else:
                  - data:
                      message: >-
                        Fenster auf! - Draußen ist es kälter als in {{
                        area_name('trigger.entity_id')}}
                        {{floor_name('trigger.entity_id')}} 
                    action: notify.matrix_harms_vorhop
            else:
              - alias: Genau ein Fenster vorhanden? - nicht-warm
                if:
                  - condition: template
                    value_template: |-
                      {{ area_entities(area_name('trigger.entity_id'))
                        | select('match', 'binary_sensor.*fenster*') | list | count == 1 }}
                    alias: Genau ein Fenster vorhanden?
                then:
                  - alias: Fenster geschlossen?
                    if:
                      - alias: Fenster geschlossen?
                        condition: template
                        value_template: |2-
                           {{ states((area_entities(area_name('trigger.entity_id'))
                            | select('match', 'binary_sensor.*fenster*') | list)[0]) == "off" }}
                    then:
                      - data:
                          message: >-
                            Fenster geschlossen halten! - Draußen ist es kälter
                            als in {{ area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}
                        action: notify.matrix_harms_vorhop
                    else:
                      - data:
                          message: >-
                            Fenster zu! - Draußen ist es kälter als in {{
                            area_name('trigger.entity_id')}}
                            {{floor_name('trigger.entity_id')}}  
                        action: notify.matrix_harms_vorhop
                else:
                  - data:
                      message: >-
                        Fenster zu! - Draußen ist es kälter als in {{
                        area_name('trigger.entity_id')}}
                        {{floor_name('trigger.entity_id')}}
                    action: notify.matrix_harms_vorhop
mode: parallel
max: 10

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106639

Trending Articles



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