I’d like to setup an automation that takes the input from OpenWeatherMap rain, Then sends me a notification that one of my windows is open from a list of 30.
The window sensors are all zigbee and grouped together. the notification works except it doesn’t contain which window is open,
The message line wraps itself after I save the automation regardless if I edit via the GUI or File directly. Im not wrapping it. HA is doing it, So im not sure if thats affecting it.
alias: 'Its Raining Close Windows '
description: Notify if A first Floor Window is optn
trigger:
- platform: numeric_state
entity_id: sensor.openweathermap_weather_code
attribute: attribution
above: '499'
below: '532'
condition:
- condition: state
entity_id: group.windows
state: 'on'
action:
- service: notify.mobile_app_walter_app
data_template:
message: >-
Rain Is Detected ;{% set domain =
'binary_sensor' %}{% set state = 'on' %} {{ states[domain] |
selectattr('state','eq', state) | selectattr('attributes.device_class',
'eq', 'window') | map(attribute='name') | list | join(', ') }}
mode: single
If I understand your post, you are asking how to insert the name of all open windows in your notify message, correct?
I’m not really sure what you are trying to do with the posted code. In HA, what is the entity and the state (or attribute) that will tell you which window is open? To my knowledge there is no group attribute that will tell you which member of the group is on.
That can’t be correct. Why not? Because it’s common to most weather integrations and contains the name of the weather provider.
I believe you simply want the trigger to listen to the sensor’s state changes (and not one of its attributes). Therefore remove attribute: attribution from the trigger.
alias: 'Its Raining Close Windows '
id: its_raining_close_windows
description: Notify if A first Floor Window is open
trigger:
- platform: numeric_state
entity_id: sensor.openweathermap_weather_code
above: 499
below: 532
condition:
- condition: state
entity_id: group.windows
state: 'on'
action:
- service: notify.mobile_app_walter_app
data_template:
message: >-
Rain Is Detected. Please close the following windows: {{ expand('group.windows') | selectattr('state','eq', 'on') | map(attribute='name') | join(', ') }}
mode: single
NOTE
Due to the way a Numeric State Trigger works, it will trigger only when the weather_code’s value changes from outside of the range to inside the range.
From a value below 499 to a higher value but below 532.
From a value higher than 532 to a lower value but above 499.
In other words, it only triggers when it crosses one of the two thresholds. It will not trigger if the value changes from 500 to 505 or from 529 to 512. All changes within the range will not trigger the automation.
Looks like I have to put this on hold for a moment.
Something is borked on my install. In the GUI yaml editor, there’s no longer a save button. and if I edit the automation.yaml file directly, Non of my automations load.
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
automation: !include automations.yaml
automation old: !include_dir_merge_list automations
binary_sensor: !include binary_sensors.yaml
automations.yaml is solely used by the editor, and I have a variety of hand-written YAML files in the automations folder, arranged into subfolders. The UI editor can’t touch these (which is good).