Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3.
- - platform: template
- sensors:
- person1_destination:
- friendly_name: "Person 1 Destination"
- value_template: "{{ state_attr('calendar.person1_gmail_com', 'location') }}"
- 5.
- - platform: template
- sensors:
- timetoleaveperson1:
- friendly_name: Time Person1 needs to leave
- value_template: >-
- {{
- ((as_timestamp(state_attr('calendar.person1_gmail_com','start_time'))
- - (state_attr('sensor.person1_to_calendar','duration')|int) * 60)|timestamp_custom()) | default(now)
- }}
- 6.
- type: markdown
- content: |-
- {% set timeleft =
- ((as_timestamp(states.sensor.timetoleaveperson1.state)
- - as_timestamp(now())) / 60) | int %}
- {% if (states.person.person1.state == 'home') %}
- {% if ((((as_timestamp(state_attr('calendar.person1_gmail_com', 'start_time')) - as_timestamp(now())) / 60) | int) >= -60) %}
- {% if timeleft < 120 %} {#Home and less than 2h to leave #}
- {%- if timeleft > 0 %} {#Person 1 is home and not late#}
- Person1, to make it to
- **{{states.calendar.person1_gmail_com.attributes.message}}**
- you need to leave at **{{((as_timestamp(states.sensor.timetoleaveperson1.state))|timestamp_custom("%H:%M"))}}**
- so you have **{{timeleft}}** minutes
- {%- elif timeleft <0 %} {#Home and late #}
- Person 1, you're late for **{{states.calendar.person1_gmail_com.attributes.message}}**!!
- {%- endif -%}
- {%- else -%} {#Home and more than 2 hours to the next meeting#}
- Person 1 has nothing planned soon
- {%- endif -%} {#Home and at least hour after person1 was supposed to leave -> either back from work or never went#}
- {%- endif -%}
- {%- else -%} {#Not home#}
- {% if timeleft < 15 %} {#Less than 15 minutes to when person1 is suposed to leave, probably left already#}
- Person 1 is expected back around **{{(as_timestamp(states.calendar.person1_gmail_com.attributes.end_time) + (states.sensor.person1_to_home.attributes.duration * 60 | int)) |timestamp_custom ("%H:%M")}}**
- {%- else -%} {#Not home but still plenty of time to next meeting, probably out and about#}
- {# Message for when Person 1is not home#}
- {%- endif -%}
- {%- endif -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement