Hello,
I have this automation :
- entity_id:
- person.alex_bostoen
to: home
id: alex_bostoen is thuis
trigger: state
for:
hours: 0
minutes: 0
seconds: 1
...
- data:
titel: >
{% set x = trigger.id %} {% set x = x.replace(' is
thuis','').replace(' is weg','').replace(' is zeker weg','') %}
{% set y = x.split('_') %} {{ y[0].capitalize() + ' ' +
y[1].capitalize() + ' is ten huize Bostoen' }}
boodschap: >
{{'Thuisgekomen op ' + now().timestamp() |
timestamp_custom('%d/%m/%Y') + ' om ' + (now() -
timedelta(seconds = trigger.for.seconds|int(0) )).timestamp() |
timestamp_custom('%H:%M:%S')}}
notificatie: false
mail: true
tts: true
tts_boodschap: >-
{% set x = trigger.id %} {% set x = x.replace(' is
thuis','').replace(' is weg','').replace(' is zeker weg','') %}
{% set y = x.split('_') %} {{ y[0].capitalize() + ' ' +
y[1].capitalize() + ' is aangekomen' }}
action: script.berichten
This works great !
But how take into account the number of minutes… ?
I did this :
- data:
titel: >
{% set x = trigger.id %} {% set x = x.replace(' is
thuis','').replace(' is weg','').replace(' is zeker weg','') %}
{% set y = x.split('_') %} {{ y[0].capitalize() + ' ' +
y[1].capitalize() + ' is ten huize Bostoen' }}
boodschap: >
{{'Thuisgekomen op ' + now().timestamp() |
timestamp_custom('%d/%m/%Y') + ' om ' + (now() -
timedelta(minutes = trigger.for.minutes|int(0), seconds = trigger.for.seconds|int(0) )).timestamp() |
timestamp_custom('%H:%M:%S')}}
notificatie: false
mail: true
tts: true
tts_boodschap: >-
{% set x = trigger.id %} {% set x = x.replace(' is
thuis','').replace(' is weg','').replace(' is zeker weg','') %}
{% set y = x.split('_') %} {{ y[0].capitalize() + ' ' +
y[1].capitalize() + ' is aangekomen' }}
action: script.berichten
But get this error ?
What am I missing here ?