raomin / ESPAltherma

Monitor your Daikin Altherma / ROTEX heat pump with ESP32
MIT License
359 stars 121 forks source link

Inverted switch #124

Closed xalex75 closed 2 years ago

xalex75 commented 2 years ago

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.

raomin commented 2 years ago

There are 2 types of relay:

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,

xalex75 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

raomin commented 2 years ago

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)

DieterTHeck commented 2 years ago

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

xalex75 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

raomin commented 2 years ago

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

xalex75 commented 2 years ago

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