ESPAltherma icon indicating copy to clipboard operation
ESPAltherma copied to clipboard

Inverted switch

Open xalex75 opened this issue 2 years ago • 7 comments

Hi. I don't now why, but when the switch is off in HA, the relay is on, if I change the switch to on, relay goes off. I can't change it directly in the relay, how can I invert it in ESPAltherma? Thanks.

xalex75 avatar Aug 09 '22 19:08 xalex75

There are 2 types of relay:

  • NC for normally closed (when off)
  • NO for normally opened (when off)

You probably have a NC one. But have a look as some has 2 possible mode/connectors.

I would advice against using NC, but as a failure would turn your heat pump always on...

If you still want to invert the mode, just replace all HIGH to LOW and vice versa where you see digitalWrite(PIN_THERM,

raomin avatar Aug 09 '22 21:08 raomin

It has a jumper, but if I move it, it doesn' switch anymore. So I think that changing it in code would be better, or change relay. Thank you, I will try.

Edit: my relay will not be used to turn on/off heating, but to put the machne in summer mode during the winter nights (so it just does ACS if needed), so a failure should be a smaller problem. Can I please ask you in which files is that? I only found a "digitalWrite(PIN_THERM, HIGH);" in main.cpp, changed it to LOW and reflashed, but looks nothing changed. Sorry, first time playng with platformio and VSC

xalex75 avatar Aug 10 '22 08:08 xalex75

I bought new relay, I prefer not changing code too much, so fure update will be easier. It will arrive tomorrow, I hope that it will act correctly 😉

xalex75 avatar Aug 10 '22 12:08 xalex75

Hi. New different relays arrived, but these are active in inverted mode too. When switch is on they are off and viceversa. I think that I will create an inverted template switch in HA, if I'm the only one experiencing this.

xalex75 avatar Aug 11 '22 10:08 xalex75

Hi @xalex75 Can you share your link to/picture of the module you bought. Normally they all have 3 wire connector: one for the NC, one for the NO (and one for the COM)

raomin avatar Aug 14 '22 07:08 raomin

Turn it around and check. F11896AF-6817-4A43-9098-C7AF59A20EA9

DieterTHeck avatar Aug 14 '22 09:08 DieterTHeck

Hi. I think there's a misunderstanding. I know that I can use NC o NO contacts. What I mean is the tin my case when switch.alterma is off, the relay is active, when it's on, the relay is not active. Maybe it depends on the gpio used on Esp32 cam, I don't know, but I fixed that with a switch template in HA that has inverted state compared to switch.altherma.

IMG_20220815_111803

There seems to be some inconsistency after reboots, but I have to check it better.

xalex75 avatar Aug 15 '22 09:08 xalex75

I'm still trying to use the switch in a reliable way. Let's start from a situation with relay off. When I reboot HA, the switch is in unknown state: image

and the switch button in lovelace is shown as off. If I click it, the entity state changes from unknown to off, and in lovelace it correctly shows it as off, but the relay goes on. If I click it again, lovelace shows it as on, and the relay goes off.

I created a template switch with inverted behavior compared to switch.altherma, and it would work if it was not for the unknown state after reboot, that makes the visible state in lovelace ureliable.

I'll try to get around this by testing the unknown state and activating automatically it one time to get the real state, it should work, but it look that there's some sort of malfunction in the switch part.

I notices thet in MQTT devices I see only althermasensor, not the switch. Is this correct? Thanks.

xalex75 avatar Aug 21 '22 10:08 xalex75

Ok, this is working for me. I tried to reboot with relay on and off and it keeps the state across reboots. "unknown" tate at boot is automatically changed to previous state.

https://pastebin.com/mnDK6tuG

xalex75 avatar Aug 21 '22 12:08 xalex75

So, all ok now @xalex75, I can close this?

raomin avatar Sep 29 '22 16:09 raomin

Hi. Yes, I managed it in Home Assistant. Thanks.

xalex75 avatar Sep 30 '22 06:09 xalex75