Any ideas on what esphome component I need to turn an led strip on and off when a desk drawer opens and closes? I have made quite a few esphome led strips with motion sensors but a drawer open and close likely requires something I haven’t encountered. Thanks (it’s for my son’s birthday present - a new gaming desk with computer).
Maybe this? Gikfun MC-38 Wired Door Sensor Magnetic Switch for Arduino EK1656 https://www.amazon.com/dp/B0154PTDFI/ref=cm_sw_r_cp_api_i_XW5PEb6CP2Q0B
Any reed switch will do. You can use the internal pull up resistors (at least esp32 has these) so no additional hw is required.
Or then use normal push button so that when drawer is closed the push button is closed. This button could also be used to activate some cool features.
Any door or window sensor actually. It doesn’t have to report to esphome. Anything that reports to home assistant - could be rfc, z-wave, zigbee etc.
Thanks. Can you explain how to use the “internal pull-ups”? I have ESP32 boards and ordered the reed switches above. Thanks
You don’t want to leave the input pin floating. It needs to be either low or high.
Depends on how you build the circuit. If the pull up resistor pulls the input pin high, you need to pull it to ground via the reed switch. Or if you have pull down resistor you need to pull the input pin high with the reed switch.
Why do you need this integrated in HA?
Just a simple pushbutton switch inline with power source to the light.
Maybe I’m not getting it, but I don’t see any benefit of having a door activated light with a ESP chip.
That is one good approach yes.
Depending on the light there could be transitions, effects, maybe don’t want the light to turn on at specific time, add later more functions to esp to do other stuff as well, keep the drawer open but get irritated of the light and want to turn it off…
Depends on use case. Personally I like to be prepared
Worked perfectly using a magnetic reed switch and the code below (once I found the right pin and reversed the switch’s wires):
binary_sensor:
- platform: gpio
pin:
number: GPIO15
mode: INPUT_PULLUP
name: "Upper Drawer"