I am having some issues with my lighting automations. I have read of cases of using the service: light.turn_on and the service: homeassistant.turn_on
Which one should I use? I have tried bot and neither work for me.
Here is an example of my automation:
- alias: Turn on Upstairs Hallway lights when there is movement after sunset
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw074_multisensor_gen5_sensor_4_0
to: 'on'
condition:
condition: sun
after: sunset
action:
service: homeassistant.turn_on
entity_id: light.upstairs_passage
- alias: Turn on Upstairs Hallway lights when there is movement before sunrise
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw074_multisensor_gen5_sensor_4_0
to: 'on'
condition:
condition: sun
before: sunrise
action:
service: homeassistant.turn_on
entity_id: light.upstairs_passage
- alias: Turn off Upstairs Hallway lights 10 minutes after last movement
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw074_multisensor_gen5_sensor_4_0
to: 'off'
for:
minutes: 10
action:
service: homeassistant.turn_off
entity_id: light.upstairs_passage
Note that light.upstairs_passage is a hue group. should this make a difference?
I have another automation that I am trying which is also not working with the following code
- alias: Turn on Kitchen lights when there is movement after sunset
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw074_multisensor_gen5_sensor_2_0
to: 'on'
condition:
condition: sun
after: sunset
action:
service: homeassistant.turn_on
entity_id: light.fibaro_system_fgd212_dimmer_2_level_7_0
- alias: Turn on Kitchen lights when there is movement before sunrise
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw074_multisensor_gen5_sensor_2_0
to: 'on'
condition:
condition: sun
before: sunrise
action:
service: homeassistant.turn_on
entity_id: light.fibaro_system_fgd212_dimmer_2_level_7_0
- alias: Turn off Kitchen lights 10 minutes after last movement
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw074_multisensor_gen5_sensor_2_0
to: 'off'
for:
minutes: 10
action:
service: homeassistant.turn_off
entity_id: light.fibaro_system_fgd212_dimmer_2_level_7_0
Light and Switch are two different services and it is important to use the right one. But you may have groups that combine both… so the homeassistant.turn_on/off is the solution as it works for all device types.
I know people who use the homeassistant service only; and some that try to be more specific. I suspect that behind the homeassistant service it figures out the type and uses the right service…
Thanks for the reply. I saw the distinction when calling a group entity comprising many sensors including light as opposed to the light entity directly itself.
I am however calling either the light or hue group of lights in both scenarios and neither homeassistant or light as the command seem to work.
Any ideas around my config where I could be tripping up?