Hi,
i need help with a calendar action. i have two entries in my calendar.
Work begin and work end.
And now i would like to measure the time between this entries and writes a third entry with the measured duration in hours. If hours are about 8 hours, ist should be red entry otherwise without special color. How can i do this?
I try the automation:
description: ""
trigger:
- platform: webhook
allowed_methods:
- POST
- PUT
- HEAD
- GET
local_only: false
webhook_id: mysecretID
id: Arbeitsanfang
condition:
- condition: template
value_template: "{{ trigger.data.user_name == 'myusername' }}"
action:
- service: notify.mobile_app_iphone14
metadata: {}
data:
message: "message: '{{ trigger.data.user_name }}'"
title: Webhook ist da
data:
message: "{{ trigger.data.user_name }}"
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.data.command == '/start' }}"
sequence:
- service: calendar.create_event
metadata: {}
data:
summary: Arbeitsbegin
description: Los gehts
location: Firma
start_date_time: "{{ now() }}"
end_date_time: "{{ now() + timedelta(minutes=1) }}"
target:
entity_id: calendar.arbeit
- conditions:
- condition: template
value_template: "{{ trigger.data.command == '/ende' }}"
sequence:
- service: calendar.create_event
metadata: {}
data:
summary: Arbeitsende
description: Für heute reicht es
location: Firma
start_date_time: "{{ now() }}"
end_date_time: "{{ now() + timedelta(minutes=1) }}"
target:
entity_id: calendar.arbeit
- service: calendar.get_events
target:
entity_id:
- calendar.arbeit
data:
start_date_time: "{{ now() }}"
end_date_time: "{{ now() }}"
response_variable: liste
- service: calendar.create_event
metadata: {}
data:
summary: Zeit
description: liste
location: Arbeitszeit
start_date: "2024-02-16"
end_date: "2024-02-16"
duration: 24
target:
entity_id: calendar.arbeit
- service: notify.telegram_notify_user
metadata: {}
data:
message: >-
{{ (liste.events | selectattr('start', 'eq',
(now()+timedelta(days=1)).date()|string ) | first).summary }}
- service: ""
data: {}
mode: single
type or paste code here
i get two webhooks which enter the entry for work beginning and end… that works…
But the measurement is thy problem…
thanks for help…