Git Product home page Git Product logo

Comments (1)

airdrummingfool avatar airdrummingfool commented on July 24, 2024

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 day, dusk, evenfall, evening, and night keys from the original config as voltage thresholds (apparently in mV), though I'm going to end up adjusting them for my own usage since my device's sensor is almost always in the shade.

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 on_press that handles turning on the light when the PIR pin goes high. In my case, I only want it to turn on the light if it is sufficiently dark outside (basically "evening" or darker):

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.

from upk2esphome.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.