Closed rradar closed 3 years ago
it looks like it has only one binary output pin, you can already use a simple binary sensor as is stated here https://esphomelib.com/esphomeyaml/cookbook/pir
Yes, as @Melkor82 says this is a simple gpio binary sensor so it's already supported.
This is more of a documentation issue. If you want, you can create a cookbook entry (like the one for the PIR sensor).
OK, very nice! I will try! :+1:
Does this also count for this "Heltec Capacitive Touch Switch Module"
It's not a motion sensor but a button/switch
@rradar Yes, that would also be a GPIO binary sensor. In general, everything that only has three pins (GNC, VCC, and a third pin often called OUT) is either a GPIO binary sensor or GPIO switch.
There are a few exceptions (DHT, ds18b20, etc) but as a general rule of thumb it's quite accurate.
Just a short feedback:
As expected I can use the RCWL-0516 identically like a pir sensor (described here: https://esphomelib.com/esphomeyaml/cookbook/pir).
For the "Heltec Capacitive Touch Switch Module" I was able to use it as a GPIO binary sensor - easy like this:
binary_sensor:
- platform: gpio
pin: D7
name: "Heltec Touch Button Sensor"
I couldn't make it work as a GPIO Switch. Not exactly sure why? Could it be limited by the hardware? How could I test?
My idea was to make use of the fluorescent light it's emitting while it's on. So it would be not only a switch but also a indicator that something is on :grin:
Yes it's currently a bit difficult to do so, and I don't have a very nice solution for it. Some time ago we came up with an ugly but working example:
# Control the output
output:
- platform: esp8266_pwm
pin: D7
id: out
max_power: 70%
# Expose output as a switch (you could also do it as a light), turn it on to get the backlight
switch:
- platform: output
name: "Button Backlight"
output: out
# Use a duty cycle sensor to check how long the output is on
# If it's more than 70%, we know it must be from a button press
sensor:
- platform: duty_cycle
pin: D7
id: duty
# Disable outputting values so that we don't spam logs
filters:
- lambda: 'return {};'
update_interval: 100ms
# Prevent duty cycle sensor from spamming logs
logger:
level: DEBUG
logs:
sensor.duty_cycle: NONE
# Finally, the template binary sensor to detect the button state
binary_sensor:
- platform: template
name: "Button State"
lambda: |-
// Use 75% to make sure we don't activate on random jitter
return id(duty).raw_state > 0.75;
That could also be turned into a cookbook entry ;-)
thank's @OttoWinter for the sketch. Looks a little rocket science to me but I'm trying hard to understand want's going on.
For my example I want to switch the "Heltec Touch Button" if a "PIR Sensor" goes on. For now I don't mind the state (which is done in your sketch by the duty_cycle and template sensor as I understand).
So I thought the easy way would be to do a sketch like this:
binary_sensor:
- platform: gpio
pin: D5
name: "PIR Sensor"
device_class: motion
on_press:
then:
- switch.toggle: buttonbacklight
- platform: gpio
pin: D7
name: "Heltec Touch Button Sensor"
device_class: power
id: heltec
# Control the output
output:
- platform: esp8266_pwm
pin: D7
id: out
# Expose output as a switch (you could also do it as a light), turn it on to get the backlight
switch:
- platform: output
name: "Button Backlight"
output: out
id: buttonbacklight
But it does not work as intended. So not when I want to... but sometimes it lights up shortly without touching (on a restart I think). So the software part for activating/switching is working somehow. I even get this promising log output:
[15:03:22][D][binary_sensor:027]: 'PIR Sensor': Sending state ON [15:03:22][D][switch:041]: 'Button Backlight' Toggling OFF. [15:03:22][D][switch:055]: 'Button Backlight': Sending state ON
I'm not sure what's wrong :confused:
(late to the party, but 2 cts...) What gave you the idea you can use the Heltec Touch Button as a switch? As far as I can tell it only has an output, OUT, and you should not be driving that from the ESP. Unless you are 100% sure it is an open collector output with some internal pullup resistor. (but mine do not look to have that)
What new integration would you wish to have?
"RCWL-0516 is a doppler radar microwave motion sensor module which can act as an alternative to a PIR motion sensor"
If possible, provide a link to an existing library for the integration:
Product link: https://www.aliexpress.com/item/Free-Shipping-Human-body-induction-module-RCWL-0516-microwave-radar-inductive-switch-module-intelligent-sensing-detector/32712700620.html (US $0.49 / piece)
Is your feature request related to a problem? Please describe. I'm always frustrated when I can't use esphomelib for all of my sensors :crying_cat_face: