Automation - If Entity Domain is, then

I’m looking to setup a very simple automation like this one:
trigger:
# Multiple entities for which you want to perform the same action.
- platform: state
entity_id:
- light.bedroom_closet
- light.kiddos_closet
- light.linen_closet
to: ‘on’
# Trigger when someone leaves one of those lights on for 10 minutes.
for: ‘00:10:00’
action:
- service: light.turn_off
data_template:
# Turn off whichever entity triggered the automation.
entity_id: “{{ trigger.entity_id }}”

EXCEPT, a few of my entities are switches. So I’d like to adjust the action to include an if statement. Basically, if is light, then light.turn_off, else, switch.turn_off.

I’ve done some searching, but only solution I’ve found is to reconfigure the switches as lights, which I’d rather not do.

Any help is appreciated!!

Just use the homeassistant.turn_off service

jeez… is it really that easy? Sorry for wasting time… I should have thought of that.

Yup (10 characters)

Done and working. Thanks again! I wish there was a way to delete stupid questions!

1 Like