Boolean switch - update status without triggering?

Hi all,

I have this switch I’m using to turn on several lights, but I also use the boolean to prevent my motion sensors to trigger the light and then turn it off.
My only problem is, if I want to set a scene, then I want the light to be kept on as if I was pushing my boolean switch. But when I set the scene the button starts to turn on all light and the scene doesn’t reflect was I have set.

My question is, is there some sort of update instead of set (sorry coming from openHAB), so I’m not that skilled in Hassio yet :smile:

You could turn off the automation associated with the input_boolean before setting the scene.

    - service: automation.turn_off
      entity_id: ...

You should be able to re-enable the automation after setting the scene without triggering it.

1 Like

So would I do that in my scene or?

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

Not in your scene, before calling your scene. What triggers the scene?

Just a scene button in my lovelace file?

  • scene.hobbyroom_bio that entity gets created when I create my scene and that’s about it?
    image

You will need to convert it to a script then. Add the automation disable as the first service call. Use service calls to set your lights how you want them, then re-enable the automation.

OH okay…
Sounds like something that is a bit over my league for now :blush:.

But thanks for your response!

It’s pretty simple. Scripts are similar to scenes but you can do more than turn on lights.

So to set your first two lights:

script:
  hobbyroom_bio:
  alias: Hobbyroom Bio
    sequence:
      - service: automation.turn_off
        entity_id: ...   #disable your input_boolean automation here
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led1
          transition: 15
          brightness_pct: 30
          kelvin: 2200
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led2
          transition: 15
          brightness_pct: 15
          kelvin: 2200
      - service: light.turn_on
        data: 
        ...etc
      - service: automation.turn_on
        entity_id: ...   # re-enable your input_boolean automation here

Wow - thanks man…

EDIT: Tried it and added the rest, but it fails when I validate:

Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/scripts.yaml”, line 4, column 13

script:
  hobbyroom_bio:
  alias: Hobbyroom Bio Scene
    sequence:
      - service: automation.turn_off
        entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led1
          transition: 15
          brightness_pct: 30
          kelvin: 2200
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led2
          transition: 15
          brightness_pct: 15
          kelvin: 2200
      - service: light.turn_off
        data:
          entity_id: light.hobbyroom_led3
      - service: light.turn_off
        data:
          entity_id: light.hobbyroom_led4
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led5
          transition: 15
          brightness_pct: 15
          kelvin: 2200
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led6
          transition: 15
          brightness_pct: 30
          kelvin: 2200
      - service: light.turn_off
        data:
          entity_id: light.hobbyroom_led7
      - service: automation.turn_on
        entity_id: input_boolean.disable_motionsensor_hobbyroom_automation

This:

Usually means the indentation is not right at the line specified.

My mistake. Alias should be indented like so:

script:
  hobbyroom_bio:
    alias: Hobbyroom Bio
    sequence:
      - service: automation.turn_off
        entity_id: ...   #disable your input_boolean automation here
      - service: light.turn_on
        data:

Yes exactly… I found that as well just a wink after you replied in the documentation.
… but still issues. No it doesn’t want to accept the

hobbyroom_bio:

Invalid config for [script]: [hobbyroom_bio] is an invalid option for [script]. Check: script->script->script->hobbyroom_bio. (See /config/configuration.yaml, line 18). Please check the docs at Scripts - Home Assistant

I simply can’t see the issue when going through the documentation :disappointed_relieved:

might be this:

since you switch off lights in the 4th, 5th and 8th service without further data (like delay or transition) you should leave out the data: and simply state:

- service: light.turn_off
  entity_id: light.hobbyroom_led3
- service: light.turn_off
  entity_id: light.hobbyroom_led4

or shorter:

- service: light.turn_off
  entity_id:
    - light.hobbyroom_led3
    - light.hobbyroom_led4
    - light.hobbyroom_led7

also, you have this:

 - service: automation.turn_off
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation

and at the bottom:

 - service: automation.turn_off
    entity_id: input_boolean.disable_motionsensor_hobbyroom_automation

which should be:

 - service: input_boolean.turn_on
   entity_id: input_boolean.disable_motionsensor_hobbyroom_automation

always easy and probably better to debug, if you order/group all services per setting. Unless of course you specifically want the order in your script above, you could order like this: first the Off switches, have a small delay, then the On switches, delay, turn on automation.

format the delay like this:

- delay:
    seconds: 2

there have been issue reports using the delay: '00:00:02' format

Actually he needs to put the automation that the input_boolean triggers in those spots. We want to disable the automation from switching the input boolean, not switch the input_boolean.

Ok , had not seen an automation in the examples yet, so yes, if that’s what’s desired it should be

- service: automation.turn_off
  entity_id: automation.correct_name_here (check dev <> ) to be sure

maybe there is not automation? Booleans don’t necessarily need an automation…

1 Like

So do you both agree, that this looks better with the correct “order” and the right services (and without the data):

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

Hobbyroom

script:
  hobbyroom_bio:
    alias: Hobbyroom Bio
    sequence:
      - service: automation.turn_off
        entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led1
          transition: 15
          brightness_pct: 30
          kelvin: 2200
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led2
          transition: 15
          brightness_pct: 15
          kelvin: 2200
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led6
          transition: 15
          brightness_pct: 30
          kelvin: 2200
      - service: light.turn_on
        data:
          entity_id: light.hobbyroom_led5
          transition: 15
          brightness_pct: 15
          kelvin: 2200
      - delay:
        seconds: 2
      - service: light.turn_off
          entity_id: 
            - light.hobbyroom_led3
            - light.hobbyroom_led4
            - light.hobbyroom_led7
            - light.hobbyroom_led7
      - service: automation.turn_on
        entity_id: input_boolean.disable_motionsensor_hobbyroom_automation

No.

This bit (and the off section as well) is not right.

      - service: automation.turn_off
        entity_id: input_boolean.disable_motionsensor_hobbyroom_automation  ### <- needs to be an automation

You need to specify the automation triggered by your input boolean. Not the input boolean itself.

not really…
your first and last services are incorrect:
you are not setting an automation as entity_id, but an input_boolean. that won’t work.

btw, why do you convert the scene to a script? That is not necessary at all, simply call the scene you had before in the script wold work just fine?

sorry but must confess I didn’t read the full topic yet, and now that I did, I don’t fully understand what you’re trying to accomplish

what do you want to update here?

So here is the deal:

I have a Xiaomi Sensor in the Hobbyroom that triggers the light to turn on and after 5 minutes if no activity the light will turn off (2 automations).
The problem is, if I sit in my chair and watches a movie, I don’t move that much, which will trigger the light to turn off. So I have created a boolean that turns on the light and provides a boolean I can use in my conditions so if the Motion Sensor does not see any movement even though it got triggered earlier, then the light wont turn off.

So I was thinking, since I have created those Scenes in my scenes.yaml file, that if I press a scene without turning the light on by pushing the boolean switch, then the light should stay on by updating my boolean.

Does that make sense?

So let’s say I keep the scene in my scenes file. Then I could create this script that updates my automation to “off” then calls the scene.hobbyroom_bio and then finally turns on the automation again - wihtout running the actual automation script. Becuase if I trigger the automation of my boolean, then it will turn on all the light again.

if that is the case, you might want to add a condition to your automations not to trigger in condition of watching tv?

yes that is very well possible:

- service: automation.turn_off
  entity_id: automation. correctnamehere
- delay:
    seconds: 2
- service: script.watchtelevision #scripts can be called directly
- delay:
    seconds: 2
- service: automation.turn_on
  entity_id: automation. correctnamehere