OK, so to Nick’s point…
I am brand new to this, and while I have a decent background in Linux and electronics in general, I know next to nothing about HA or ESPHome. Let’s face it folks, the documentation for both HA and ESPHome are sparse and most documentation/support is provided by the Community. The previous threads I’ve searched don’t address this issue and/or have very little information about what was done to solve it. I don’t expect somebody to do the work for me… I’m hoping for a pointer in the right direction.
I am running HA OS 6.6 in a VM under Ubuntu 20.04.3 with KVM hypervisor. The HA OS image was provided by HA. The Supervisor is 2021.10.8, and Core is 2021.11.1
I thought I was clear about the problem: The function of the device and controller does not match the reported state. The device function is the opposite of the expected state. Correcting this function to the expected state by placing “inverted: True” in each pin/switch definition works for function - but the logs show the exact opposite of what is reality. The current state is what is reflected by the n3.yaml file below. The only change I made I saw in another thread… “inverted: True”. When that didn’t work, I went back to default - the yaml file below.
The current configuration has the relays and thir loads “ON” even though the HA dashboard switches are “OFF”. The logs also show them “OFF”; as evidenced by them showing as set to “ON” when you toggle them “ON” in HA. The logs then reflect them being toggled “OFF” when the HA dashboard is used to toggle them “OFF”. The problem, again, is that the HA switch toggle and resultant log entries are 180 degrees out of phase with the reality: the devices are “ON” when HA says they are “OFF” and vice versa (under the yaml used below) Using “inverted: True” in each pin definition results in correct function (loads and relays are “OFF” or “ON” when the HA dashboard says they should be), but the log shows the state as opposite of that.
All I wish to do is have the State reflect the Reality. I can use “inverted: True” to correct the function of my devices and the HA dashboard. Is this possible?
n3.yaml
esphome:
name: n3
platform: ESP32
board: esp32dev
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "****"
ota:
password: "****"
wifi:
ssid: "****"
password: "****"
# Optional manual IP
# manual_ip:
# static_ip: 192.168.0.102
# gateway: 192.168.0.1
# subnet: 255.255.255.0
# dns1: 192.168.0.1
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "N3 Fallback Hotspot"
password: "****"
captive_portal:
switch:
- platform: gpio
pin: GPIO15 #D15
name: "SW-1"
id: SW1
- platform: gpio
pin: GPIO2 #D2
name: "SW-2"
id: SW2
- platform: gpio
pin: GPIO4 #D4
name: "SW-3"
id: SW3
- platform: gpio
pin: GPIO16 #RX2
name: "SW-4"
id: SW4
- platform: gpio
pin: GPIO17 #TX2
name: "SW-5"
id: SW5
- platform: gpio
pin: GPIO5 #D5
name: "SW-6"
id: SW6
- platform: gpio
pin: GPIO18 #D18
name: "SW-7"
id: SW7
- platform: gpio
pin: GPIO19 #D19
name: "SW-8"
id: SW8
INFO Reading configuration /config/esphome/n3.yaml…
INFO Starting log output from n3.local using esphome API
INFO Successfully connected to n3.local
[00:50:31][I][app:099]: ESPHome version 2021.10.3 compiled on Nov 8 2021, 10:56:40
[00:50:31][C][wifi:490]: WiFi:
[00:50:31][C][wifi:352]: Local MAC: 94:B9:7E:DA:37:04
[00:50:31][C][wifi:353]: SSID: [redacted]
[00:50:31][C][wifi:354]: IP Address: 192.168.0.102
[00:50:31][C][wifi:356]: BSSID: [redacted]
[00:50:31][C][wifi:357]: Hostname: ‘n3’
[00:50:31][C][wifi:359]: Signal strength: -54 dB ▂▄▆█
[00:50:31][C][wifi:363]: Channel: 1
[00:50:31][C][wifi:364]: Subnet: 255.255.255.0
[00:50:31][C][wifi:365]: Gateway: 192.168.0.1
[00:50:31][C][wifi:366]: DNS1: 192.168.0.1
[00:50:31][C][wifi:367]: DNS2: 0.0.0.0
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-1’
[00:50:31][C][switch.gpio:049]: Pin: GPIO15
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-2’
[00:50:31][C][switch.gpio:049]: Pin: GPIO2
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-3’
[00:50:31][C][switch.gpio:049]: Pin: GPIO4
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-4’
[00:50:31][C][switch.gpio:049]: Pin: GPIO16
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-5’
[00:50:31][C][switch.gpio:049]: Pin: GPIO17
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-6’
[00:50:31][C][switch.gpio:049]: Pin: GPIO5
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-7’
[00:50:31][C][switch.gpio:049]: Pin: GPIO18
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][switch.gpio:048]: GPIO Switch ‘SW-8’
[00:50:31][C][switch.gpio:049]: Pin: GPIO19
[00:50:31][C][switch.gpio:071]: Restore Mode: Restore (Defaults to OFF)
[00:50:31][C][logger:233]: Logger:
[00:50:31][C][logger:234]: Level: DEBUG
[00:50:31][C][logger:235]: Log Baud Rate: 115200
[00:50:31][C][logger:236]: Hardware UART: UART0
[00:50:31][C][captive_portal:150]: Captive Portal:
[00:50:31][C][ota:082]: Over-The-Air Updates:
[00:50:31][C][ota:083]: Address: n3.local:3232
[00:50:31][C][ota:086]: Using Password.
[00:50:31][C][api:134]: API Server:
[00:50:31][C][api:135]: Address: n3.local:6053
[00:50:31][C][api:139]: Using noise encryption: NO
[00:51:00][D][switch:013]: ‘SW-1’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-1’: Sending state ON
[00:51:00][D][switch:013]: ‘SW-2’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-2’: Sending state ON
[00:51:00][D][switch:013]: ‘SW-3’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-3’: Sending state ON
[00:51:00][D][switch:013]: ‘SW-4’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-4’: Sending state ON
[00:51:00][D][switch:013]: ‘SW-5’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-5’: Sending state ON
[00:51:00][D][switch:013]: ‘SW-6’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-6’: Sending state ON
[00:51:00][D][switch:013]: ‘SW-7’ Turning ON.
[00:51:00][D][switch:037]: ‘SW-7’: Sending state ON
[00:51:01][D][switch:013]: ‘SW-8’ Turning ON.
[00:51:01][D][switch:037]: ‘SW-8’: Sending state ON
[00:51:06][D][switch:017]: ‘SW-1’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-1’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-2’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-2’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-3’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-3’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-4’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-4’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-5’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-5’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-6’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-6’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-7’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-7’: Sending state OFF
[00:51:06][D][switch:017]: ‘SW-8’ Turning OFF.
[00:51:06][D][switch:037]: ‘SW-8’: Sending state OFF
[00:51:22][D][esp32.preferences:113]: Saving preferences to flash…
The log reflects the inverse of reality.