Meteorologisk institutt (Met.no) how to include state in my alert message

I have created an alert if any of my windows are opened (using a helper I created for a separate alert) if the forecast is raining etc but in the alert I would like the actual state e.g. raining, pouring, snowing, does anyone know how I can do this? Below is the code I created via the UI:

alias: Rain alert + window opened notif
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.living_room_window_left_opening
      - binary_sensor.living_room_window_right_opening
      - binary_sensor.kitchen_window_opening
      - binary_sensor.bedroom_one_window_left_opening
      - binary_sensor.bedroom_one_window_right_opening
    from: "off"
    to: "on"
condition:
  - condition: device
    device_id: XXXX
    domain: device_tracker
    entity_id: d272519f302aedf87c0b3cffa3c14a15
    type: is_not_home
    enabled: false
  - condition: or
    conditions:
      - condition: state
        entity_id: weather.forecast_home
        state: lightning-rainy
      - condition: state
        entity_id: weather.forecast_home
        state: rainy
      - condition: state
        entity_id: weather.forecast_home
        state: pouring
      - condition: state
        entity_id: weather.forecast_home
        state: snowy-rainy
      - condition: state
        entity_id: weather.forecast_home
        state: snowy
action:
  - device_id: XXXXXYYYY
    domain: mobile_app
    type: notify
    message: >-
      {{ trigger.to_state.attributes.friendly_name }}  has been opened while
      raining
mode: single

Thanks!
Chris

you mean like this? or am i misundestanding?

just for fun i changed your condition block… it’s logically identical to what you had, so ignore/restore that if you’d like… the answer to your question is in the last message: line

alias: Rain alert + window opened notif
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.living_room_window_left_opening
      - binary_sensor.living_room_window_right_opening
      - binary_sensor.kitchen_window_opening
      - binary_sensor.bedroom_one_window_left_opening
      - binary_sensor.bedroom_one_window_right_opening
    from: "off"
    to: "on"
condition:
  - condition: device
    device_id: XXXX
    domain: device_tracker
    entity_id: d272519f302aedf87c0b3cffa3c14a15
    type: is_not_home
    enabled: false
  - condition: template
    value_template: |-
      {{ states('weather.forecast_home') in 
         ['lightning-rainy', 
           'rainy',
           'pouring',
           'snowy-rainy',
           'snowy'] }}
action:
  - device_id: XXXXXYYYY
    domain: mobile_app
    type: notify
    message: >-
      {{ trigger.to_state.attributes.friendly_name }}  has been opened while
      {{ states('weather.forecast_home') }}
mode: single

Thank you @armedad this worked perfectly!

just for fun, look at the updated condition block…

1 Like