How can I create an on/off UI switch that changes the value of an attribute defined in my configuration.yaml?

I’m using the Circadian Lighting custom component to have my lights automatically change temperature and brightness throughout the day. Here is my configuration for it in the configuration.yaml file:

switch:
  - platform: circadian_lighting
    name: Circadian Office
    min_brightness: 1
    max_brightness: 100
    lights_ct:
      - light.office
    disable_brightness_adjust: false
  - platform: circadian_lighting
    name: Circadian Kid Bedroom
    lights_ct:
      - light.KidBedroom
    disable_brightness_adjust: true
  - platform: circadian_lighting
    name: Circadian Master Bedroom
    min_brightness: 1
    max_brightness: 100
    lights_ct:
      - light.MasterBedroom
    disable_brightness_adjust: true

I would like to add switches on my UI that toggle just the value of the disable_brightness_adjust attribute for each of the configurations.

With my current configuration, I can add a switch that turns circadian lighting on or off completely for a set of lights, but that’s not what I want to do. I want to be able to enable/disable manual brightness control without disabling the circadian lighting entirely.

Thanks!

Can you just create different switches with the various values?

Changing config will require reloading config which creates a huge mess.

Agreed, changing the config directly wouldn’t be a good way to do this.

I’m not sure how to split a single switch into multiple switches though.

Just change name

This is one solution, but would require you to turn Circadian Office_true on and Circadian Office off every time OP wants only Color Temperature adjusted, then turn Circadian Office_true off and Circadian Office on when both should be adjusted. If both get left on then lights will get double the calls for adjustments which is just extra overhead. Another solution is to have one switch that only adjusts color temperature, and one that only adjusts brightness. That way each can be turned on/off independent of each other with no need to flip two switches, and you have the added flexibility to have brightness adjust without color temperature if you want. There’s an example here: Is it possible to toggle the value of "disable_brightness_adjust" from the UI? · claytonjn/hass-circadian_lighting · Discussion #240 · GitHub

# Enable Circadian Lighting
circadian_lighting:

switch:
# Add Color Temperature Switch
  - platform: circadian_lighting
    lights_ct:
      - light.example_light
    name: Example Color Temperature Circadian Lighting Switch
    disable_brightness_adjust: true
# Add Brightness Switch
  - platform: circadian_lighting
    lights_brightness:
      - light.example_light
    name: Example Brightness Circadian Lighting Switch

Thanks! And sorry for the slow reply.

That looks to be what I’m looking for. The post you referenced was also my post :slight_smile:

This is working great except for one issue: now, when I power the lights off and on, the brightness often doesn’t auto-adjust even if the “brightness switch” is enabled. I have to toggle that brightness switch off then on again, while the lights are powered on, to fix the brightness.

The weird thing is that when this happens the lights turn on really dim, even if they were powered off during daylight hours then powered back on during daylight hours. So no event should have set them to be so dim during the period when they were off.

I can’t currently prevent people from physically powering the lights off (using the normal light switches). Any idea what would fix this? I can try creating an automation that triggers when the lights reconnect that toggles the brightness switch, but I’m wondering if there’s a less hacky answer.

They’re Philips Hue lights, so the problem may have something to do with the Hue app, which I’ll test.

This is my config:

circadian_lighting:
  min_colortemp: 2200
  max_colortemp: 6500

switch:
  - platform: circadian_lighting
    lights_ct:
      - light.office
    name: Office Temperature
    disable_brightness_adjust: true
  - platform: circadian_lighting
    lights_brightness:
      - light.office
    name: Office Brightness
  - platform: circadian_lighting
    lights_ct:
      - light.hanna_bedroom
    name: Hanna Bedroom Temperature
    disable_brightness_adjust: true
  - platform: circadian_lighting
    lights_brightness:
      - light.hanna_bedroom
    name: Hanna Bedroom Brightness
  - platform: circadian_lighting
    lights_ct:
      - light.master_bedroom
    name: Master Bed Temperature
    disable_brightness_adjust: true
  - platform: circadian_lighting
    lights_brightness:
      - light.master_bedroom
    name: Master Bed Brightness

Thanks!

Do you see anything relevant in the logs? You might need to turn on debug logging for Circadian Lighting (ref. Debugging · claytonjn/hass-circadian_lighting Wiki · GitHub)

To be clear, in this situation by powered off you mean from the wall switch, cutting power, not powered of through software? If that’s the case then you probably want to adjust the “power on behavior” of the lights in the Hue app. I use the “power loss recovery” option for all of my Hue lights, so if power is cut they turn back on to whatever state they were in when powered off.

Thanks! I think that’s likely the problem, I had each light bulb set in the Hue app to power on at a different, specific setting. I’ll change them all to “power loss recovery”.