Pre-set the brightness for the next time a certain light gets turned on (kind of like a "reset" or such); How to do this?

Hello all,

Can you help me with how to achieve the subject. I imagine it’s simple, I’m just dense sometimes. Essentially what I would like to do is have the automation below, set the 2 kitchen cabinet lights to like 80% brightness for the next time they come on. (So whether the brightness was preset at like midnight or at the end of the below automation, I’m ok with either-- I just don’t want a weird flash in the middle of the night, etc.)

Is this doable, almost like a light reset, prepping them for the next day? It would be preferred to tie it to the end of the below automation if possible (preferred over the midnight idea)

Thank you all for all of the help you have given me lately!!

Activation

    alias: Dog Mode Activated
    mode: single
    trigger:
      - platform: state
        entity_id: binary_sensor.gym_motion_sensor
        to: "on"
      - platform: state
        entity_id: input_boolean.dog_mode
        to: "on"
    action:
      - choose:
          - conditions:
              - condition: template
                value_template: '{{ trigger.to_state.attributes.friendly_name == "Dog Mode" }}'
            sequence:
              - service: script.text_notify
                data:
                  who: "parents"
                  message: "Dog Mode has been enabled manually"
          - conditions:
              - condition: state
                entity_id: input_boolean.sentry_mode
                state: "on"
              - condition: state
                entity_id: group.family
                state: "home"
            sequence:
              - service: input_boolean.turn_on
                entity_id: input_boolean.dog_mode
              - service: script.jarvis_alert
                data_template:
                  # who: kitchen
                  message: "Turning on Dog Mode."
          - conditions:
              - condition: state
                entity_id: input_boolean.sentry_mode
                state: "on"
              - condition: state
                entity_id: group.family
                state: "not_home"
              - condition: state
                entity_id: input_boolean.vacation_mode
                state: "off"
            sequence:
              - service: script.text_alert
                data:
                  who: parents
                  message: "Wrigley may be trying to go out and no one appears to be here to let him out."
      - service: script.dog_mode_lighting_on
        data: {}
      - delay:
          minutes: 20
      - service: input_boolean.turn_off
        entity_id: input_boolean.dog_mode

Deactivation
# # After 20, minutes deactivate dog mode

  - id: dog_mode_deactivated
    alias: Dog mode Deactivated
    initial_state: true
    trigger:
      - platform: state
        entity_id: input_boolean.dog_mode
        to: "off"
    action:
      - service: script.text_notify
        data:
          who: "parents"
          message: "Dog Mode has been disabled"
      - service: light.turn_off
        data: {}
        target:
          entity_id:
            - light.long_kitchen_cabinet_accents
            - light.short_kitchen_cabinet_accents

Why wouldn’t you just turn them on to the brightness you want the next time you turn them on?

I was hoping to make it seemless so the next person that uses a voice assistant doesn’t have to tell it a brightness.

Aka: WAF

I did something like this recently with my closet light where I have a different night time and daytime brightness. What I did is setup 2 scenes for the light with the brightness and color for the related time. And what I did then is when the light is turned off I call the scene I want as my default before the light is actually turned off. Then when the light is turned on next time it’s at the “default” color/brightness and then will change to the correct scene based on the time of day. Now I’m using a wireless ZigBee switch to turn the smart bulb on/off so that is my trigger, the bulb turning on/off is not the trigger.

What is your light/switch setup?

That’s exactly how I handle it. I have a trigger for lights turning on for certain lights. Those lights when they turn on, will transition to the brightness for that time period. So even if google or a light switch turns it on, it’ll dim/bright to the appropriate level fairly quickly. It isn’t ‘seamless’ though.

Ahhh, scenes. I figured there had to be a Sharp way to do it. I’m not sure I know how to do it completely yet but I’m following your direction.

In my Instance these are under cabinet lights that aren’t tied to switches. At night they are motion activated to a low brightness by an automation I didn’t post here.

All other times, they are not motion activated but voice 99% of the time.

Time of day sensors are the perfect idea for this situation. Let me post the other automation here in a second so we can get this hashed out. I only posted the deactivate in the leading post.

This isn’t terrible. Honestly I think it will work well, I was just making this one more complicated than it was sadly. I’m a pro at that. I’ll post my original activation automation in just a second.

Essentially, I want the lights to go back to blaring bright when dog mode isn’t activated.

I don’t use scenes. I don’t like them. You may not easier. The GUI activates a scene just by editing it. Its terrible in my opinion. I simply script it. Simply and easy.

Yeah, that’s kind of what I’m doing except for the reverse because I don’t want the light coming on blaring and then going darker late at night or early in the morning. Transitioning from low light to bright causes a visual stepping but it’s acceptable during the day but not at night when I want the light darker at night and never bright.

@timnolte @calisro

Alright, the original post has been edited to show the full picture of what I have currently.

I still specify a value (based on dymanic variables) so they turn on via automations to the correct brightness. I just piggy back that to handle the switches/google to fix it if an automation didn’t turn it on. Seems to be okay. But yes, they can be turned on very bright via switch at night which isn’t great till it auto-dims.

True, yeah. This is what I meant. When dog mode gets activated at night, do the cabinet lights at like 30%. And then my original thoughts were at deactivation to set the lights back to the 100% but I found out it does exactly what I ask and blinds me for a second late at night because I was essentially trying to set it and then turn them “off” abruptly. So you say, when the boolean “dog mode” is on as a condition, do a scene or script that sets my preferred “look”. How do I do a catch all for all other times though? I have to do an automation that says when boolean “dog mode” is not on… do this for those individual lights. Or I guess I could do a choose?

EDIT: I’m trying to be lazy and modify what I already have if possible. Maybe that will be more difficult in the log run.

Why not just have the automations that turn them on set the brightness explicitly? Alternatively set a default brightness in light_profiles.csv.

I didn’t even know about that default brightness concept. That’s nice.

The main reason for me was not wanting to explicitly state the brightness. Each night when the dog went out. The next day we went into the kitchen to cook, they were too low and had to be adjusted.

I have these specific lights coming on by automation an hour or so before sunset and we always end up doing things out of routine. —ie, our routine is routinely no routine.

Here is my full YAML, you can ignore the fact that I have a single vs double tap as that was my initial way to handle the 2 light modes but changed to using sunset/sunrise.

alias: Tim's Closet Light Toggle
description: ''
trigger:
  - platform: device
    domain: mqtt
    device_id: b9ddcab3f70aa81efd2c0f3c562ce559
    type: action
    subtype: single
    discovery_id: 0x00158d0006fbeb3d action_single
    id: single-tap
  - platform: device
    domain: mqtt
    device_id: b9ddcab3f70aa81efd2c0f3c562ce559
    type: action
    subtype: double
    discovery_id: 0x00158d0006fbeb3d action_double
    id: double-tap
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: single-tap
          - condition: or
            conditions:
              - condition: sun
                before: sunrise
              - condition: sun
                after: sunset
        sequence:
          - if:
              - condition: device
                type: is_off
                device_id: 63c75257c27e4598c6f128f860fd9050
                entity_id: light.tims_closet_light
                domain: light
            then:
              - service: scene.turn_on
                target:
                  entity_id: scene.tim_s_closet_light_night_light
                metadata: {}
            else:
              - type: turn_off
                device_id: 63c75257c27e4598c6f128f860fd9050
                entity_id: light.tims_closet_light
                domain: light
      - conditions:
          - condition: trigger
            id: single-tap
          - condition: or
            conditions:
              - condition: sun
                after: sunrise
              - condition: sun
                before: sunset
        sequence:
          - if:
              - condition: device
                type: is_off
                device_id: 63c75257c27e4598c6f128f860fd9050
                entity_id: light.tims_closet_light
                domain: light
            then:
              - service: scene.turn_on
                data:
                  transition: 2
                target:
                  entity_id: scene.tim_s_closet_light_normal
            else:
              - service: scene.turn_on
                data: {}
                target:
                  entity_id: scene.tim_s_closet_light_night_light
              - type: turn_off
                device_id: 63c75257c27e4598c6f128f860fd9050
                entity_id: light.tims_closet_light
                domain: light
    default: []
mode: single

So the csv file you speak of cause the light to ignore it’s last setting and it always defaults to what is in the csv?

Thank you for this so that I can review when I am back to my PC. Very helpful, I learn by seeing for sure.

It should IF the light is off and is being turned on by HA without an explicit contradicting setting.

It won’t transition an already “on” light.

The below light_profiles.csv should work. You need to restart HA after creating the file. Brightness is a 0-254 value, not a percentage.

profile,color_x,color_y,brightness,transition
light.long_kitchen_cabinet_accents.default,,,204
light.short_kitchen_cabinet_accents.default,,,204

@jerrm

This is great. This is really what I was envisioning/ hoping to do. Also, I follow you on an already “on” light, that makes since.

I could see the other line of thought on this of, “you don’t need to be hiding stuff” in files people know nothing about haha. (This seems like a hidden trick that only the experts would know about.)

If you don’t mind me asking, how did you find out about this little gem of an idea? I like it.

Thank you for giving me this. I will end up using this more than likely.

Last thing I will add is, as a devils advocate and from a “transparency” perspective, do you have any other approaches at this that you feel would be more “kosher”. Def feel like “light_profiles.csv” is an ace up the sleeve for sure. And it potentially could even get annoying reverting back to something other than the last used state.—> It just happens to be in this dog mode case, that it’s last used state is annoying. hahaha. Everything is annoying apparently, I am starting to see. :slight_smile:

I guess perfect world scenario would be “maintain the last state in all instances except for the instance of when it was set by the dog mode automation”

Also, where do I find “light_profiles.csv”, it must not be in the config directory.