Garden Assistant

Home Assistant automation projects, questions, etc. go here.
00schteven
LED-Curious
LED-Curious
Reactions:
Posts: 23
Joined: Thu Dec 31, 2020 10:39 pm

It most defiantly dims to off. I had it hooked up last night and working. Some strange things were going on though, I set the output to "ledc".

Code: Select all

light:
  - platform: monochromatic
    name: "flower_light"
    output: flower_light
output:
  - platform: ledc
    id: flower_light
    pin: 27
    inverted: True
    min_power: 0%
    max_power: 100%
    
With the lower limit set to 0 and the upper 100 the light would dim from 100% to 40%, so at lower then 40 it would shut off. So I went back into the config and changed the lower limit to 20%, now it dims from 1-100 but will not dim to off. It was getting super late by this point so I gave up for the night. Today I plan getting the enclosure all set and ready.

What output settings have you found to work the best?
@stevetheganjafarmer
00schteven
LED-Curious
LED-Curious
Reactions:
Posts: 23
Joined: Thu Dec 31, 2020 10:39 pm

This is what I have so far:
Screenshot_20210107-231846.png
IMG_20210107_232527733_HDR.jpg
IMG_20210107_232607203_HDR.jpg
@stevetheganjafarmer
00schteven
LED-Curious
LED-Curious
Reactions:
Posts: 23
Joined: Thu Dec 31, 2020 10:39 pm

Now that I have the basics working I want to add some automation to simulate a sunset and sunrise, maybe a solar noon. The esp32 is controlling my light, it is the on/off timer and dimmer. I have it set to return to 80% from lights out as the light is too damn bright. Getting it to ramp slowly up to 100% was easy. Getting it to stop at a adjustable value I could set from the home screen was something eles. After a few hours playing around this is the automation that I got:

Code: Select all

- id: '1610574859252'
  alias: Test Light Sun Rise
  description: ''
  trigger:
  - platform: time
    at: input_datetime.test_light_on_time
  condition: []
  action:
  - type: turn_on
    device_id: 9a6a92804a0aa266950c3a6ee14a29a4
    entity_id: light.test_light
    domain: light
    brightness_pct: 1
  - repeat:
      until:
      - condition: template
        value_template: '
          {{ states(''input_number.maximum_brightness'') | float  <= ((states.light.test_light.attributes.brightness)/2.55)  | float }}'
      sequence:
      - type: brightness_increase
        device_id: 9a6a92804a0aa266950c3a6ee14a29a4
        entity_id: light.test_light
        domain: light
      - delay: 00:02:00
  mode: single
- id: '1610616240469'
  alias: Test Light Sun Set
  description: ''
  trigger:
  - platform: time
    at: input_datetime.test_light_off_time
  condition:
  - condition: device
    type: is_on
    device_id: 9a6a92804a0aa266950c3a6ee14a29a4
    entity_id: light.test_light
    domain: light
    for:
      hours: 0
      minutes: 0
      seconds: 1
  action:
  - repeat:
      until:
      - condition: device
        type: is_off
        device_id: 9a6a92804a0aa266950c3a6ee14a29a4
        entity_id: light.test_light
        domain: light
        for:
          hours: 0
          minutes: 0
          seconds: 1
      sequence:
      - type: brightness_decrease
        device_id: 9a6a92804a0aa266950c3a6ee14a29a4
        entity_id: light.test_light
        domain: light
      - delay: 00:02:00
  mode: single
It's greasy but it kind of works. I have a few helpers: "input_datetime.test_light_on_time" and "input_datetime.test_light_off_time" to trigger the automation, and "input_number.maximum_brightness" to stop before 100%. For testing purposes I'm using an extra esp32 and it's status led as my test light.

Code: Select all

light:
  - platform: monochromatic
    name: "test_light"
    output: test_light

output:
  - platform: ledc
    id: test_light
    frequency: 1220 Hz
    pin: GPIO2
    inverted: false
    min_power: 0%
    max_power: 100%
The brightness of the light is 0-255, but I wanted it to be adjustable by a slider in %, so there is a bit of math in the template. I need to tweak the step somehow to smooth out the transition, and increase the accuracy. I also want to adjust the delay from the home screen so I can adjust the time of the effect. The default dim step is 10%, so I get about 10 steps from 0 to 100, 2 minuets a step translates to roughly 20 minuet transition.
Is anyone doing this in a more graceful way? Or see something obvious that I do not?


A few edits because I first tried to type this up and copy things from the file editor on my cell phone before I sat down at the keyboard.
@stevetheganjafarmer
00schteven
LED-Curious
LED-Curious
Reactions:
Posts: 23
Joined: Thu Dec 31, 2020 10:39 pm

https://community.home-assistant.io/t/c ... nent/61246

Had anyone played around with this yet?
@stevetheganjafarmer
User avatar
LEDG
Site Admin
Reactions:
Posts: 1599
Joined: Sun Jun 04, 2017 8:15 pm

Haven't played with that component.

Thought I'd share something I discovered about the weird lighting range given by ledc...

Apparently you need to specify a gamma_correct to make the dimming more linear. It defaults to 2.8, so you set it to 1.0 like this:

output:
- platform: ledc
pin: 27
frequency: 1220 Hz
inverted: true
id: growlight_pwm
channel: 0

light:
- platform: monochromatic
name: "Grow Light"
output: growlight_pwm
gamma_correct: 1.0
Want to Support the Site?

Use this Amazon referral link and any purchase you make within 24 hrs will earn LEDgardener a commission at no cost to you!
00schteven
LED-Curious
LED-Curious
Reactions:
Posts: 23
Joined: Thu Dec 31, 2020 10:39 pm

The Circadian rhythm component works but not how I thought it would. It is ment to compensate for when the sun sets. So at lights on it would be 100%, dim to minimum at noon, back to 100% for sun set. I just set my test light to "inverted: true" to get the effect. I have not played with it too much yet, I am working up the courage to go poke around the .py files. I am also looking at Flux to accomplish the same thing without installing HACS.
@stevetheganjafarmer
Post Reply