Boolean switch - update status without triggering?

As you can see here - I use my boolean to check whether the light was turned on manually or not:

- alias: '[Hobbyroom] Motion/Lux Turn Off Spot'
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d00012441a4
    from: 'on'
    to: 'off'
    for:
      minutes: 5
  condition:
    condition: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    state: 'off'
  action:
  - service: light.turn_off
    entity_id:
    - light.hobbyroom_led1
    - light.hobbyroom_led2
    - light.hobbyroom_led3
    - light.hobbyroom_led4
    - light.hobbyroom_led5
    - light.hobbyroom_led6
    - light.hobbyroom_led7

So if the input_boolean.disable_motionsensor_hobbyroom_automation is “off” then the lights won’t get turned on.
I was just hoping that I could send some kind of a .pushupdate(on) or so, to my input_booelan, so that the switch would be turned on. but without running the automation.

Can I somehow call that scene instead of a script?

sorry my fault, should have written:

- service: scene.turn_on
  entity_id: scene.hobbyroom_bio

So like this:

#################### Scenes ####################

Hobbyroom

script:
  hobbyroom_bio:
    alias: Hobbyroom Bio
    sequence:
      - service: automation.turn_off
        entity_id: automation.hobbyroom_turn_off_spot
      - delay:
          seconds: 2
      - service: scene.turn_on
        entity_id: scene.hobbyroom_bio
      - delay:
          seconds: 2
      - service: automation.turn_on
        entity_id: automation.hobbyroom_turn_on_spot

I am not sure what you say is what’s happening… what this automation does is trigger when the binary_sensor has been ‘off’ for 5 minutes, and then, checks if the input_boolean in ‘off’ , and if so, switches off these lights.

as long as we don’t know if you’ re input_boolean triggers another automation we can’t really be sure.

if that would not be the case, you could do as I suggested before, while I think that still doesn’t help you. Because it automatically enables the automation again…

maybe you’d be better of with a template switch or an input_boolean you set when watching tv.

and use an extra automation to be triggered by this input_boolean:

Here is what my input_boolean does:

- alias: '[Hobbyroom] Turn on Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    from: 'off'
    to: 'on'
  action:
  - service: light.turn_on
    entity_id:
    - light.hobbyroom_led1
    - light.hobbyroom_led2
    - light.hobbyroom_led3
    - light.hobbyroom_led4
    - light.hobbyroom_led5
    - light.hobbyroom_led6
    - light.hobbyroom_led7
    
- alias: '[Hobbyroom] Turn off Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    from: 'on'
    to: 'off'
  action:
  - service: light.turn_off
    entity_id:
    - light.hobbyroom_led1
    - light.hobbyroom_led2
    - light.hobbyroom_led3
    - light.hobbyroom_led4
    - light.hobbyroom_led5
    - light.hobbyroom_led6
    - light.hobbyroom_led7

So if I turn on the input_boolean.disable_motionsensor_hobbyroom_automation, then my light will turn on, and of course the other way around if switched off.
So if I am sitting in my chair and someone comes into the room and triggers the Motion Sensor and leaves again, then after 5 minutes, the light will be swithed off. So that is why I created the input_boolean to prevent that.

cool.

can be 1 automation btw:

- alias: '[Hobbyroom] Turn on Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
  action:
  - service_template: > 
      light.turn_{{states('input_boolean.disable_motionsensor_hobbyroom_automation')}}
    entity_id:
      - light.hobbyroom_led1
      - light.hobbyroom_led2
      - light.hobbyroom_led3
      - light.hobbyroom_led4
      - light.hobbyroom_led5
      - light.hobbyroom_led6
      - light.hobbyroom_led7

might consider creating a group with these lights, and then turn_on/off the group.

Nice (as stated earlier I’m not that skilled here yet) but thanks for sticking and helping)!
So basically I can remove the two automations and just have this one:

- alias: '[Hobbyroom] Turn on_off Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
  action:
  - service_template: light.turn_{{states('input_boolean.disable_motionsensor_hobbyroom_automation')}}
    entity_id:
      - light.hobbyroom_led1
      - light.hobbyroom_led2
      - light.hobbyroom_led3
      - light.hobbyroom_led4
      - light.hobbyroom_led5
      - light.hobbyroom_led6
      - light.hobbyroom_led7

did a small typo correction, but yes you could. You’d want to disable this in case of watching tv. Easiest to do that is create an extra input_boolean.watching tv, and have this automation use that as a condition:

  - alias: '[Hobbyroom] Turn on Spot'
    trigger:
      platform: state
      entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    condition:      
      condition: template
      value_template: >
        {{is_state('input_boolean.watching_tv','off')}}  
    action:
      service_template: > 
        light.turn_{{states('input_boolean.disable_motionsensor_hobbyroom_automation')}}
      entity_id:
        - light.hobbyroom_led1
        - light.hobbyroom_led2
        - light.hobbyroom_led3
        - light.hobbyroom_led4
        - light.hobbyroom_led5
        - light.hobbyroom_led6
        - light.hobbyroom_led7

still this doesn’t help for you automatic trigger on the binary sensor:

trigger:
platform: state
entity_id: binary_sensor.motion_sensor_158d00012441a4
from: ‘on’
to: ‘off’
for:
minutes: 5

will be away for a short moment, and back in an hour or so… :wink:

I’m sorry - you lost me there.
I don’t understand why I should use any conditions on the switch (input_boolean).

The Input_boolean should be used for two things:

  1. Turn the light in the Hobbyroom on and off - no matter what
  2. Used to prevent the Motion Trigger to turn off the light (which works now as we speak in the condition block)

My Scene file:
Creates the desirec light scene, but I can’t set the input_bolean, so that means the light will change as soon as the Motion gets triggered.

Scripts file:
Either this should call the scene file and run the scene, while it first turns off the automation (input_boolean) and then when the scene is set, using delay to wait 2 seconds, turn back on the (input_boolean) automation.

you’re right, you shouldn’t, my bad.

so you have several options:

  • You could use the condition in the automation to prevent it from kicking in and turning off the lights when watching tv.

as you already did (check the indenting errors I corrected and the condition, I always like to use template conditions because you can check these in the dev-template page. also took out the from:. Since it is a boolean, only the to: suffices):

- alias: '[Hobbyroom] Motion/Lux Turn Off Spot'
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d00012441a4
    to: 'off'
    for:
      minutes: 5
  condition:
    condition: template
    value_template: >
      {{is_state('input_boolean.disable_motionsensor_hobbyroom_automation','off')}} #my input_boolean.watching_tv
  action:
    service: light.turn_off
    entity_id:
      - light.hobbyroom_led1
      - light.hobbyroom_led2
      - light.hobbyroom_led3
      - light.hobbyroom_led4
      - light.hobbyroom_led5
      - light.hobbyroom_led6
      - light.hobbyroom_led7
  • You could also use the automation toggle in the frontend for that btw. If there’s nothing else you’d want to set in ‘tv-mode’ , and only want to disable the automatic lights after the binary_sensor, simply use the automation, and run the script/scene.

If you’d like to add other scripts, automatons or whatever, use the input_boolean as trigger for an extra automation, or even use a template switch, and have separate on/off sequences.

You would have to test things, especially using the same input_boolean for both automations… It might prove to be wise to add an extra delay in the Turn on spot automation, and have it wait for the input_boolean to have disabled the other automation. Give it 5 seconds.

So I changed the code as written a bit above, where the input_boolean can turn the light on and off without using the 2 automations.

- alias: '[Hobbyroom] Turn on_off Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
  action:
  - service_template: light.turn_{{states('input_boolean.disable_motionsensor_hobbyroom_automation')}}
    entity_id:
    - light.hobbyroom_led1
    - light.hobbyroom_led2
    - light.hobbyroom_led3
    - light.hobbyroom_led4
    - light.hobbyroom_led5
    - light.hobbyroom_led6
    - light.hobbyroom_led7

This works and the light turns on and off as they should.

I then went back to scene file and edited it, so that it firs turns the light on and then the other ones off (the grouping you talked about).

- name: Hobbyroom Bio
  entities:
    input_boolean.disable_motionsensor_hobbyroom_automation:
      state: on
    light.hobbyroom_led1:
      state: on
      transition: 15
      brightness_pct: 15
      kelvin: 2200
    light.hobbyroom_led2:
      state: on
      transition: 15
      brightness_pct: 5
      kelvin: 2200
    light.hobbyroom_led5:
      state: on
      transition: 15
      brightness_pct: 5
      kelvin: 2200
    light.hobbyroom_led6:
      state: on
      transition: 15
      brightness_pct: 15
      kelvin: 2200
    light.hobbyroom_led3:
      state: off
    light.hobbyroom_led4:
      state: off
    light.hobbyroom_led7:
      state: off

Finally I tried editing the script file as we first talked about.
But no matter what I do, it just don’t want to validate the file. I read through different threads were people seem to get it working, but I just can’t :sweat:… Keep in mind that this code is in the scripts.yaml file…

Hobbyroom_bio_scene:
  alias: Hobbyroom Bio Scene
  sequence:
  - service: automation.turn_off
      entity_id: automation.hobbyroom_turn_on_off_spot
  - delay:
      seconds: 2
  - service: scene.turn_on
      entity_id: scene.hobbyroom_bio
  - delay:
      seconds: 2
  - service: automation.turn_on
      entity_id: automation.hobbyroom_turn_on_off_spot

So first it disables the automation which triggers the light to turn on, then it runs the scene from the scens file where, as you can see, I’ve added the line withh the boolean switch and set its state to on…
Finally it enables the automation again.

But it just keeps error-ing me :rage:

this is not correct, the input_boolean shouldn’t be in the script at all.

- name: Hobbyroom Bio
  entities:
    input_boolean.disable_motionsensor_hobbyroom_automation:
      state: on

If you want to use the scene (and of course you do given the dedicated settings per light,) you might be better of using the 2 separate automatons for on and off again…

- alias: '[Hobbyroom] Turn on Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    to: 'on'
  action:
    - service: scene.turn_on
      entity_id: scene.hobbyroom_bio

- alias: '[Hobbyroom] Turn off Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    to: 'off'
  action:
    - service: light.turn_off
      entity_id:
        - light.hobbyroom_led1
        - light.hobbyroom_led2
        - light.hobbyroom_led3
        - light.hobbyroom_led4
        - light.hobbyroom_led5
        - light.hobbyroom_led6
        - light.hobbyroom_led7

summarizing:
you have an automation that’s sets the lights following the binary_sensor. Conditioned you don’t watch tv.
If you do watch tv, flip the automation off (or the dedicated input_boolean) and turn on/off the lights manually. Until you re-enable the automation/toggle the input_boolean again… Simple :wink:

you shouldn’t use Hobbyroom_bio_scene, unless you’d have a wait_template inserted at the end, before the automation is reenabled. Have it wait for the input_boolean to be ‘off’ again. Otherwise it simply would start killing your lights again after 5 minutes of no movement.

  - wait_template: >
      {{ is_state('input_boolean.disable_motionsensor_hobbyroom_automation,'off')}}

No I guess not - I just wished it was that simple :slight_smile:.
It doesn’t fail when I run the scene, but I can also see that the switch doesn’t set the state to ‘on’.

The thing is, if I do this manually it works.
If I open the lovelace - turns off the automation for the input_boolean, then go to my scene selection and runs the scene selection, the light changes.
Then I turn on the input_boolean and finally I enable the automation again.
Success… and the light stay on even though the motion sensor gets triggered.

which switch? You havent given us the code for a switch? Or do you mean the frontend representation of the input_boolean?

this in fact is not correct then, since if you enable the automation, the lights would have to go off again… at least, that’s what you instruct it to do.

Yes exactly. I was advised to use a input_boolean as a “Dummy Switch”.

Hmm… well that’s at least was happen (using the code you provided earlier instead of having two automations - one for turning it off and one for turning it on)?
If i press my input_boolean which is representated as a switch “Dummy Switch” the light turns on (switch turns on) and if I press it again, the lights turn off (switch turns off)

- alias: '[Hobbyroom] Turn on_off Spot'
  trigger:
    platform: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
  action:
  - service_template: light.turn_{{states('input_boolean.disable_motionsensor_hobbyroom_automation')}}
    entity_id:
    - light.hobbyroom_led1
    - light.hobbyroom_led2
    - light.hobbyroom_led3
    - light.hobbyroom_led4
    - light.hobbyroom_led5
    - light.hobbyroom_led6
    - light.hobbyroom_led7

The input_boolean (Dummy Switch) marked with red:
image

sure, that’s correct. As I stated above, you don’t have the scene settings when turning ‘on’ now, so you might want to go back to the 2 automations I re-edited for you above.

If all is correct then this input_boolean would be used as a trigger for the on/off switching of the lights, and as a condition in the automation that uses the binary_sensor to kill the lights after 5 minutes.

hobbyroom_lys is not in the automation, so won’t be set. That too is to be expected…

Okay I will convert back then, but I still don’t know how I should proceed.
I think I will have to give up on this one - I just can’t see the logic.

So maybe for now I will just have to turn on that Dummy Switch (input_boolean) and then afterwards I can chose the scene I want.

Not really sure what’s confusing you now so let me try to re-iterate:

you have an automation that triggers on the binary_sensor, and has a condition not to do anything if you are watching tv (the input_boolean being on).

also, you have 2 automations that trigger on the same input_boolean. On means turn on the scene, off means turn off the lights.

that is all, and should do exactly what you want.

If not, please let me know what doesn’t work. (and best use the correct entities and their names, to stop the confusion growing. (eg dummy switch isn’t an entity, an input_boolean is)

I have 2 automations, one that just turn on my light and one that turns off my light (the input_boolean “dummy switch”).
When I turn this one on, I don’t call or set any scenes, it simply just turns on the light, and I think it just turns it on at the previously known state.

If I then want the light to be set with different brightness and color, then I press one of my scenes:

  • White
  • Warm
  • PC
  • Bio

But the above just changes the light to the desired settings, and doesn’t keep the motion trigger to turn off my light, because the condition as stated here looks for the input_boolean, whether it is ‘on’ or ‘off’'. If ‘on’ then it doesn’t turn off the lights after the 5 minutes.

  - condition: state
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
    state: 'off'