Crewski / njsPC-HA

Home Assistant integration for nodejs-PoolController
29 stars 6 forks source link

Cannot set heater mode from HA #8

Closed FlaMike closed 1 year ago

FlaMike commented 2 years ago

I am using your HA integration along with the nodejs-poolController version 7.7.0 along with Home Assistant version 2022.10.5. I am not able to change the heat mode from the HA UI. When I switch the heat mode from Off to Heat using the climate.pool-heater entity in the HA UI, it changes back immediately to Off, even though the setpoint for the heater is above the current water temperature.

If I change the heat mode from Off to Heat in the poolControllerDashboard UI, the heater behaves as expected.

Is there a way to change the heat mode from within Home Assistant?

Thank you!

Crewski commented 2 years ago

Hey @FlaMike , it's most likely because your heater is expecting values of 0 for off and 1 for on (someone else has the same issue on the HA forum). When I set it up for my equipment, 1 was off and something else was on. I need to thumb through the code to figure out how to fix it......I've just been busy with other stuff so haven't had a chance yet. I hope to get to it soon.

FlaMike commented 2 years ago

Thank you for your quick response! It's not a big issue for me at the moment--too darned cold to swim for my taste. And I can toggle the heater mode using the Dashboard should we have a heat wave that motivates me to swim :-)

Whenever you're able to get a fix out there, I will certainly take care advantage of it. I wanted to make sure I wasn't doing anything that was causing the problem in my instance.

If you need a beta tester for the fix or there is something I can do to assist you, please let me know.

Thanks again for your quick reply & very much appreciated HA integration!!!

Crewski commented 1 year ago

@FlaMike I just pushed out v0.4.0 that hopefully will fix your issue. Let me know if it works....assuming you aren't closed for the season (I'm in Ohio so mine's been closed since mid-October).

FlaMike commented 1 year ago

I updated to 4.0 through HACS, restarted HA and reloaded the HA integration. Unfortunately, the heater control still follows whatever is set in the nodejs-poolcontroller console (at port 5150). If the heater is off at the console and I turn it on in the HA dashboard, it flips back off just like it did previously. If the heater is on in console, I can't turn it off via the HA dashboard (it flips back on).

The pool isn't closed for the winter, although I've not used it for months due to cold weather after the hurricanes (we were not affected by the storms, at least). This past weekend, we gave the freeze protect circuit quite a workout--it was in the 20s for 3-4 days. I'm in the Panhandle, not south Florida. Pool water temp is currently 47--a long way for the heater to make it swim friendly.

If I can help you with debugging or additional testing, please let me know.

Where in Ohio are you located? I grew up in Cleveland & we moved to Florida about 12 years ago from Columbus.

Thanks for your help!

Crewski commented 1 year ago

We were down in Indian Rocks Beach right before Christmas. It turned pretty cold right after we left.....granted I was greeted with -8 deg when I got back to Cincinnati (born and raised).

Maybe I made the wrong assumption of what your equipment is. Can you post your response to http:<njspc_ipaddress>:4200/config/options/heaters/. You can use Postman or just simply put it in the address bar of your browser.

FlaMike commented 1 year ago

Sorry you had a chilly Indian Rocks Beach getaway. Tough weather for most of the country.

Below is the response to the query. If there's anything else I can help with, please let me know.

{"tempUnits":{"val":0,"name":"F","desc":"Fahrenheit"},"bodies":[{"val":0,"name":"pool","desc":"Pool"},{"val":1,"name":"spa","desc":"Spa"},{"val":32,"name":"poolspa","desc":"Pool/Spa"}],"maxHeaters":16,"heaters":[{"id":1,"isActive":true,"portId":0,"body":32,"type":1,"master":0,"name":"Gas Heater","cooldownDelay":5}],"heaterTypes":[{"val":0,"name":"none","desc":"No Heater","hasAddress":false},{"val":1,"name":"gas","desc":"Gas Heater","hasAddress":false},{"val":2,"name":"solar","desc":"Solar Heater","hasAddress":false,"hasPreference":true},{"val":3,"name":"heatpump","desc":"Heat Pump","hasAddress":true,"hasPreference":true},{"val":4,"name":"ultratemp","desc":"UltraTemp","hasAddress":true,"hasCoolSetpoint":true,"hasPreference":true},{"val":5,"name":"hybrid","desc":"Hybrid","hasAddress":true},{"val":6,"name":"maxetherm","desc":"Max-E-Therm","hasAddress":true},{"val":7,"name":"mastertemp","desc":"MasterTemp","hasAddress":true}],"heatModes":[{"val":0,"name":"off","desc":"Off"},{"val":1,"name":"heater","desc":"Heater"}],"servers":[],"rs485ports":[{"portId":0,"enabled":true,"rs485Port":"/dev/ttyUSB0","mockPort":false,"netConnect":false,"netHost":"raspberrypi","netPort":9801,"inactivityRetry":10,"portSettings":{"baudRate":9600,"dataBits":8,"parity":"none","stopBits":1,"flowControl":false,"autoOpen":false,"lock":false},"name":"Primary","isOpen":true}]}

FlaMike commented 1 year ago

Just re-read your post. Looks like you squeaked at Indian Rocks & then cooled way down back home. Never been to Indian Rocks, but we do love the Gulf Coast. I'm in Santa Rosa Beach, between Panama City & Destin. About as far north as you can be on the Gulf Coast. Superb beaches, though, just not for swimming in January :-)

Crewski commented 1 year ago

Its weird because when I try to mimic your setup, I get 1 as being Off and 2 as being Heater. Oh well.

In your custom component folder for njspc_ha, in climate.py replace the async_set_hvac_mode (should be line 243) with the following:

    async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
        if len(self._heatmodes) <= 2:
            njspc_value = None
            if hvac_mode == HVACMode.OFF:
                njspc_value = next(
                    (k for k, v in self._heatmodes.items() if v.lower() == "off"), None
                )
            else:
                njspc_value = next(
                    (k for k, v in self._heatmodes.items() if v.lower() != "off"), None
                )
            if njspc_value is None:
                self.coordinator.logger.error(
                    "Invalid mode for set_hvac_mode: %s", hvac_mode
                )
                return
            data = {"id": self._body["id"], "mode": njspc_value}
            await self.coordinator.api.command(url=APT_SET_HEATMODE, data=data)
        return

If it works, I'll push it to the repository. Make sure to reboot after the change.

FlaMike commented 1 year ago

You are the man! Works like a champ!! I turned on the heater for, oh, 10 seconds or so & then turned it off. All looks good for a push to the world. The heater mode is reflected instantly in the poolcontroller dashboard (at ipaddress:5150).

If you want me to run the heater for longer, I can do so. Previously, it flipped to off in less than a second. Same when turning it on and the dashboard never updated.

Thank you so much for fixing this and making your integration available to the world. Like the pool controller software itself, it's a real gem and appreciated greatly!!

I have one other observation to share. I think this is either a Pentair intellichlor issue or possibly the poolcontroller folks. I have a current setpont for the salt generator of 8% (the water is cold after all and the pool isn't being used). The reported value of the cell's generation is also 8%. However, because the water is cold (about 47), the cell is shut down and the output should be zero, I believe. The pc-dashboard shows 8% output. I should verify what the EasyTouch panel says, although I don't know if it's available information on the actual controller. Anyway, kind of weird. Any thoughts/opinions/suggestions are welcome.

Thanks again for all!

Crewski commented 1 year ago

Glad we got it fixed. No need to run it longer, if it didn't change back right away it should be good.

Not sure on the SWG output, but it's definitely a question for the nodejs-PoolController guys since its showing 8% in dashpanel as well. Sorry I'm not of help on that issue.

I'll push the update and close this issue.