so after updating to 118, I now see this for the first time using an automation that has been there for ever…
some how the var entityid which gets passed to the script isn’t correct, and I don’t see why, because several other scripts/automations I use don’t return this error. Please have a look with me?
automation:
- alias: Trigger alarm while armed
trigger:
platform: state
entity_id:
- binary_sensor.attic_sensor_motion
- binary_sensor.auditorium_sensor_motion
- binary_sensor.front_room_sensor_motion
...
- binary_sensor.master_bedroom_sensor_motion
to: 'on'
condition:
- >
{{trigger.to_state is not none and
trigger.from_state is not none and
trigger.to_state.state != trigger.from_state.state}}
- >
{{states('alarm_control_panel.ha_rpi4_alarm') in ['armed_away','armed_home']}}
action:
- service: alarm_control_panel.alarm_trigger
entity_id: alarm_control_panel.ha_rpi4_alarm
- condition: state
entity_id: input_boolean.notify_alarm
state: 'on'
- service: script.alarm_triggered
data:
entityid: >
{{trigger.entity_id}}
and script:
alarm_triggered:
alias: Alarm triggered
mode: queued
sequence:
service: notify.mobile_app_calltheboss
data:
title: >
{% set room = entityid.object_id.split('_sensor_motion')[0].replace('_',' ')|capitalize %}
Alarm triggered in the {{room}}
message: >
{% set name = entityid.object_id.replace('_',' ')|capitalize %}
{{as_timestamp(now())|timestamp_custom('%X')}}: {{name}} triggered the alarm, check whats up!
while this:
- service: >
script.{% if is_state('input_boolean.notify_announcement','on') %}announce_presence
{% elif is_state('input_boolean.notify_presence','on') %}notify_presence
{% else %}continue
{% endif %}
data:
trigger: Presence tracking
entityid: '{{trigger.entity_id}}'
tostate: '{{trigger.to_state.state}}'
fromstate: '{{trigger.from_state.state}}'
and script:
notify_presence:
alias: Notify presence
mode: queued
sequence:
service: notify.notify
data:
title: >
{{trigger}}: {{state_attr(entityid,'friendly_name')}} notification
message: >
{% set name = state_attr(entityid,'friendly_name') %}
{{as_timestamp(now())|timestamp_custom('%X')}} :
{% if tostate == 'not_home' %}
{{-name}} left {{fromstate}}
{% elif fromstate == 'not_home' %}
{{-name}} arrived at {{tostate}}
{% else %}
{{-name}} left {{fromstate}} and arrived at {{tostate}}
{% endif %}
works just as it has always done
I can manipulate the string like this of course:
{% set entityid = 'binary_sensor.attic_sensor_motion' %}
{% set room = entityid.split('.')[1].split('_sensor_motion')[0].replace('_',' ')|capitalize %}
{{room}}
but rather like to manipulate the object itself:
this works just fine, all in the 1 automation:
- service: notify.mobile_app_calltheboss
data:
title: >
{% set room = trigger.to_state.object_id.split('_sensor_motion')[0].replace('_',' ')|capitalize %}
Alarm triggered in the {{room}}
message: >
{% set room = trigger.to_state.object_id.split('_sensor_motion')[0].replace('_',' ')|capitalize %}
{{as_timestamp(now())|timestamp_custom('%X')}}: {{room}} triggered the alarm, check whats up!
thanks!