Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data:
- timestamp: >-
- {%- macro next_time(input_id) -%}
- {{ (today_at(states(input_id)) + iif(states(input_id) < now().strftime("%H:%M:%S"), timedelta(days=1), timedelta())) | as_timestamp }}
- {%- endmacro %}
- {%- macro get_range(checkpoint, start_entity, end_entity) -%}
- {%- set next_range_start=next_time(start_entity) | float %}
- {%- set range_end=next_time(end_entity) | float %}
- {%- set range_start = iif(next_range_start > range_end, next_range_start - 86400, next_range_start) -%}
- {%- set checkpoint_in_range = (range_start < checkpoint <= range_end) %}
- {{ [checkpoint_in_range, range_end] | to_json }}
- {%- endmacro %}
- {%- set in_minutes = (now() + timedelta(minutes=states('input_number.delay_duration')|int(180)) | as_timestamp %}
- {%- set is_morning, morning_end = get_range(in_minutes, 'input_datetime.morning_start_output', 'input_datetime.morning_end_output') | from_json %}
- {%- set is_day, day_end = get_range(in_minutes, 'input_datetime.day_start_output', 'input_datetime.day_end_output' ) | from_json %}
- {%- set is_evening, evening_end = get_range(in_minutes, 'input_datetime.evening_start_output', 'input_datetime.evening_end_output') | from_json %}
- {%- set is_night, night_end = get_range(in_minutes, 'input_datetime.night_start_output', 'input_datetime.night_end_output' ) | from_json %}
- {%- if is_morning %}{{ morning_end }}
- {%- elif is_day %}{{ day_end }}
- {%- elif is_evening %}{{ evening_end }}
- {%- elif is_night %}{{ night_end }}
- {%- else %}{{ in_minutes }}{%- endif %}
- target:
- entity_id: input_datetime.salon_na_parterze_kinkiet_przy_lozku_opoznienie
- action: input_datetime.set_datetime
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement