Boolean switch - update status without triggering?

ok, if that’s what you want, it’s fine. I thought you wanted the hobby room_bio be the scene to call when turning on the lights. That’s why I suggested to use 2 automations for turning on /off the lights.

there’s the 3d automation: - alias: ‘[Hobbyroom] Motion/Lux Turn Off Spot’
can you confirm this is working as expected now?

If so, everything is working as expected. So what’s your issue left?

The input_boolean (dummy switch) triggers those two automations:

- 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

And then I have the Motion Sensor automations:

- alias: '[Hobbyroom] Motion/Lux Turn On Spot'
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_1xxxxxxxxxxxxxxx
    from: 'off'
    to: 'on'
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.illumination_1xxxxxxxxxxxxxxx
        below: 70
      - condition: state
        entity_id: input_boolean.disable_motionsensor_hobbyroom_automation
        state: 'off'
  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] Motion/Lux Turn Off Spot'
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_1xxxxxxxxxxxxxxxxxxxxx
    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

…and then of course I have the scenes with the four different light settings.
So the issue is still, how do I easiest toggle the dummy_switch to 'on" when I trigger one of the scenes.

this is no issue at all, and if that is really the only thing you want, simply disable the automation ‘[Hobbyroom] Motion/Lux Turn On Spot’. All automations are visible in the frontend ( if you customize as follows:

homeasisstant:
  customize:
    group.all_automations:
      control: hidden
      hidden: false

, show a toggle, and you can flip that toggle. ( you wouldn’t even need the condition input_boolean in that case, believe I suggested that already before)

If all is well, you could just as easily flip the input_boolean, which is also visible in your frontend? Cant you see it? You should place the input_boolean in a card/group somewhere in your configuration of course.

btw, if you use these 2 automatons for switching on/off the lights, and don’t use the scene for On, you can use my combined automation after all.

- 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

id rename the input_boolean into something positive. That way it is easier to use with conditions (don’t have to remember the negative negation…) and also give it a more meaningful and shorter name. You might want to use it in other scenarios/scenes/scripts later on, input_boolean.hobby_motion_detection might be more suited, or even input_boolean.watch_tv…

if you’d do that, you could change the service_template in:

light.turn_{{'on' if is_state('input_boolean.watch_tv','off') else 'off')}}

but I am wondering why you would turn off the lights when you turn off the input_boolean. This isn’t necessary since the automation would take care of that, when no movement has been registered for 5 minutes…

You are right about that. The thing is that I have tablets in my rooms, and people doesn’t always understand the motion thing and then I want to provide them the possibility to turn the light off when they leave the room.

I think I need to read more up on this. Even though it might be straight forward I seem to run against the wall not getting it.
I’m really sorry, but I’m so grateful that you took the time explaining all this and came with some nice solutions!

well that’s a perfectly valid reason :wink:

you might want to go in the direction of Modes: TV mode, (switch off motion, turn on light, turn on tv etc etc) Study mode (turn on this, turn off that), Home way mode (turn on motion sensor, turn on alarm) etc etc.

Thats what I do and this is the frontend:

55

Just had my dinner :wink:

Before you arrive there, you could for now simply rely on the scenario I described above (turning on /off the automation before and after watching) and trust the system to take care of the rest.

Feel free to come back here if you want further assistance!

So let’s say that I don’t want to use the dummy switch I used and instead wants to do as you say.
Then I have the scenes (Normal (which substitute the one I was trying to use as the input_boolean), PC, Cinema, Turn off (This one could be like your away).
Would it then be possible to do what you described?

Maybe you could have a TeamViewer session with me. I will end up having to use this in many rooms because of my motion sensors.

yes that would be possible.
I have it set up as follows:
Use a main automation that sets the mode/activity based on my input, and sets switches, and selects scripts belonging to that selection (which set motion sensors, lighting levels etc etc, mostly system things). In these scripts, scenes (with lighting settings) are called, per created for each activity.

I’ve built this modularly, so I can always adapt following growing insight or needs, and don’t need to change the main logic of it all.

Hey Marius,

So in order to do and implement like you…
Can you show some exambles of how you enable and disable your Motion Detectors and how you use those lovely icons of yours. Do you use these with scenes or scripts?

i use Hue motion sensors, which I en/disable through api calls. I have set some global values the App, so the sensors act independently from HA also. But, in my scripts and scenes I need to override that (watching TV in the evening while the sensors are normally on and triggering the lights…)

Can you switch the sensors through HA?

this is what Hue uses:

switch:
  - platform: command_line
    switches:
      frontdoor_motion_sensor_switch:
        friendly_name: 'Frontdoor motion sensor switch'
        command_on: >
          curl -X PUT -d '{"on":true}' "http://192.168.1.212/api/key/sensors/5/config/"
        command_off: >
          curl -X PUT -d '{"on":false}' "http://192.168.1.212/api/key/sensors/5/config/"
        command_state: curl http://192.168.1.212/api/key/sensors/5/
        value_template: >
          {{value_json.config.on}}

I then use these in scripts:

  - alias: 'Frontdoor sensor Off when dogs free'
    id: 'Frontdoor sensor Off when dogs free'
    #    initial_state: 'on'
    trigger:
      platform: state
      entity_id: input_boolean.home_mode_dogs_free
    condition:
      condition: template
      value_template: >
          {{ is_state('group.family', 'not_home')}}
    action:
      - service_template: >
          switch.turn_{{'off' if trigger.to_state.state == 'on' else 'on'}}
        entity_id: switch.frontdoor_motion_sensor_switch
      - condition: template
        value_template: >
          {{ is_state('input_boolean.notify_system', 'on')}}
      - service: notify.notify
        data_template:
          message: >
            Frontdoor motion sensor switched {{'off' if trigger.to_state.state == 'on' else 'on'}}, the dogs are free.

To get a bigger picture, I’d advise you to draw your desired schematics first, create some sort of rudimental architecture what you want to do in which situation. Then create that first setup, and build from there.

example, my main setup consists of this input_select:

input_select:
  activity:
    name: Activity selection
    icon: mdi:home
    options:
      - Opstaan
      - Aan de slag
      - Gym
      - Gaming
      - Selamat makan
      - Home theater
      - Naar bed

and corresponding automation:

automation:

  - alias: 'Activity selection'
    id: 'Activity selection'
#    hide_entity: True
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: input_select.activity
    condition:
      condition: template
      value_template: >
        {{ states('input_select.activity') in 
            ['Opstaan','Aan de slag','Home theater',
             'Gym', 'Gaming', 'Selamat makan', 'Naar bed'] }}
    action:
      - service_template: >
          script.{{ trigger.to_state.state | lower | replace(' ','_') }}
      - delay:
          seconds: 2
      - service: mqtt.publish
        data_template:
          topic: 'activity_selection'
          retain: true
          payload: >
            {{ states('input_select.activity') }}
#      - service: python_script.summary

as you can see I have scripts for each of those activities, in which I again call scene for lighting schema’s and subordinate script for system settings like motion sensors etc etc…

I don’t use Lovelace yet, and have heavily invested in Tiles…

this is my Tiles setup for the activities, of which I posted the screenshot in one of the above replies:

homeassistant:
  customize:

    input_text.tiles_activity:
      custom_ui_state_card: state-card-tiles
      config:
        columns: 4
#        column_width: minmax(75px, 75px)
        icon_size: 75px
        entities:
          - entity: script.opstaan_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Opstaan') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/opstaan.png
           # label: Opstaan

          - entity: script.aan_de_slag_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Aan de slag') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/aandeslag.png
           # label: Aan de slag!

          - entity: script.gym_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Gym') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/gym.png
           # label: Gym

          - entity: script.gaming_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Gaming') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/gaming.png
           # label: Gaming

          - entity: script.selamat_makan_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Selamat makan') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/selamatmakan.png
           # label: Selamat makan

          - entity: script.home_theater_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Home theater') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/hometheater.png
           # label: Home theater
            more_info: script.home_theater_direct

          - entity: script.naar_bed_direct
            style_template: >
              if (entities['input_select.activity'].state === 'Naar bed') return 'background-color: #F0C209';
              return 'background-color: #555B65';
            image: /local/activities/naarbed.png
          #  label: Naar bed

Have a look and see if you can reuse things, or have questions.
cheers!

Unfortunately that seems to be my issue with my Xiaomi Motion Sensors, which was why I went down the road with a dummy switch as my kinda substitution for that.
So no, I’m not able to and the Hue motion sensors are just too expensive here where I love :smile:

stop calling it a dummy switch…
if it switches , it isn’t a dummy.
if you can’t switch off the sensor, you can switch off the automation that uses the sensor can you? Thats what we tried before, with succes I believe?

I’'ll try to remember that - it just that its a switch that “I created” to do some stuff for me, that the system didn’t create itself (openHAB terms).

Yes - Motion Sensors has been implemented in rules, so I guess the rules where the Motion Sensors are a part of just need to be switched off…
So what I could do in the hobbyroom was to create 4 scenes, where those scenes disable the motion rules (which will mean the light will stay on).

sure. but replace scene with script. create scripts that disable the motion automation, run their thing, call the lighting scene. think of a good moment to enable the automations again, and see if that can be automated. Probably :wink:

see the main setup I posted above.

it calls this script (among others):

home_theater:
  alias: Home theater
  sequence:
    - service: switch.turn_on
      entity_id:
        - switch.sw_tv_auditorium_cl
        - switch.subwoofer_outlet
    - service: script.scene_home_theater
    - delay:
        seconds: 5
    - service: switch.turn_on
      entity_id: switch.sw_audio_auditorium_cl
    - service: switch.turn_off
      entity_id: switch.sw_audio_gym_cl

which uses this sub script.scene_home_theater:

scene_home_theater:
  alias: Call Home theater scene
  sequence:
    - service: scene.turn_on
      entity_id: scene.home_theater_off
    - service: switch.turn_off
      entity_id:
        - switch.auditorium_motion_sensor_switch
        - switch.dining_table_motion_sensor_switch
    - condition: template
      value_template: >
        {{ is_state('binary_sensor.home_theater_lux_input', 'on')}}
    - service: scene.turn_on
      entity_id: scene.home_theater_on

and the scene:

##########################################################################################
# Scenes Home theater
##########################################################################################

- name: Home theater off
  entities:
    light.buffet: off
    light.dining_table: off
    light.office_inside: off
    light.master_bedroom: off
    group.bureau_lights: off

- name: Home theater on
  entities:
    light.kist:
      state: on
      transition: 4
      brightness: 125
      hs_color: [14,83]
    light.home_theater:
      state: on
      transition: 4
      brightness: 100
      rgb_color: [255,188,85]
    light.office_outside: on
    light.gym_audio:
      state: on
      transition: 4
      brightness: 100
    light.lounge_chair_long:
      state: on
      transition: 4
      brightness: 91
      hs_color: [21,65]

another activity selection, runs the same system, of course with other settings.