Possible to set the brightness of a light without turning it on?

I have a light dimmer on an esphome, I have the http_request and web server hoping I could send a request to set the brightness without turning it on. But it does not seem to be exposed for doing this.

Reason I want this is at night I was the bathroom lights to only turn on to a very dim setting.

Probably better to have the brightness set at turn on with a time check. I do this with a porch light. Here is the HA automation.You could probably adapt bits of this and run it on the ESP.

alias: Night - Porch Light Auto
description: ""
trigger:
  - platform: sun
    event: sunset
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_d8e3be07_ias_zone
  - platform: time
    at: "00:00"
condition: []
action:
  - choose:
      - conditions:
          - condition: sun
            after: sunset
          - condition: time
            before: "00:00"
        sequence:
          - choose:
              - conditions:
                  - type: is_no_motion
                    condition: device
                    device_id: 8e8d3133a93cc1ba43ad6fbceab31619
                    entity_id: >-
                      binary_sensor.lumi_lumi_sensor_motion_aq2_d8e3be07_ias_zone
                    domain: binary_sensor
                sequence:
                  - delay:
                      hours: 0
                      minutes: 2
                      seconds: 0
                      milliseconds: 0
                  - type: turn_on
                    device_id: 7e58e524851f041c0aa6c3210bd2a99f
                    entity_id: light.porch_light
                    domain: light
                    brightness_pct: 30
              - conditions:
                  - type: is_motion
                    condition: device
                    device_id: 8e8d3133a93cc1ba43ad6fbceab31619
                    entity_id: >-
                      binary_sensor.lumi_lumi_sensor_motion_aq2_d8e3be07_ias_zone
                    domain: binary_sensor
                sequence:
                  - type: turn_on
                    device_id: 7e58e524851f041c0aa6c3210bd2a99f
                    entity_id: light.porch_light
                    domain: light
                    brightness_pct: 100
            default:
              - type: turn_on
                device_id: 7e58e524851f041c0aa6c3210bd2a99f
                entity_id: light.porch_light
                domain: light
                brightness_pct: 30
      - conditions:
          - condition: time
            after: "00:00"
          - condition: sun
            before: sunrise
        sequence:
          - choose:
              - conditions:
                  - type: is_no_motion
                    condition: device
                    device_id: 8e8d3133a93cc1ba43ad6fbceab31619
                    entity_id: >-
                      binary_sensor.lumi_lumi_sensor_motion_aq2_d8e3be07_ias_zone
                    domain: binary_sensor
                sequence:
                  - delay:
                      hours: 0
                      minutes: 2
                      seconds: 0
                      milliseconds: 0
                  - type: turn_off
                    device_id: 7e58e524851f041c0aa6c3210bd2a99f
                    entity_id: light.porch_light
                    domain: light
              - conditions:
                  - type: is_motion
                    condition: device
                    device_id: 8e8d3133a93cc1ba43ad6fbceab31619
                    entity_id: >-
                      binary_sensor.lumi_lumi_sensor_motion_aq2_d8e3be07_ias_zone
                    domain: binary_sensor
                sequence:
                  - type: turn_on
                    device_id: 7e58e524851f041c0aa6c3210bd2a99f
                    entity_id: light.porch_light
                    domain: light
                    brightness_pct: 100
            default: []
      - conditions:
          - condition: sun
            after: sunrise
            before: sunset
        sequence:
          - type: turn_off
            device_id: 7e58e524851f041c0aa6c3210bd2a99f
            entity_id: light.porch_light
            domain: light
    default: []
mode: restart
max: 10

I like your solution, i may change mine to something similar just my condition is not time based.

I did come up with a solution using the native api to create a service for the esp that allows me to call from HA or NodeRed to set a brightness level. The service just sets a global var on the esp, then when the switch turns on that var is used for the brightness value. This covers my use-case but has holes in it because i have not coding catching all the ways the brightness can be changed to “reset” the value.

Shocking that HA and esphome do not expose an api to change light settings WITHOUT turning on the light. Since then the light will turn on with the last state set naturally.

Hi,
I just find a solution using the lambda in ESPHOME like this:

on_value:
      then:
        - lambda: id(lightID).remote_values.set_brightness(x/100);

with x a number from 0 to 100

1 Like

I would like to revive this thread because I need the same functionallity.

Little background: I have a shelly dimmer 2 flashed with ESPHome which is automated using the Entity Controller component. There it is possible to turn my lights on when motion is detected but also declare a so called “night mode” where the brigthness can be set to a different level. After the night mode finishes, I disable the automation, so that the light gets not turned on automatically at full brightness in the mourning.
I would need a way to reset the brightness again without turning on the light in case someone turns the light on manually afterwards.

The Rest API allows me to turn_on, turn_off and toggle the light, but only the turn_on command allows specifying a brightness.

I remember the official shelly API allowed me to also set the brightness level on the turn_off command, so I just called http://url_of_shelly/light/0?turn=off&brightness=100 while it was already off.

Is there a similar way for ESPHome?

Did you look in the Docs? Its in there. https://esphome.io/

Of course I did, otherwise I wouldn’t have known which commands the Rest API supports.

I found out how you can do this in esphome: Light Component — ESPHome

then:
  - light.control:
      id: led_top
      brightness: !lambda return x/100;

light.control lets you set values and if you do not change the state, then it won’t turn on the light.

1 Like