Question about light off automations and scenes

Im making my way through all of the lighting automations in my home, and trying to make it modular as possible so I can add to it later. Right now the idea is to have an Input_Select for each room, which controls the rooms mode (Automatic, Morning, Away, Sleep, Party, Vacation, and Manual). The house itself has another Input_select with most of the same values, that when changed automatically moves the other rooms into the corresponding mode.

For motion lighting, I am running a simple automation to turn a group of lights/switches on. No scene activation included.

alias: Motion Livingroom Lights
trigger:
  platform: state
  entity_id: binary_sensor.lr_motion_sensor
  to: 'on'
action:
  service: homeassistant.turn_on
  entity_id: group.all_living_room_lights

To turn them off I have two automations. The only difference is the timer, which is linked to the mode.

alias: Kitchen Lights Off 5
trigger:
  - platform: state
    entity_id: binary_sensor.kitchen_motion_sensor
    to: 'off'
    for:
      minutes: 5
condition:
  condition: or
  conditions:
    - condition: state
      entity_id: 'input_select.kitchen_override'
      state: 'Automatic'
    - condition: state
      entity_id: 'input_select.kitchen_override'
      state: 'Morning'
    - condition: state
      entity_id: 'input_select.kitchen_override'
      state: 'Manual'
action:
  - service: homeassistant.turn_off
    entity_id: group.kitchen_lights

alias: Kitchen Lights Off 2
trigger:
  - platform: state
    entity_id: binary_sensor.kitchen_motion_sensor
    to: 'off'
    for:
      minutes: 2
condition:
  condition: or
  conditions:
    - condition: state
      entity_id: 'input_select.kitchen_override'
      state: 'Sleep'
    - condition: state
      entity_id: 'input_select.kitchen_override'
      state: 'Away'
    - condition: state
      entity_id: 'input_select.kitchen_override'
      state: 'Movie'
action:
  - service: homeassistant.turn_off
    entity_id: group.kitchen_lights

I will be using another set of automations that change the scene depending on the mode selected for the room in the Input_Select. Here is where I run into the issue.

As far as I know scenes can not be activated while keeping the lights off, IE the scene itself turns the lights on.
Likewise the automation to turn the light off is triggered by the motion sensor moving INTO the off state.
So if I have automations setup that change the scene in the house based on other triggers, there is a good chance that it will turn the lights ON in a room where there is no motion. Since the turn off automation is based on the state of the motion sensor turning OFF, that means the lights are going to stay on until someone trips the motion sensor and then allows it to move into the OFF state.

From what I understand LIFX allows for scenes to be sent to the bulbs even if they are in the off state (not working for me yet), but that would only account for my living room. Every other room in the house is a mix of GE Switches, Cree bulbs and Lightify Color bulbs.

Does anyone have any suggestions? Either a different way to write the “Turn Off” automation, or something I dont understand about Scenes?

Ok, I think i follow you. Your issue is that when you change the input_select, it activates a new scene which turns on the scene?

You could make a switch template that is used for your room lights instead of using the input select. Then monitor the switch template for on/off, when that occurs, check the condition and fire the scene. So your input_select wouldn’t fire the scene, the on/off of the switch would. If you want to fire a scene, you’d have to have a script that swaps the input_select and then turn on the switch.

If i followed your question wrong, let me know. I don’t have the best reading comprehension.

Also as an aside, your condition you posted up there is long winded. If you want to shorten your code with the same result, this would work:

condition:
  condition: template
  value_template: "{{ states('input_select.kitchen_override') in ['Sleep', 'Away', 'Movie'] }}"

Then you could use 1 automation to cover all rooms:

condition:
  condition: template
  value_template:>
    {% if 'kitchen' in trigger.entity_id %}
      {% set dropdown = 'input_select.kitchen_override' %}
    {% elif 'some other room' in trigger.entity_id %}
      {% set dropdown = 'input_select.some_other_room' %}
    {% else %}
      {% set dropdown = 'input_select.dummy' %}
    {% endif %}
    {{ states(dropdown) in ['Sleep', 'Away', 'Movie'] }}

You’d just need to make a fake unused input_boolean.dummy incase HA screws up and you have a bad trigger.

Hey Petro,

Thanks for the suggestion on shortening. Running everything from one automation obviously seems better.

I am trying to accomplish a few things with this setup, and avoid a few problems I had in my old setup in Smartthings.

Here is an example of what I want to avoid. Lets say I have a script to dim the lights for a movie based on the media player state. That might be what I want 90% of the time, but there is a 10% chance I might be eating dinner on a TV tray or working on some project and do not want it to be that dark. I wanted to come up with a simple way to override the the scenes I have automate.

I also wanted to create a way to setup sleep mode in my 3br house. I have GE Dimmers in each bedroom that are capable of double tap. A double tap down would put the bedroom itself into sleep mode. If all 3 bedrooms are in sleep mode, the house goes to sleep mode. This is tied to another set of conditions to checks to see if guest mode is on for the 3rd (guest bedroom) so only two rooms need to go to sleep. Or location checks for me and my roommate, to check to see if only one room needs to go into sleep for the whole house to sleep.

I was planning on setting up the Automatic mode to be a shifting light warmth/brightness based on the time of the day. This is where I started realizing that scenes alone were going to be an issue.

Down the road, I am hoping to add my Google Homes into the mix for things like Morning mode.
Id like to have a motion trigger setup in the bedrooms for a specific time frame, and if the room is currently in sleep. This would trigger my google home to state the time, and then ASK if Im ready to get up. If yes, that bedroom would go into Morning Mode along with the other rooms in the house, minus the other two bedrooms.

The biggest thing for me, is that I want this to be as easy as possible for my roommate and guests, who may or may not be technically inclined. Second, to have this be as modular as possible, so I can add new modes should I need to down the road with as little work on the back end as possible.

Ive just started the build out and basically just have simple motion automations setup for right now.
If you think you have a simpler method to accomplish this stuff, Im all ears.

How do you currently trigger your scenes?

Via an automation that watches the state of the Input_select.
At present the two I have setup (Automatic and Sleep) are just triggering the scene.
I had planned to point it to a script, which would include the action of triggering the scene, as well as other things should I choose it.

alias: Override Master Bedroom Scene
trigger:
  platform: state
  entity_id: input_select.master_bedroom_override
action:
  service: homeassistant.turn_on
  data_template:
    entity_id: >
      {% if is_state("input_select.master_bedroom_override", "Automatic") %}
        scene.master_bedroom_automatic
      {% elif is_state("input_select.master_bedroom_override", "Morning") %}
        script.mbr_morning
      {%-elif is_state("input_select.master_bedroom_override", "Party") %}
        script.mbr_party
      {%-elif is_state("input_select.master_bedroom_override", "Sleep") %}
        scene.master_bedroom_sleep
      {%-elif is_state("input_select.master_bedroom_override", "Away") %}
        script.mbr_away
      {%-elif is_state("input_select.master_bedroom_override", "Movie") %}
        script.mbr_movie
      {%-elif is_state("input_select.master_bedroom_override", "Vacation") %}
        script.mbr_vacation
      {%-elif is_state("input_select.master_bedroom_override", "Manual") %}
        script.mbr_manual
      {% else %}
        none
      {% endif %}

Maybe you should build a template sensor that intelligently chooses a room state based on the two input_selects. Then build your automation off that sensor changing. That way all your logic for overriding an input with the other input would be in one place and ‘easy’ to follow.