I have created the following automation which is basically:
When I leave home, my two vacuums will clean designated rooms and turn off lights.
If I leave home for a second time that same day, vacuum 1 will clean additional rooms and turn off lights.
alias: 2-vaccum
description: ""
trigger:
- platform: state
entity_id:
- zone.home
to: "0"
condition: []
action:
- if:
- condition: template
value_template: >-
{{ this.attributes.last_triggered | default(as_datetime(0)) <
today_at() }}
then:
- service: vacuum.send_command
metadata: {}
data:
params:
rooms:
- Hallway
- Kitchen
target:
entity_id: vacuum.irobot
- service: vacuum.send_command
metadata: {}
data:
params:
rooms:
- Living Room
target:
entity_id: vacuum.irobot2
- service: light.turn_off
target:
entity_id:
- light.dining_room_dimmer_light_sw
- light.chair_dimmer_light_sw
- light.hall_bathroom_light_sw
- light.hall_light_dimmer_sw
- light.hallway_dimmer_light_sw
- light.loft_dimmer_light_sw_basic
- light.master_bedroom_light_sw
- light.master_closet_light_dimmer_switch
- light.office_light_dimmer_sw
- light.stair_light_fixture_dimmer_light_sw
- light.sun_room_dimmer_light_sw
- light.vaulted_ceiling_light_sw
- light.entryway_dimmer_sw
- light.garage_attic_light_sw_basic
data: {}
- service: switch.turn_off
target:
entity_id:
- switch.banister_xmas_lights_kp_7
- switch.couch_light_sw
- switch.garage_attic_light_sw
- switch.in_wall_paddle_switch_qfsw_500s
- switch.guest_bedroom_light_sw_2
- switch.in_stair_foot_light_sw_2
- switch.kitchen_undercabinet_light_sw
- switch.master_bathroom_light_switch
- switch.xmas_tree_lights_kp6
data: {}
- delay:
hours: 0
minutes: 32
seconds: 0
milliseconds: 0
- service: switch.turn_off
target:
entity_id:
- switch.kitchen_light_sw
data: {}
else:
- service: vacuum.send_command
metadata: {}
data:
params:
rooms:
- Sun Room
- Dining Room
- Laundry
target:
entity_id:
- vacuum.irobot
- service: switch.turn_off
target:
entity_id:
- switch.banister_xmas_lights_kp_7
- switch.couch_light_sw
- switch.garage_attic_light_sw
- switch.in_wall_paddle_switch_qfsw_500s
- switch.guest_bedroom_light_sw_2
- switch.in_stair_foot_light_sw_2
- switch.kitchen_light_sw
- switch.master_bathroom_light_switch
- switch.xmas_tree_lights_kp6
data: {}
- service: light.turn_off
target:
entity_id:
- light.dining_room_dimmer_light_sw
- light.chair_dimmer_light_sw
- light.hall_bathroom_light_sw
- light.hall_light_dimmer_sw
- light.hallway_dimmer_light_sw
- light.loft_dimmer_light_sw_basic
- light.master_bedroom_light_sw
- light.master_closet_light_dimmer_switch
- light.office_light_dimmer_sw
- light.stair_light_fixture_dimmer_light_sw
- light.sun_room_dimmer_light_sw
- light.vaulted_ceiling_light_sw
- light.entryway_dimmer_sw
- light.garage_attic_light_sw_basic
data: {}
- delay:
hours: 0
minutes: 36
seconds: 0
milliseconds: 0
- service: light.turn_off
target:
entity_id:
- switch.kitchen_light_sw
data: {}
mode: single
The problem I am having is the template code here:
condition: []
action:
- if:
- condition: template
value_template: >-
{{ this.attributes.last_triggered | default(as_datetime(0)) <
today_at() }}
does not execute. The automation stops.
I get the following error:
Error: required key not provided @ data['command']
I have this same code in another automation and it works just fine.
Thanks in advance for any and all help.