home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.17k stars 29.85k forks source link

Support HitachiAirToAirHeatPump (hlrrwifi:HLinkMainController) in Overkiz integration #85781

Closed Chris-NL closed 9 months ago

Chris-NL commented 1 year ago

The problem

I'm using the overkiz integration to integrate my Somfy Tahoma Pro box (firmware 2018.24.4.7). This has 2 positionable horizontal awnings, 2 sensors and 4 split unit air conditioners of Hitachi connected to it.

The overkiz integration adds the airco units as HitachiAirToAirHeatPump devices, but I only see one disabled entity for each airco (button.airco_1_start_identify). I can't seem to use them on any of the dashboard or automations.

I'm not sure if I'm doing something wrong, maybe there is a solution for the problem.

What version of Home Assistant Core has the issue?

2023.1.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

overkiz

Link to integration documentation on our website

https://www.home-assistant.io/integrations/overkiz

Diagnostics information

config_entry-overkiz-9a960f4ff17ee791f14ce8da40a9d67d.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Chris-NL commented 12 months ago

There's some serious improvement! Hopefully we're getting closer each time :)

When I clicked the auto mode button I got the error (I included the details from the log below): _[140240945708224] {'errorCode': 'UNSPECIFIEDERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'}

But clicking on cooling, dehumidify, fans, heat or off all work now. I also tested the fan speed: also works. There's also a function called "preset" with the values none or holiday mode. I can select holiday mode and I can also see a change in the Somfy app. I turned it on while the airco was cooling, nothing else happened, so I don't know what this function does.

So if you could get the auto mode to work I think we're there.

One other minor thing I wanted to mention is the screenshot below. Don't know if it has anything to do with testing, but the labels for the fields are some placeholders: image

From the logs: Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/overkiz/executor.py:91 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 09:10:29 (3 occurrences) Last logged: 09:18:19

[140240945708224] {'errorCode': 'UNSPECIFIED_ERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 227, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2006, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 210, in async_set_hvac_mode await self._global_control( File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 449, in _global_control await self._global_control_ovp( File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 373, in _global_control_ovp await self.executor.async_execute_command( File "/config/custom_components/overkiz/executor.py", line 91, in async_execute_command exec_id = await self.coordinator.client.execute_command( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 620, in execute_command response: str = await self.execute_commands(device_url, [command], label) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 648, in execute_commands response: dict = await self.post("exec/apply", payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 789, in post await self.check_response(response) File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 899, in check_response raise OverkizException(result) pyoverkiz.exceptions.OverkizException: {'errorCode': 'UNSPECIFIED_ERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'}

dotvav commented 12 months ago

It is encouraging and enraging at the same time. It looks like one of the parameters is the "target tempereature" in most of the modes, but when you swith to auto, this parameter becomes "temperature change" and needs to be an integer between -5 and +5. Do you have any idea what this value range could mean, is there any operation property that you can set to something beween -5 and +5?

I think I can find a way to keep the current operating "temperature change" hidden, but I wonder if this is something that can/should be controllable in HomeAssistant.

chabou-san commented 12 months ago

I know I'm kind of intervening from nowhere but I'm actually following actively this PR. :)

This "temperature change" range kind of makes sense regarding the behaviour we're getting from the remote controller @Chris-NL mentioned (that I also have). When using the "auto" mode, the system automatically target a temperature (I believe its 23°C, as seen as the target temperature from hi-kumo.com website), but I'm actually surprised by the range, as from the hi-kumo webapp, you can only change within 22 - 28°C (so the range is [-1;5]).

As a side note at home, I have 2 kind of remotes :

So I guess the behaviour you seem to try to understand is based on old devices from Hitachi where the range was different.

Regarding your last question, I have my opinion on this, but I'm not one to decide : HomeAssistant may not have to mimic exactly the behaviour of the devices it controls.

dotvav commented 12 months ago

Excellent @chabou-san. Thanks for commenting, that helps a lot.

I have just pushed an update that may (or may not) fix the issue. I am curious what HomeAssistant is going to show in the temperature gauge in case it works 🤞

Chris-NL commented 12 months ago

When I look at the Somfy App, there is a difference in temperature range between the auto mode and the other modes.

The auto mode allows me to select a temperature between 22 and 28 degrees. The other modes (except fans only mode, no range there) have a range between 16 and 32. Hope this helps.

What I also don't understand in the Auto mode is this: let's say the room temp is around 23 degrees and I want to cool it around this temperature. It could happen that the Airco switches itself into heating. I can turn the temperature down, but the airco doesn't switch from heating to cooling (only indicator for me when this happens is that the Somfy App shows me a red dot instead of a darkblue dot). To resolve this issue I have to switch the airco off. Set a lower desired temperature (21 degrees for example), turn is back on in auto mode and increase the temp back to 23. I think this defeats the whole idea of auto function, but apparently this is how Hitachi designed it. And it's even worse if another one of the split units is still on, then I have to turn them all of first to switch the unit from heating to cooling. But I'm so used to set it to auto, don't know why though :)

For your update. Still doesn't work. No functional change, still an error on the Auto function. The logs give me: Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/overkiz/executor.py:91 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 12:47:07 (1 occurrences) Last logged: 12:47:07

[140620537931200] {'errorCode': 'UNSPECIFIED_ERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 227, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2006, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 210, in async_set_hvac_mode await self._global_control( File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 449, in _global_control await self._global_control_ovp( File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 373, in _global_control_ovp await self.executor.async_execute_command( File "/config/custom_components/overkiz/executor.py", line 91, in async_execute_command exec_id = await self.coordinator.client.execute_command( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 620, in execute_command response: str = await self.execute_commands(device_url, [command], label) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 648, in execute_commands response: dict = await self.post("exec/apply", payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 789, in post await self.check_response(response) File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 899, in check_response raise OverkizException(result) pyoverkiz.exceptions.OverkizException: {'errorCode': 'UNSPECIFIED_ERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'}

dotvav commented 12 months ago

Apologies, I had not properly synced my change. You can try again now.

Chris-NL commented 12 months ago

No luck, same status.

Logbook: Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/overkiz/executor.py:91 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 17:10:00 (1 occurrences) Last logged: 17:10:00

[140538794265408] {'errorCode': 'UNSPECIFIED_ERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 227, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2006, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 211, in async_set_hvac_mode await self._global_control( File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 465, in _global_control await self._global_control_ovp( File "/config/custom_components/overkiz/climate_entities/hitachi_air_to_air_heat_pump.py", line 389, in _global_control_ovp await self.executor.async_execute_command( File "/config/custom_components/overkiz/executor.py", line 91, in async_execute_command exec_id = await self.coordinator.client.execute_command( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 620, in execute_command response: str = await self.execute_commands(device_url, [command], label) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry ret = await target(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 648, in execute_commands response: dict = await self.post("exec/apply", payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 789, in post await self.check_response(response) File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 899, in check_response raise OverkizException(result) pyoverkiz.exceptions.OverkizException: {'errorCode': 'UNSPECIFIED_ERROR', 'error': 'Managed action group is invalid : When setting auto ModeChangeState, TemperatureChangeState should be an integer, included in [-5;5]'}

dotvav commented 12 months ago

OK. I am not able to debug this here. It would help if you (@Chris-NL or @chabou-san) could join the Discord server and/or ping me there (username dotvav). I can let you know how and what http traffic to capture with your browser and then share with me, and we can make a few tests. That would allow me to observe the real command parameters instead of trying to guess (and failing).

chabou-san commented 12 months ago

I could, but I’m on hlrr protocol, not ovp. So I can’t reproduce the errors @Chris-NL is having.

dotvav commented 12 months ago

I could, but I’m on hlrr protocol, not ovp. So I can’t reproduce the errors @Chris-NL is having.

Alright. I have hlrr too and I can test my own devices. Don't hesitate to test yours too and let me know if you find any bug.

I have talked with @iMicknl and we think these 2 protocols are too different, after all, and they don't belong together in the same class file. It makes development and support unnecessarily complex. We can deliver support for hlrr earlier without clubbing it with ovp, and we can work on ovp support shortly. I'll keep this thread informed on the progress, but it might take some time (because I need to travel for work) and I don't think it will be done in time for the October release of HA.

@Chris-NL if Discord doesn't work for you, please let me know if there is a medium (instant messaging, bulletin board) where we can connect privately to share information that don't belong in this thread.

Chris-NL commented 12 months ago

All sounds plausable.

I had to create an account with discord and I've send you a friendship invite through it last Sunday, no response yet. Not familiar with Discord, maybe I'm doing something wrong.

dotvav commented 12 months ago

Updating this thread. @Chris-NL and I have made a lot of progress "offline". I think we have the protocol almost figured out, and a version of the component that doesn't crash. But it is still missing an important feature: changing the temperature in HA when the mode is AUTO. In particular, we might be able to figure out what the "pivot" temperature is on his device (seems to be 23), but I don't know if it is the same on all the (OVP) devices.

dotvav commented 11 months ago

Hi @Chris-NL. When you have a moment, please test this integration again on your device and let me know if you find an issue.

jkrasinger commented 11 months ago

Hi, thank you to all which are actively working to solve or better, add some additional features to the "overkiz" implementation for HA. Until now i am using the aasivak add-on, but as i prefer using the integrations in HomeAssistant i tried overkiz again and found, that it does not create a climate entry in HomeAssistant for my RAK-50PEDC. After finding this issue i tried again with the latest fix #95706 and, hurray, a climate entry was created successfully and is working for HLRR. Great. As i can now compare "aasivak" with "overkiz" i found one interesting difference. if the heater is turned off and I change the target temperature, then the heater is also turned on in "overkiz", but not in "aasivak". In aasivak only the target temperature changes. @dotvav : Is this intentional, coincidence or a bug?

dotvav commented 11 months ago

Thanks for the feedback @jkrasinger. The difference that you are observing is totally unintentional from my part. It is hard to tell right now if one option is better than the other, or if there are solid expectations. It makes me curious so I'll have a look and see if that could be the sign of a hidden bug.

Regarding the HA integration, I'd love to have it in the next release cycle. I'm pretty confident about HLRR so I'll try to get that out. OVP needs more work and if I don't finish it in the next few days, I will extract it from this PR and submit it again later when it works.

jkrasinger commented 11 months ago

@dotvav : Thank you for the quick reply. I am curious if the code will be implemented in the next release cycle, would be very nice, then I could remove the add-on again and use overkiz. As for the difference between overkiz and aasivak it would be good for me personally if the behavior was the same, but is not really important. I would then have to change a little code in my ESP32 remote control (via MQTT and HA) for the air conditioning. Thanks again for your work!

dotvav commented 11 months ago

@jkrasinger I have found the root cause of the discrepancy. The code is a little bit more consistent with the fix, so it's a good thing.

@Chris-NL I have refactored the code and possibly elminated the bug you have encountered. Feel free to test again.

jkrasinger commented 11 months ago

@dotvav I agree with you that this is a good thing. But there is one more question to this behaviour: if the heater is off and i change the target-temperature, what (mode) will be switched on, the "heater", the "cooler" or the "dryer"? Is there a specification for this, is this depending on temperature (like any automatic state) or whatever? Do you have an answer? As i'm only using the heater and never the cooler this is of real interest for me. Thanks

dotvav commented 11 months ago

Hi @jkrasinger, there is no specification. And there is no reason that the unit should change state (ON/OFF) or mode (cool, heat, dry...) when someone changes the target temperature. There was a bug in the overkiz integration that was forcing the unit to ON when one would change any other value. I have fixed it.

Now, there is a major difference between the way HA and Overkiz are managing climate entities. Overkiz allows the main operation state (ON/OFF) and the hvac mode (cool, heat, dry...) to be managed independently, while HA considers both a single sate (off, cool, heat, dry...). But that doesn't force us cut too many corners, and changes to the target temperature, fan speed or swing mode should not turn the unit ON anymore.

jkrasinger commented 11 months ago

Hi @dotvav thank you for the good news, sounds perfect. I will again take a closer look for me on the behavior with my ESP32 Box and my "pyscripts" :+1:

jkrasinger commented 11 months ago

Hi @dotvav .... i just reloaded the integration with #95706 and now it behaves exactly as before with "aasivak". Thank you very much for the perfect and quick work and responses. Now i will wait for the release of this patch without any hurry. :+1: :+1:

dotvav commented 11 months ago

Hi there,

The first PR, that will bring support for HLRRWIFI devices, is in review here: PR 95706. Hopefully, we manage to get it in the next release.

I have also been working on the OVP protocol on a separate branch: https://github.com/dotvav/home-assistant-core/tree/overkiz-hitachi-air-heat-pump-ovp . It still requires some testing, but I should be able to make another PR soon out of it.

dotvav commented 10 months ago

Hi @Chris-NL, we spoke on Discord and thank you for the testing. For tracking purpose and for clarity, can you confirm if the OVP devices are working as expected with this PR https://github.com/home-assistant/core/pull/102159 ? If you have found some issues, can you summarize what the behavior is that you observe versus what you expect?