@bean wrote:
I have a d1 mini configured to a reed sensor; copy/pasted from another project. I am trying to modify the project so the sensor will power a relay. I have tried many combinations but can not get the correct code. I did have the switch showing in home assistant but it did not control the relay so I removed the code.
What is the code for the switch and then how does the switch power the relay on/off with the status of the binary_sensor?
esphome: name: esphome_freezer_door platform: ESP8266 board: d1_mini wifi: ssid: 'ssid_here' password: 'password_here' fast_connect: true manual_ip: static_ip: 192.168.1.145 gateway: 192.168.1.1 subnet: 255.255.255.0 dns1: 192.168.1.1 dns2: 192.168.1.1 api: ota: web_server: port: 80 logger: binary_sensor: - platform: gpio pin: number: GPIO13 mode: INPUT_PULLUP inverted: False name: "Freezer Door" device_class: door filters: - delayed_on: 20ms
The binary_sensor is working correctly, just need to have it control the relay. The relay is stacked on the D1 mini.
The switch should be named “Freezer Light” and will be GPIO5. I want it to turn on when the binary_sensor: “Freezer Door” opens and remain off when the binary_sensor: “Freezer Door” is closed.
Hope this makes sense, any help appreciated.
Posts: 5
Participants: 2