Scene.turn_on trigger not triggering

I have a switch in my system that, due to its mechanical features, must toggle it’s state when it receives an on or off from HA. I have a scene defined that turns off all of the lights except this one in that area and I would like to trigger an automation routine to toggle it’s state if it is currently “On” but not if it is off.

I have the following scene defined:
scene.upstairs_off

I have an automation that was built using the HA automation editor that is defined as:

- id: '1556942237223'
  alias: Stairwell Test
  trigger:
  - event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.upstairs_off
    event_type: call_service
    platform: event
  condition:
  - condition: state
    entity_id: switch.upstairs_stairway_lights
    state: 'On'
  action:
  - data:
      entity_id: switch.upstairs_stairway_lights
    service: switch.turn_off 

and I have the card with the scene in it defined as follows:

- entity: scene.upstairs_off
  tap_action:
    action: call-service
    service: scene.turn_on
    service_data:
      entity_id: scene.upstairs_off

The automation will not trigger with these definitions and I could really use some help figuring out why.

Thank you for any advice here!

Please edit your post and format your code correctly.

I tried 4 times to get the code to format correctly. Did it exactly like the GIF shows but no dice.

Try again. There is an alternative method here: How to help us help you - or How to ask a good question

The three tick method worked. Thanks.

Make sure that the automation is on/enabled from the states page. Secondly, does the light turn off if you trigger the automation from the services page? Lastly, the condition state more than likely needs to be lowercase.

- id: '1556942237223'
  alias: Stairwell Test
  trigger:
  - event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.upstairs_off
    event_type: call_service
    platform: event
  condition:
  - condition: state
    entity_id: switch.upstairs_stairway_lights
    state: 'on'               <---- should probably be lowercase
  action:
  - data:
      entity_id: switch.upstairs_stairway_lights
    service: switch.turn_off 
1 Like

Thanks for the reply.

  1. yes, the automation is on,
  2. yes, if I trigger the automation manually, the light changes state
  3. I’ve tried the automation with the condition in lowercase, and mixed case and neither affects the automation. I also removed the condition altogether and there was no change - the automation was not triggered by activating the scene.

If you trigger the scene from the services page, does it do the same?

I did try that too but the outcome was the same.

Try triggering the automation from the dev tools services menu. This overrides the trigger and conditions. That just leaves the actions.

Yep, I don’t think I made that clear. I rested the automation with and without the condition and with the condition variable lower case and mixed case via activating the scene.

I tested the action of the automation with the manual trigger.

Then is your switch entity_id correct?

Can you actually change the switch from the front end UI?

Ok, I’m embarrassed to admit it but this was a very simple and totally stupid mistake on my end. I didn’t reload automations in the general section.

It is working well now. Thank you all for your persistence and valuable tips. It is very much appreciated!

3 Likes