I have a 8 port switching relay bank for DC circuits, connected to a 30 pin ESP32 dev board. The relays are powered by an independent 5V supply. On startup, the relays are powered, but HA shows the state as “off”. Turning “on” the switches in HA shows their state as "on, but the relays turn off. Setting inverted: True causes the relays to work correctly (i.e., the relays only allow loads to function when switched “on” in HA) but HA logs show the state now to be “off”.
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?
Oh you were clear about the problem, perhaps I didn’t clearly enough say that I was particularly directing you at point 12, formatting your code in the post. Looks good now.
OK. Cool! Thanks so much! Will that have any effect on automations that rely on a State? I haven’t even started on automations yet, but am wondering if “If “on” (or “off”) do …” will behave properly.