I have an esp8266 multi sensor with motion/temp/hum/lux connected to HA via esphome and I need to build an automation based on movement and light level.
Currently I have the lux reading coming in every 10 seconds. Is it possible to make the sensor send a lux reading whenever motion is detected? That way I can set the interval to once an hour and not poll constantly.
The lux sensor
- platform: adc
pin: A0
name: "Kitchen LUX"
unit_of_measurement: lx
update_interval: 10s
filters:
- lambda: |-
return (x / 10000.0) * 20000000.0;
7h30n3
(The One)
August 26, 2020, 12:56pm
3
You need to use this: https://esphome.io/guides/automations.html#component-update-action
So you add to your PIR sensor something like this:
on_press:
then:
- component.update: lux_sensor
Assuming your motion sensor is binary and you set the id of your lux sensor to lux_sensor
.
Something like this in the yaml of the node?
sensor:
- platform: adc
pin: A0
name: "Kitchen LUX"
unit_of_measurement: lx
update_interval: 10s
filters:
- lambda: |-
return (x / 10000.0) * 20000000.0;
binary_sensor:
- platform: gpio
pin: D5
name: "Kitchen PIR Sensor"
device_class: motion
on_press:
then:
- component.update: lux_sensor
Still not sure what value to put in for the lux_sensor
though
7h30n3
(The One)
August 26, 2020, 5:10pm
5
Just add the id to the adc sensor like this:
sensor:
- platform: adc
pin: A0
id: lux_sensor
name: "Kitchen LUX"
unit_of_measurement: lx
update_interval: 10s
filters:
- lambda: |-
return (x / 10000.0) * 20000000.0;
binary_sensor:
- platform: gpio
pin: D5
name: "Kitchen PIR Sensor"
device_class: motion
on_press:
then:
- component.update: lux_sensor
Perfect, works great, thanks
1 Like