Closed pawelsky closed 3 years ago
Have you tried implementing this in ESPHome as a GPIO Binary Sensor? While I have not tested it, I believe it might be what you're looking for to make this work without modifying the custom dimmer code.
@JeffResc Not quite what I'm looking for. That would only give me a sensor, which would then have to be handled by HA. I was more thinking of making it part of the dimmer firmware to react to the button so it could be used even if HA/network fails.
Also I'm not sure if GPIO2 is not used for something else (did not look at the board under the microscope yet). Did anyone check?
I'm not sure about GPIO2 either, but this template would work for any GPIO port. So just because it's a sensor doesn't necessarily mean it needs to be handled by HA / have a network connection. This is some YAML I'm using on another device and it should work just fine for this use as well:
binary_sensor:
- platform: gpio
pin:
number: GPIO2
mode: INPUT_PULLUP
inverted: true
internal: true
id: push_button
on_press:
then:
- light.toggle: main
You can see more about on_press
, on_release
, on_click
, on_double_click
, on_multi_click
, etc. here.
@JeffResc Will give it a try, thanks.
In the meantime checked the #2
pad - it doesn't seem to be connected to anything other than the GPIO2 pin.
BTW there is also pad #5
exposed which is connected to GPIO5 (and nothing else) - see top right corner.
Tested the binary_sensor automations and they do what I need. Thanks again @JeffResc 😀
@JeffResc One thing I'm missing in the Sonoff D1 Dimmer module is an input to control it with a momentary wall switch. Short press would switch the dimmer on/off, long press would cycle through the brightness level back and forth.
Did you consider adding such option to your custom configs? If I'm not mistaken the GPIO2 pin is broken out on the boards, and could probably be used for that.