AutomationDataset/multipolygon/multipolygon_automations.yaml

70 lines
2.1 KiB
YAML

- alias: Watchy Calendar Agenda
description: ''
triggers:
- entity_id:
- switch.watchy_56ae04_connected
to: 'on'
trigger: state
conditions: []
actions:
- response_variable: agenda
metadata: {}
target:
entity_id:
- calendar.main
- calendar.birthdays
action: calendar.get_events
data_template:
start_date_time: '{{ today_at("00:00:00") }}'
end_date_time: '{{ today_at("23:59:59") }}'
- alias: Parse data
variables:
simplified: "[\n {% for i in (agenda['calendar.main'].events + agenda['calendar.birthdays'].events)\
\ | sort(attribute=\"start\") %}\n {% set start = as_datetime(i.start)\
\ %}\n {% set end = as_datetime(i.end) %}\n {% if start.day == now().day\
\ %}\n {{ [(start.hour * 60 + start.minute), (end.hour * 60 + end.minute)\
\ if end.day == now().day else (24 * 60), (i.summary | trim)] | to_json }},\n\
\ {% endif %}\n {% endfor %}\n]\n"
- action: persistent_notification.create
enabled: false
data_template:
message: '{{ simplified | to_json }}
'
- data_template:
agenda_json: '{{ simplified | to_json }}'
action: esphome.watchy_56ae04_set_agenda
mode: single
- alias: Watchy Weather
description: ''
triggers:
- entity_id:
- switch.watchy_56ae04_request_weather
to: 'on'
trigger: state
conditions: []
actions:
- action: rest_command.openweathermap_forecast
response_variable: response
data: {}
- if:
- condition: template
value_template: '{{ response.status == 200 }}'
then:
- alias: Parse data
variables:
simplified: '{ "list": [ {% for i in response.content.list %} {{ { ''dt'':
i.dt, ''main'': { ''feels_like'': i.main.feels_like }, ''weather'': [{ ''id'':
i.weather.0.id }], ''sys'': { ''pod'': i.sys.pod } } }} {{ "," if not loop.last
}} {% endfor %} ] }
'
- action: persistent_notification.create
data:
message: '{{ simplified }}'
enabled: false
- action: esphome.watchy_56ae04_set_weather
data_template:
weather_json: '{{ simplified }}'
mode: single