thomasgermain / vaillant-component

Multimatic integration for Home Assistant (also compatible with sensoAPP)
MIT License
136 stars 24 forks source link

QM_COOLING_FOR_X_DAYS return unknown error #60

Closed muckil closed 3 years ago

muckil commented 3 years ago

I use your integration for a year. After you released the cooling feature I want to add this in my homeassistant. But I do not get it running.

At the moment I run the version 1.6.2. With other versions it does not run with other versions either.

If I want to set the quick mode for QM_COOLING_FOR_X_DAYS with this service call:

service: multimatic.set_quick_mode data: quick_mode: QM_COOLING_FOR_X_DAYS

I get this error message in the UI:

Failed to call service multimatic.set_quick_mode. Unknown error

See the attached traceback of the homeassistant log:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 25, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 525, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1216, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 350, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 368, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 568, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service await handler.job.target(service_call) File "/config/custom_components/multimatic/service.py", line 99, in service_call await method(data=call.data) File "/config/custom_components/multimatic/service.py", line 123, in set_quick_mode await self._hub.set_quick_mode(quick_mode) File "/config/custom_components/multimatic/hub.py", line 325, in set_quick_mode await self._manager.set_quick_mode(qmode) File "/usr/local/lib/python3.8/site-packages/pymultimatic/systemmanager.py", line 195, in set_quick_mode await self._call_api( File "/usr/local/lib/python3.8/site-packages/pymultimatic/systemmanager.py", line 664, in _call_api return await self._connector.request(method, url, payload) File "/usr/local/lib/python3.8/site-packages/pymultimatic/api/connector.py", line 171, in request raise ApiError('Cannot ' + method + ' ' + url, response=resp, pymultimatic.api.error.ApiError: Cannot put https://smart.vaillant.com/mobile/api/v4/facilities/{SERIALNUMBER}/systemcontrol/v1/configuration/quickmode

I removed the serialnumber from the API call with {SERIALNUMBER} Other Quick modes work.

I hope you can help me or give a hint how to use this quick mode

thomasgermain commented 3 years ago

Hello,

thanks for reporting the issue, I will improve the log in the next release, I will add the response payload.

Do you have the option (QM_COOLING_FOR_X_DAYS) through the mobile app ?

thomasgermain commented 3 years ago

I'm receiving {"errorCode":"INVALID_PARAMS"}, status: 400.

Now I'm not sure if this is because I don't have any cooling system or because QM_COOLING_FOR_X_DAYS has changed for something else, I will investigate

muckil commented 3 years ago

Hello,

thank you for your quick Response.

I have attached some Screenshots in german language. I hope this can help you.

Yes, I have the Option through the mobile app. In german it is called "manuelles kühlen".

Screenshot_20210610-125530_VRC 700

After I select the mode, there is a selection menu where I have to determine for how many days I want to activate the Option.

Screenshot_20210610-125537_VRC 700

thomasgermain commented 3 years ago

Hmm ok, it will take some times, I will have to decompile the android apk to see what is the new technical name for QM_COOLING_FOR_X_DAYS and then release a new version

thomasgermain commented 3 years ago

I checked the APK and as far as I can see, this is still QM_COOLING_FOR_X_DAYS, so I don't know why the API is giving an error. If you know how to do, it would be great to have the API response for https://smart.vaillant.com/mobile/api/v4/facilities/{serial}/systemcontrol/v1/configuration/quickmode while you have this quick mode enable

muckil commented 3 years ago

Hi, I don't know if you mean something like this. I ran your pymultimatic API with this command:

    async with aiohttp.ClientSession() as session:
        connector = Connector(user, passw, session)
        # get information about quickmode
        response = await connector.request('get', urls.system_quickmode(serial=SERIAL))
        print(response)

I get this as response:

{'body': {'quickmode': 'QM_COOLING_FOR_X_DAYS', 'duration': 2}, 'meta': {'resourceState': [{'state': 'SYNCED', 'timestamp': 1623421463084, 'link': {'rel': 'self', 'resourceLink': '/facilities/{SERIALNUMBER}/systemcontrol/v1/configuration/quickmode'}}]}}

Just for your information. I noticed that if no Quickmode is enabled I get this:

Traceback (most recent call last):
  File "/home/ide/pymultiMATIC/multi.py", line 35, in <module>
    asyncio.get_event_loop().run_until_complete(info())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/home/ide/pymultiMATIC/multi.py", line 29, in info
    response = await connector.request('get', urls.system_quickmode(serial=SERIAL))
  File "/home/ide/pymultiMATIC/pymultimatic/api/connector.py", line 165, in request
    return await self.request(method, url, payload)
  File "/home/ide/pymultiMATIC/pymultimatic/api/connector.py", line 172, in request
    payload=payload)
pymultimatic.api.error.ApiError: Cannot get https://smart.vaillant.com/mobile/api/v4/facilities/{SERIALNUMBER}/systemcontrol/v1/configuration/quickmode

Let me know if I can support you with some API calls or something else.

thomasgermain commented 3 years ago

Ok so this is really strange, because I'm able to set all quick mode but if I try for QM_COOLING_FOR_X_DAYS I receive an HTTP 400 (I also tried setting a duration in day, but no luck).

By the way, do you have a VRC700 or VRC720 ? (It sounds the integration is not working with VRC720)

muckil commented 3 years ago

Hi,

sry for late responding. I have a VRC721.

Do you have a code snippet for setting the mode through pymultiMATIC? Maybe with the option to set the duration. Something like my last post.

I'll try it against my VRC directly.

Another idea: Is there a simple solution to get the API call from the app, when I activate the QM_COOLING_FOR_X_DAYS ?

Thank you in advance

thomasgermain commented 3 years ago

I think I got it. You can check branch get_rooms from pymultimatic repo (ok, name is really bad :sweat_smile:). It should provide a fix to set the duration correctly (I was parsing it to a str,don't know why).

Here is a small example:

manager = ...
print(await manager.set_quick_mode(QuickModes.get('QM_COOLING_FOR_X_DAYS', 2)))
print(await manager.get_quick_mode())
muckil commented 3 years ago

Wonderful. That works. I am looking forward to the next release.

Thank you very much. That makes this integration even better.

thomasgermain commented 3 years ago

here is the next release: https://github.com/thomasgermain/vaillant-component/releases/tag/1.7.0b3

thomasgermain commented 3 years ago

Let me know if you still have the issue

thomasgermain commented 3 years ago

version 1.7.0 is out and I'm doing some cleaning, please open an new issue if you still have trouble.