-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ADC-based ambient light sensor #10
Comments
Thanks for posting this. My device has similar keys and functionality. The light sensitivity setting code above doesn't seem to do anything on my device, but I was able to set up a text sensor to display the light level as read by my device's light sensor, based on your ADC sensor. I used the text_sensor:
- platform: template
id: text_sensor_ambient
name: Ambient Light Sensor
sensor:
- platform: adc
pin: ADC3
id: adc_ambient
name: Ambient ADC Value
unit_of_measurement: "V"
state_class: "measurement"
# This `on_value` trigger will update the text sensor based on the voltage thresholds read from the original config
# in my device's case, they looked like this:
# "day": 0,
# "dusk": 200,
# "evenfall": 1500,
# "evening": 1800,
# "night": 2150,
on_value:
then:
- lambda: |-
if (x > 2.15) {
id(text_sensor_ambient).publish_state("Night");
}
else if (x > 1.8) {
id(text_sensor_ambient).publish_state("Evening");
}
else if (x > 1.5) {
id(text_sensor_ambient).publish_state("Evenfall");
}
else if (x > 0.2) {
id(text_sensor_ambient).publish_state("Dusk");
}
else {
id(text_sensor_ambient).publish_state("Day");
} I then set my own "light sensitivity trigger" by adding the following condition to my binary_sensor:
- platform: gpio
pin: P6
name: PIR Sensor
id: binary_sensor_pir
device_class: motion
on_press:
if:
condition:
sensor.in_range:
id: adc_ambient
above: 1.8
then:
- light.turn_on: light_flood Separate from this, my device has a PIR sensitivity setting that I think can be inferred from the configuration. I will create an issue to detail what I've found. |
Based on my tests (as I mentioned in libretiny-eu/libretiny#219), the mere existence of one of the keys: 'day', 'dusk', 'evenfall', 'evening' and 'night' suggest that there's an ADC-based ambient light sensor. There seem to be no configuration of ADC in UPK, but all of my 3 kind of lamps that have this use the same setup, which can be expressed in esphome yaml like this:
And the keys can be expressed as esphome select like this:
The above thresholds are taken from UPK itself of course.
My python knowledge is yet too basic to try the pull request, so I'm leaving this to someone else to try :)
The text was updated successfully, but these errors were encountered: