Set scene without changing state of lights

Hi there!

I can’t seem to setup a scene that only changes the brightness and NOT the state.
The lights can change state depending on other conditions, but I want the brightness to change universally when its night/day
i.e.

scene:
  - name: Night
    entities:
      light.hallway:
        brightness: 150
  - name: Day
    entities:
      light.hallway:
        brightness: 250

when I activate the scene as per:

  - alias: "It's Night Time"
    trigger:
      platform: state
      entity_id: sun.sun
      state: "below_horizon"
    action:
      service: scene.turn_on
      entity_id: scene.night
  - alias: "It's Daytime"
    trigger:
      platform: state
      entity_id: sun.sun
      state: "above_horizon"
    action:
      service: scene.turn_on
      entity_id: scene.day

i get the following error:
16-05-07 19:54:30 homeassistant.helpers.state: reproduce_state: Unable to reproduce state <state light.hallway=None; brightness=150 @ 2016-05-07T19:54:25.032289+10:00>

Which makes sense as the hallway light has no ‘state’ just = None.
Any way to set the brightness of a light without changing its state?

Brightness can only be changed in Home Assistant via the turn on service. So your state needs to be on for brightness to be set.

Kinda lights you working with anyway?

I have scenes that do just that what you are trying to accomplish. Like Paul us states you have to work with a light which has state “on” cause you are going to set brightness with an “update” on that state.

My hallway light fi reduces brightness to 25% at 22:30hrs so no one has to look for the lights at night when they need to take a leak or have the munchies.

@dennisaion LimitlessLED globes

The use-case is -
Motion sensors / Dash Buttons around the house which turn lights on and off, but depending on the time of day, the brightness will be different.
The lights aren’t necessarily ‘on’ when the sun sets or rises.
I guess I could do it with two separate automation triggers for every action, one for day and one for night, but that doesn’t seem like the ‘right way’.
I couldn’t work out how to use a variable for brightness i.e.

entity_id: lights.hallway
data:
  brightness: someVariable?

any thoughts?

@perrin7

I also have MiLight/LimitlessLed. I have it set like this.


#################################################################
## Control lights
#################################################################
light:
  platform: limitlessled
  bridges:
    - host: 192.168.0.111
      port: 8899
      version: 5
      groups:
      - number: 1
        type: rgbw
        name: Office
      - number: 2
        type: rgbw
        name: Hallway
      - number: 3
        type: rgbw
        name: Dining
      - number: 4
        type: rgbw
        name: Kids Bedroom
    - host: 192.168.0.111
      port: 8899
      version: 5
      groups:
      - number: 1
        type: white
        name: Frontdoor
      - number: 2
        type: white
        name: Livingroom
      - number: 3
        type: white
        name: Floor light
      - number: 4
        type: white
        name: Bed Light

#################################################################
## Groups
#################################################################
group:
  Lights:
   - light.frontdoor
   - light.livingroom


You can do the following


#################################################################
## Automations lights
#################################################################
automation:
- alias: 'Turn down hallway light to 25 percent'
  trigger:
    platform: time
    after: "22:30:00"
  action:
    service: light.turn_on
    entity_id: light.hallway
    data:
      brightness: 25


Now here is what you should be interested in. Check the trigger, condition and the scene it calls.
Each time my living light is turned on between 6pm and 12 it will turn om with a brightness of 100 (little under 50%)
You can try yourself. Make two scenes with two different timeframes and brightness settings and your good to go.


#################################################################
## Automations Livingroom
#################################################################
- alias: "Livingroom"
  trigger:
    platform: state
    entity_id: light.livingroom
    from: 'off'
  condition:
    platform: time
    after: '18:00:00'
    before: '23:59:00'
  action:
    service: scene.turn_on
    entity_id: scene.livingroom

#################################################################
## Automations Frontdoor
#################################################################
- alias: "Frontdoor"
  trigger:
    platform: state
    entity_id: light.frontdoor
    from: 'off'
  condition:
    platform: state
    entity_id: sun.sun
    state: 'below_horizon'
  action:
    service: scene.turn_on
    entity_id: scene.frontdoor

#################################################################
## Scenes
#################################################################
  - name: Frontdoor
    entities:
      light.frontdoor:
        state: on
        color_temp: 300
  - name: Livingroom
    entities:
      light.livingroom:
        state: on
        color_temp: 444
	brightness: 100

1 Like

You can use templates for data and service attributes:

entity_id: lights.hallway
data_template:
  brightness: {% if now.hour > 20 %}25{% else %}75{% endif %}

Awesome. So it’ll look like this?


#################################################################
## Automations lights
#################################################################
automation:
- alias: 'Turn down hallway light to 25 percent'
  trigger:
    platform: time
    after: "22:30:00"
  action:
    service: light.turn_on
    entity_id: lights.hallway
    data_template:
      brightness: {% if now.hour > 20 %}25{% else %}75{% endif %}