claytonjn / hass-circadian_lighting

Circadian Lighting custom component for Home Assistant
Apache License 2.0
778 stars 87 forks source link

While in Sleep mode, switching back to "normal" colortemp #94

Open rosch100 opened 4 years ago

rosch100 commented 4 years ago

While sleep mode is enabled at night and the lights receive another trigger to turn on, the color changes to normal night colors even though the sleep_mode setting did not change.

I have set up my lights to turn on/off via motion sensors. So, it is not uncommon for the lights to receive another turn on trigger at night.

Since I use your suggested template kelvin: '{{ state_attr(''sensor.circadian_values'', ''colortemp'') | int }}', could it be that the sensor.circadian_values does not change to sleep mode colortemp?

My config: configuration.yaml

circadian_lighting:
  min_colortemp: 2000
  max_colortemp: 6500
  sunrise_offset: -00:00:00

switch:
  - platform: circadian_lighting
    name: Mit Helligkeit
    sleep_colortemp: 5000
    sleep_brightness: 1
    sleep_entity: input_boolean.circadian_sleepmode
    sleep_state: "on"
    lights_ct:
      - light.lampe_schlafzimmer_dach_light
      - light.lampe_schlafzimmer_bett_light  

input_boolean:
  circadian_sleepmode:
    name: Licht Nachtmodus
    initial: off
    icon: mdi:moon-waning-crescent 

automations.yaml

- id: '1586430819624'
  alias: Licht im Schlafzimmer einschalten
  description: ''
  trigger:
  - device_id: f160509cd5154058bf9222d7bdfa84db
    domain: binary_sensor
    entity_id: binary_sensor.bewegung_schlafzimmer_occupancy
    platform: device
    type: motion
  condition: []
  action:
  - service: light.turn_on
    data_template:
      kelvin: '{{ state_attr(''sensor.circadian_values'', ''colortemp'') | int }}'
      brightness_pct: '{{ state_attr(''switch.circadian_lighting_mit_helligkeit'',
        ''brightness'') | int }}'
      entity_id:
      - light.lampe_schlafzimmer_bett_light
      - light.lampe_schlafzimmer_dach_light
basnijholt commented 4 years ago

@rosch100, I have introduced a new configuration setting only_once in the latest beta, you might want to check that out.

Also, I think you are confused about how your configuration works. Your light turns on upon a trigger from a binary_sensor and only then it sets it to the color you want. However, if you manually switch on the light, nothing will happen.

Luckily, this problem is fixed by just using the only_once: true setting :tada:

rosch100 commented 4 years ago

Thank you @basnijholt ! I'd want to try the change, is there a simple way to switch to the beta branch from HACS?

basnijholt commented 4 years ago

For that, I think we need to wait until @claytonjn merged https://github.com/claytonjn/hass-circadian_lighting/pull/113 and released a new beta.

claytonjn commented 4 years ago

I merged #113 and pushed 2.0.1b from my phone this morning but I've been AFK all weekend. @rosch100 to switch to beta releases in HACS you have to locate Circadian Lighting under Integrations, open the three-dot menu, choose Reinstall, then toggle the "Show beta version" switch.