hi,
i’m trying to setup a binary sensor based on multiple motion sensors and room locations of current home devices to identify is anyone is present in room e.g. anyone in livinigroom or bedroom.
below code is not working when template value is defined in multiple lines…
no_one_in_livingroom:
friendly_name: No one in Livingroom
value_template: >-
'{{ (states.sensor.lalit_room_location.state != "livingroom" and
states.sensor.jyoti_room_location.state != "livingroom")
and (
( (now()-states.binary_sensor.livingroom_motion.last_changed).total_seconds() > 1*60) and
( (now()-states.binary_sensor.gallery_motion.last_changed).total_seconds() > 1*60) and
( (now()-states.binary_sensor.kitchen_motion.last_changed).total_seconds() > 1*60)
)
}}'
entity_id: sensor.time
while below code is working fine if i put everything into 1 line.
no_one_in_livingroom:
friendly_name: No one in Livingroom
value_template: '{{ (states.sensor.lalit_room_location.state != "livingroom" and states.sensor.jyoti_room_location.state != "livingroom") and ( ( (now()-states.binary_sensor.livingroom_motion.last_changed).total_seconds() > 1*60) and ( (now()-states.binary_sensor.gallery_motion.last_changed).total_seconds() > 1*60) and ( (now()-states.binary_sensor.kitchen_motion.last_changed).total_seconds() > 1*60) ) }}'
# '{{ (states.sensor.lalit_room_location.state != "livingroom" and
# states.sensor.jyoti_room_location.state != "livingroom")
# and (
# ( (now()-states.binary_sensor.livingroom_motion.last_changed).total_seconds() > 1*60) and
# ( (now()-states.binary_sensor.gallery_motion.last_changed).total_seconds() > 1*60) and
# ( (now()-states.binary_sensor.kitchen_motion.last_changed).total_seconds() > 1*60)
# )
# }}'
entity_id: sensor.time
any thoughts why it’s not working in multi-line formatting?