Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing preset in ViCare integration fails when device provides presets that are not supported by HA #128034

Closed
noseshimself opened this issue Oct 9, 2024 · 30 comments · Fixed by #128167

Comments

@noseshimself
Copy link

The problem

If you read out the states of climate.cu401b_s_heizung

you will find the attributes

preset_mode: home
vicare_programs: comfort, eco, fixed, normal, reduced, standby
active_vicare_program: normal

If you use the Home Assistant controls, the Vicare app or the control panel of the heating to change the mode to any other setting and try to set it back to "Home" again using Home Assistant in

image

you will get the pop-up

image

and the heating seems to be drunk until turned off and on again (seems that Viessmann's plausibility checks in their controller software are not that good either).

  1. Bug: It seems that "normal" and "fixed" were confused.

  2. If you really intended to use "fixed": Fixed requires (according to the controller manuals for ModBUS communication) that an additional parameter has to be set; if it remains unset "it fails". Easy observation: It does something but not what you intended it too.

What version of Home Assistant Core has the issue?

core-2024.10.1

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

ViCare

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Oct 9, 2024

Hey there @CFenner, mind taking a look at this issue as it has been labeled with an integration (vicare) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of vicare can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign vicare Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


vicare documentation
vicare source
(message by IssueLinks)

@CFenner
Copy link
Contributor

CFenner commented Oct 9, 2024

Can you please activate the debug logging, reproduce the issue and share the logs.

@noseshimself
Copy link
Author

caught it

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:245
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 16:35:57 (1 occurrences)
Last logged: 16:35:57

[546284955408] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 1029, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 742, in async_set_temperature
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/vicare/climate.py", line 287, in set_temperature
    self._api.setProgramTemperature(self._current_program, temp)
  File "/usr/local/lib/python3.12/site-packages/PyViCare/PyViCareHeatingDevice.py", line 411, in setProgramTemperature
    return self.service.setProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}",
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PyViCare/PyViCareCachedService.py", line 29, in setProperty
    response = super().setProperty(property_name, action, data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PyViCare/PyViCareService.py", line 58, in setProperty
    return self.oauth_manager.post(url, post_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 93, in post
    self.__handle_command_error(response)
  File "/usr/local/lib/python3.12/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 70, in __handle_command_error
    raise PyViCareCommandError(response)
PyViCare.PyViCareUtils.PyViCareCommandError: (PyViCareCommandError(...), 'Command failed with status code 400. Reason given was: VALIDATION_ERROR')

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:245
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 16:36:14 (8 occurrences)
Last logged: 17:24:40

[546284955408] Unexpected exception
[546267010320] Unexpected exception
[546266205344] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 800, in async_handle_set_preset_mode_service
    await self.async_set_preset_mode(preset_mode)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 808, in async_set_preset_mode
    await self.hass.async_add_executor_job(self.set_preset_mode, preset_mode)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/vicare/climate.py", line 297, in set_preset_mode
    target_program = HeatingProgram.from_ha_preset(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/vicare/types.py", line 51, in from_ha_preset
    if VICARE_TO_HA_PRESET_HEATING.get(HeatingProgram(program)) == ha_preset:
                                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'fixed' is not a valid HeatingProgram

Didn't they announce quite a few changes in their data points? I'm already wondering why I'm getting quite a few things in the ViCare app that Home Assistant does not show (return temperatures of the heating, energy consumption of the heat pump but also data about gas burner run times and its energy consumption).

@CFenner
Copy link
Contributor

CFenner commented Oct 9, 2024

So, the first error message is about set_temperature, how is that related to the error. I thought it's just about the preset/mode.

Also from the second log I do not get much information. Please go into "protocols", filter for vicare and click on "show full log" and share that.

Looks like your active preset/program is fixed. Can you confirm that?

@CFenner
Copy link
Contributor

CFenner commented Oct 9, 2024

I'm already wondering why I'm getting quite a few things in the ViCare app that Home Assistant does not show (return temperatures of the heating, energy consumption of the heat pump but also data about gas burner run times and its energy consumption).

The App uses another API (or at least not the basic plan) to access the values. Not all values that you see there (e.g. Abgasthemperatur) are listed in the public api. But electricity and gas consumption, burner runtimes, etc. should all work in HA.

@alex1255
Copy link

alex1255 commented Oct 10, 2024

Hello, I have the same problem and can't switch modes with HA.
I switched on debug and tried switching to "sleep" once. Unfortunately I got the error message described above.

I can't switch anything else either, or the values ​​reset after a short time!

Best regards
Alex

@CFenner
Copy link
Contributor

CFenner commented Oct 10, 2024

@alex1255 can you switch to debug mode, repeat the error and send the logs again?

@alex1255
Copy link

alex1255 commented Oct 10, 2024

Hello. Yes, no problem, but I just did that ;-). Or do you mean something else? Here is the error message in the GUI:
vicare-log.log

Bildschirmfoto 2024-10-10 um 10 50 38

@CFenner
Copy link
Contributor

CFenner commented Oct 10, 2024

I would at expect at least on log output containing the word debug 😉

You activate the debug mode on the integration in the devices & services view. Just checking on my side, so I can show you what I mean.

@CFenner
Copy link
Contributor

CFenner commented Oct 10, 2024

Bildschirmfoto 2024-10-10 um 11 07 35

@alex1255
Copy link

Yes, exactly in the integration! First switch it on, then switch it on, then switch it off again. Then Chrome automatically downloads the log file! That must be it, right?

@alex1255
Copy link

sorry for my English, here is a better version ;-)
First switch on debug, then the switching process and then switch debug off again.

@noseshimself
Copy link
Author

Looks like your active preset/program is fixed. Can you confirm that?

Yes. And the Home Assistant setting "Home" should probably be assigned "normal", not "fixed". According to my information (for controlling the heating using ModBUS) "fixed" requires additional settings and is meant to not use any intelligence but nailing the temperature to a certain value independent of other sensors (like outside temperature). If the prerequisite settings have not been made it will result in an error. And the heating behaves... strangely.

@alex1255
Copy link

Hi,
No, I can't confirm that. The heating is currently running normally via an internal timer. So it's automatic!
By the way, it's a Vitodens 300-W B3HA 19KW.

@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

Ah, I think I spotted the issue, but need to pickup my kids now... I hope I can have a look into it this evening.

@noseshimself
Copy link
Author

Gut

Ah, I think I spotted the issue, but need to pickup my kids now...

As long as we keep our fingers off the presets in Home Assistant, all is fine. It's a real low-prio bug.

But I still believe, all you have to do is select a different preset.

@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

@home-assistant rename Changing preset in ViCare integration fails when device provides presets that are not supported by HA

@home-assistant home-assistant bot changed the title ViCare Integration: Preset mode "home" does not exist and causes problems when applied using this integration (at least with a CU401B aka Vitocaldens 222-F) Changing preset in ViCare integration fails when device provides presets that are not supported by HA Oct 11, 2024
@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

@noseshimself @alex1255 could you verify the change as my heating does not provide unsupported presets?

@alex1255
Copy link

OK - was genau soll ich machen?

@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

Du brauchst das Terminal Add-on.

Im terminal gibst du den code ein:

curl -o- -L https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d vicare -p 128167

Dann einmal neu starten und ausprobieren.

Um das Ganze wieder zu entfernen, gibst du rm -d custom_componenets/vicare (glaube ich).

@alex1255
Copy link

Sieht gut aus! Es scheint keine Fehler mehr zu geben und ich kann die Voreinstellungen schalten. Nur die Anzeige ist sehr träge in HA. Ich der ViCare App auf dem Handy zeigt es dann sofort an....
Du bist ein Held :-)
Das kann ich jetzt so lassen oder?
Danke für die schnelle Hilfe!
Alex
Looks good! There don't seem to be any more errors and I can switch the default settings. Only the display is very slow in HA. The ViCare app on my phone shows it immediately....
You're a hero :-)
I can leave it like that now, right?
Thanks for the quick help!
Alex

@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

Du hast jetzt eine lokale Kopie der vicare integration in custom_components, dies überschreibt die built-in integration. Du kannst das jetzt so lassen. Sobald der fix live ist, solltest du es aber löschen um nicht vom aktuellen Stand abgehängt zu sein.

@alex1255
Copy link

Ach noch was: Weißt du ob "ECO Mode" dann das selbe wie "reduced" ist?

@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

Nur die Anzeige ist sehr träge in HA.

Ja, leider, der richtige Wert wird erst mit dem nächsten update von der API angezeigt. Hier sollten wir einen assumed state einbauen, damit erstmal das, was gerade über die API gesetzt wurde, auch sofort angezeigt wird.

@alex1255
Copy link

das wäre toll - ja. Auf jeden Fall verwirrt es nicht so sehr wie jetzt....

@CFenner
Copy link
Contributor

CFenner commented Oct 11, 2024

Ach noch was: Weißt du ob "ECO Mode" dann das selbe wie "reduced" ist?

Da bin ich leider nicht sicher. Es sind zwei unterschiedliche modi in vicare.

Ich habe erstmal die Vicare presets wie folgt auf die HA presets gemappt:

comfort / comfort heating == comfort
eco == eco
normal / normal heating == home
reduced / reduced heating == sleep

@alex1255
Copy link

Perfekt! Dann kann ich mir jetzt endlich meine Timer in HA dazu basteln :-) Danke für die abschließende Info über das mapping.

@noseshimself
Copy link
Author

noseshimself commented Oct 11, 2024

comfort / comfort heating == comfort
eco == eco
normal / normal heating == home
reduced / reduced heating == sleep

But...

The ViCare app is only offering "normal", "reduced" and "fixed" for the CU401-B. "eco" will become active depending on the choice between "economical" and "ecological" (i.e. the controller will choose between gas burner and heat pump based on energy cost or efficiency).

"active" seems to have something to do with "party mode". But I'd really like to know what "fixed" is intended for, "standby" seems to be a frost protection mode . Take a look yourself...

config_entry-vicare-98e7148db7bf163fc7c57b56b369fe63.json

And while we're at it: Why are not all of the interesting data points handed over to Home Assistant? Example: According to the config entry ViCare is reporting data about the gas burner like

         {
            "apiVersion": 1,
            "commands": {},
            "deviceId": "0",
            "feature": "heating.burners.0.statistics",
            "gatewayId": "################",
            "isEnabled": true,
            "isReady": true,
            "properties": {
              "hours": {
                "type": "number",
                "unit": "hour",
                "value": 2591
              },
              "starts": {
                "type": "number",
                "unit": "",
                "value": 3720
              }
            },
            "timestamp": "2024-10-11T17:01:45.978Z",
            "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/0/features/heating.burners.0.statistics"          },

but it does not show up anywhere. I guess the integration is a bit fixated of consisting of one heat source and several drains but the entire system can consist of several sources (which can be heating OR cooling or both) attached to a central controller. The CU401 consists of a gas burner, a heat pump and a hot water storage in one package. In my case an external buffer has been added, too. In theory we could add further heat exchangers like a geo-thermal heat pump that could be used to draw energy from the ground or a water to water heat pump that could get rid of excess energy when used as cooling device. I know at least one installation where this is used to cool PV elements to increase its efficiency. But I guess I have to try asking for more flexibility in a feature request...

@CFenner
Copy link
Contributor

CFenner commented Oct 12, 2024

In general every vicare system seems to be a unicorn 🦄. By now, we just try to map the devices that are in the api by type. Hybrids are not considered. So if the api show the devices as an own unit you should see it.
buy maybe open a new issue as this one is fixed and btw also released with 24.10.2

@noseshimself
Copy link
Author

I will open a special snowflake issue for this.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants