If scene is activated, then turn off a switch

I am struggling to get this simple task to work: Turn off a switch if a scene is activated.

What I did so far:
I made a switch for the Circadian Lighting component, which is working:

switch.circadian_lighting_bathroom_circadian_lighting

I have a scene which changes the color of my bathroom lights

scene.bathroom_relax

If the Arcadian Light switch is on, I cannot change the color using my scene – obviously. Now I created an automation, which checks if my scene is turned on and turns the switch off. But it is not working and I don’t know what I am doing wrong. Please help me.

Here is my code. I found this trigger part on this forum.

alias: "Activate Scene - Bathroom Relax"
trigger:
  - platform: event
    event_type: call_service
    event_data:
      service_data:
        entity_id: [scene.bathroom_relax]
      domain: scene
      service: turn_on
action:
  - service: switch.turn_off
    entity_id: switch.circadian_lighting_bathroom_circadian_lighting

EDIT:
I guess I need to re-activate the scene after the switch is turned off, because the active Arcadian Lighting won’t allow a change in color.

  1. Scene “bathroom relax” is activated
  2. Arcadian Lighting switch turns off
  3. Scene “bathroom relax” activates

Why don’t you program the switches in your scenes instead of automations? For example click the link below.

I think it is even possible to activate another scene within a scene but I will have to test this first to be sure.

1 Like

I forgot to mention, that I am using the deCONZ-component for my lights. I created scenes using the Phoscon-Web-UI. So the scene.bathroom_relax shows up in HA, but I don’t have a config file for it.

Ah ok, that complicates things. Well the thing with scenes is (at least in my case) that the state is always set to “scening”. This means that you can’t set a trigger to it as the state never changes. I don’t know if this is true for your particular scene, but with HA scenes (the standard ones) this is not possible as far as I know. I could be terribly wrong though.

What you could do is the following. Create 2 groups (1 group with all the devices in your scene that should be ‘on’ and 1 group for all devices that should be ‘off’) you can then set conditions in your automations that when both those groups meet the requirement that it will trigger an automation. I have been experimenting with this so I could have Homekit like scening and it works pretty well.
You will need to create input booleans as well if you want the states to be shown.

Examples here:
Automations: https://github.com/jimz011/homeassistant/blob/c2e0770994b6541e882deaf6d914cbed20f922dc/configuration/automations.yaml#L2432

Groups: https://github.com/jimz011/homeassistant/blob/c2e0770994b6541e882deaf6d914cbed20f922dc/configuration/groups.yaml#L91

Input_booleans: https://github.com/jimz011/homeassistant/blob/c2e0770994b6541e882deaf6d914cbed20f922dc/configuration/input_boolean.yaml#L15

Video of how my scenes look like, also any automation can be programmed to these buttons.

Yeah, my scenes are always in state “scening”.

I just had a quick look at your examples, but I think I need more time to figure out how I can do this.
Maybe on the weekend…

Thanks for your help so far.

hey there,

any news on here? have you been able to fix it / find a work around?

i got the same problem… i am running two busch jäger battery powered wall switches (2 channel) and i want to trigger lights with them… setup is:

busch jäger -> conbee 2 -> deconz -> home assistant (hass.io on rpi3b)

thanks in advance,
andreas

I got a working setup now.

My physical setup:

Busch Jäger battery powered wall switch -> Conbee 2 -> DeConz (Phoscon) -> Home Assistant

The switches are always in the “scening mode”. So i was not able to toggle a light or somethin else.

My solution:

Home Assistant listens for events. Whe the switch is triggered HASS triggers an automation (which that toggles the light.

Way to get to the event:

Developer tools -> Event listener -> listen for “deconz_event” -> find out the device id and the event number… something like this:

  event: 1002
  id: wandsender_eg

Then i created an automation with the following trigger:

event_data:
  event: 1002
  id: wandsender_eg
event_type: deconz_event
platform: event

… which toggles the light…

Maybe it helps somebody :slight_smile:

Best regards,
Andreas

this might be of use:

- id: '1582139333432'
  alias: scene sync
  initial_state: 'on'
  trigger:
    platform: event
    event_type: call_service
    event_data:
      domain: scene
      service: turn_on
  action:
  - data_template:
      message: 'SceneSync: {{ trigger.event.data.service_data.entity_id }}'
    service: persistent_notification.create
1 Like