I have a physical 220 volt light switch. It is also managed by nodemcu via a local blynk server. In the out of internet or wifi, the physical switch continue to work. I plan to move to home assistant from blynk. I’ve connected nodemcu (switch) to hass and I can turn on/off from phisical switch and from esphome. But if wifi is out phisical switch out too. Please help me to configure the nodemcu connected to esphhome so that the physical switch (nodemcu) works in the out of wifi.
Can you post your ESPHome configuration.
# D5 - out, connecting relay_1
# D6 - out, connecting telay_2
# D4 - out, just for testing inner nodemcu led
# D3 - in, connectin to phisical button_1
# D7 - in, connectin to phisical button_2
esphome:
name: esp8266-01
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key:
ota:
password:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp8266-01 Fallback Hotspot"
password: "h8JgQEoNhJXF"
captive_portal:
output:
- platform: gpio
id: led
pin:
number: D4
inverted: true
- platform: gpio
id: relay_1
pin:
number: D6
- platform: gpio
id: relay_2
pin:
number: D5
light:
- platform: binary
id: in_led
output: led
name: Left Lamp
- platform: binary
id: led_1
output: relay_1
name: butt_1
- platform: binary
id: led_2
output: relay_2
name: butt_2
binary_sensor:
- platform: gpio
pin:
number: D3
mode: INPUT_PULLUP
inverted: True
name: "button_1"
- platform: gpio
pin:
number: D7
mode: INPUT_PULLUP
inverted: True
name: "button_2"
Your yaml doesn’t show any action if you press one of the two configured binary_sensor
s
How does actually light switching actually work?
Your esp can control totally locally when used something like this:
light:
- platform: binary
id: in_led
output: led
name: Left Lamp
binary_sensor:
- platform: gpio
pin:
number: D3
mode: INPUT_PULLUP
inverted: True
name: "button_1"
on_state:
then:
- light.toggle: in_led
check the last three lines
Thank you. It looks too simple to understand this
"How does actually light switching actually work? " - over automation
when you press a button, you need to tell the node what to do … hence the last three lines
on-state
I think in my switch I have something like on-press … two things you have to look-up
and then
If it helps I can give you my yaml
I have read “Binary Sensor Component” and “Binary Light”. If you can please send me your yaml. I can’t find the command to initial seting of nodemcu. For example,
when the nodemcu is rebooted, the relay must be disabled (i.e. D5 = OFF) How to do it?
Simplified code (instead of the first message):
output:
- platform: gpio
id: relay
pin:
number: D5
inverted: true
binary_sensor:
- platform: gpio
pin:
number: D1
mode: INPUT_PULLUP
inverted: True
name: "butt_1"
on_click:
then:
- light.toggle: led_1
light:
- platform: binary
id: led_1
output: relay
name: butt_2
I’ve found a solution for my task. Maybe someone will come in handy.
There are:
- Phisical switch
- wemos d1 mini
- Relay
- Lamp
A task:
- Turn ON/OFF the lamp independently by phisical button and from Home Assistant
- Turn ON/OFF the lamp by phisical button if WiFi is down.
- After reboot wemos the lamp should OFF.
Code:
switch:
- platform: gpio
name: "Relay ON/OFF on D5"
id: relay_d5
pin:
number: D5
restore_mode: ALWAYS_OFF
binary_sensor:
- platform: gpio
pin:
number: D3
mode: INPUT_PULLUP
inverted: True
name: "butt_1"
on_press:
then:
- switch.toggle: relay_d5