Viessmann Component

Can you post your configuration/automation/Lovelace card for this. I can’t get this to work

Here is my entire set of configurations that is doing that. Note that it is probably not the best, I’ve been doing that when I was new to HA :slight_smile: Also some of the controls are moved to scripts as this was needed when I was exposing it to HADashboard, no need if you just have it with lovelace. Another thing is that now you can have triggers based on entity attributes, back then it was possible to trigger automations by entity state only.

input_select:
  vicare_mode:
    name: ViCare Mode
    options:
      - standby
      - dhw
      - dhwAndHeating
      - forcedReduced
      - forcedNormal
    icon: mdi:radiator
    


automation:
  - id: heating_reduced
    alias: Heating - Input Select Reduced
    trigger:
    - platform: state
      entity_id: climate.vicare_heating
    condition:
    - condition: template
      value_template: '{{ trigger.to_state.attributes.active_vicare_mode == "forcedReduced"
        }}'
    action:
    - service: input_select.select_option
      entity_id: input_select.vicare_mode
      data:
        option: forcedReduced
  - id: heating_off
    alias: Heating - Input Select Off
    trigger:
    - platform: state
      entity_id: climate.vicare_heating
    condition:
    - condition: template
      value_template: '{{ trigger.to_state.attributes.active_vicare_mode == "standby"
        }}'
    action:
    - service: input_select.select_option
      entity_id: input_select.vicare_mode
      data:
        option: standby
  - id: heating_auto
    alias: Heating - Input Select Auto
    trigger:
    - platform: state
      entity_id: climate.vicare_heating
    condition:
    - condition: template
      value_template: '{{ trigger.to_state.attributes.active_vicare_mode == "dhwAndHeating"
        }}'
    action:
    - service: input_select.select_option
      entity_id: input_select.vicare_mode
      data:
        option: dhwAndHeating
  - id: heating_dhw
    alias: Heating - Input Select Auto DHW
    trigger:
    - platform: state
      entity_id: climate.vicare_heating
    condition:
    - condition: template
      value_template: '{{ trigger.to_state.attributes.active_vicare_mode == "dhw" }}'
    action:
    - service: input_select.select_option
      entity_id: input_select.vicare_mode
      data:
        option: dhw
  - id: heating_heat
    alias: Heating - Input Select Heat
    trigger:
    - platform: state
      entity_id: climate.vicare_heating
    condition:
    - condition: template
      value_template: '{{ trigger.to_state.attributes.active_vicare_mode == "forcedNormal"
        }}'
    action:
    - service: input_select.select_option
      entity_id: input_select.vicare_mode
      data:
        option: forcedNormal
  - id: heating_is_standby
    alias: Heating - Input Select Standby
    trigger:
    - platform: state
      entity_id: input_select.vicare_mode
      to: standby
    condition: []
    action:
    - service: script.heating_standby
  - id: heating_is_dhw
    alias: Heating - Input Select DHW
    trigger:
    - platform: state
      entity_id: input_select.vicare_mode
      to: dhw
    condition: []
    action:
    - service: script.heating_dhw
  - id: heating_is_dhwandheating
    alias: Heating - Input Select DHW and Heating
    trigger:
    - platform: state
      entity_id: input_select.vicare_mode
      to: dhwAndHeating
    condition: []
    action:
    - service: script.heating_auto
  - id: heating_is_forcedReduced
    alias: Heating - Input Select forcedReduced
    trigger:
    - platform: state
      entity_id: input_select.vicare_mode
      to: forcedReduced
    condition: []
    action:
    - service: script.heating_off
  - id: heating_is_forcedNormal
    alias: Heating - Input Select forcedNormal
    trigger:
    - platform: state
      entity_id: input_select.vicare_mode
      to: forcedNormal
    condition: []
    action:
    - service: script.heating_heat
    
    
script:
  heating_auto:
    alias: Heating - Set Auto Mode
    sequence:
    - service: climate.set_hvac_mode
      data:
        hvac_mode: auto
        entity_id: climate.vicare_heating
  heating_off:
    alias: Heating - Set Forced Reduced Mode
    sequence:
    - service: climate.set_hvac_mode
      data:
        hvac_mode: 'off'
        entity_id: climate.vicare_heating
  heating_heat:
    alias: Heating - Set Forced Normal Mode
    sequence:
    - service: climate.set_hvac_mode
      data:
        hvac_mode: heat
        entity_id: climate.vicare_heating
  heating_dhw:
    alias: Heating - Set DHW mode
    sequence:
    - service: vicare.set_vicare_mode
      data:
        entity_id: climate.vicare_heating
        vicare_mode: dhw
  heating_standby:
    alias: Heating - Set standby mode
    sequence:
    - service: vicare.set_vicare_mode
      data:
        entity_id: climate.vicare_heating
        vicare_mode: standby

Has anyone created a sensor for the energy consumption based on integration of the gas burner modulation and kW ratings of their burner? I want to display the kWh usage in the energy monitor.

Is anyone else having problems connecting to the API? Since 21:00/21:30 last night I have not received any updates from the sensors. The app/ViGuide is working without any problems.

Restarting HA or reloading the integration results in an error:

2022-10-12 17:37:13.175 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ViCare for vicare
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.10/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/vicare/__init__.py", line 52, in async_setup_entry
await hass.async_add_executor_job(setup_vicare_api, hass, entry)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/vicare/__init__.py", line 74, in setup_vicare_api
vicare_api = vicare_login(hass, entry.data)
File "/usr/src/homeassistant/homeassistant/components/vicare/__init__.py", line 63, in vicare_login
vicare_api.initWithCredentials(
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCare.py", line 26, in initWithCredentials
self.initWithExternalOAuth(ViCareOAuthManager(
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCare.py", line 31, in initWithExternalOAuth
self.__loadInstallations()
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCare.py", line 43, in __loadInstallations
installations = self.oauth_manager.get(
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 37, in get
response = self.__oauth.get(f"{API_BASE_URL}{url}").json()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Many thanks for that. Great place to start for me

Yes the API is very unstable for me aswell in the last days. Multiple errors over the course of the day.

In general it works for me, just yesterday at ~4PM CET I’ve had the following error:
'Request failed with status code 502 and message "Your request could not be performed as there was a problem with external service". ViCare ErrorId: req-01...
But works ok since then,

I have now tried the following:

  • completely restarted the Vitodens
  • Deleted ViCare integration from Home Assistant
  • HA restarted
  • generated a new API key in the Developer Portal

Unfortunately, the attempt to set up the integration again fails:

2022-10-13 13:28:35.562 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.10/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.10/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/vicare/config_flow.py", line 53, in async_step_user
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/vicare/__init__.py", line 63, in vicare_login
vicare_api.initWithCredentials(
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCare.py", line 26, in initWithCredentials
self.initWithExternalOAuth(ViCareOAuthManager(
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCare.py", line 31, in initWithExternalOAuth
self.__loadInstallations()
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCare.py", line 43, in __loadInstallations
installations = self.oauth_manager.get(
File "/usr/local/lib/python3.10/site-packages/PyViCare/PyViCareAbstractOAuthManager.py", line 37, in get
response = self.__oauth.get(f"{API_BASE_URL}{url}").json()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Does anyone else have an idea what else I could try, since it doesn’t seem to be a general problem?
Using the current HA version 2022.10.3

Nevermind.
Followed the suggestion to delete the vicare_token.save file as suggested by oschinger here:
Error setting up ViCare entry for vicare - Issue #77050 - home-assistant/core - GitHub

rm /config/.storage/vicare_token.save

I was then able to re-add the integration.

As my heating system doesn’t provide these consumption values out of the box, I used the Integration/Rieman sum integral-function to approximate actual gas consumption:

  • Create a Rieman sum integration-helper that “eats” the ViCare modulation sensor - I played around a bit and got the best precision using left method and 4 digits:


    This will provide you with an artificial sensor that displays “%days”, which you can imagine as a multiplication of the modulation percentage having run for how much of the day (100 %days could mean the burner has run for the full day at full steam, or for two days at 50% modulation; 25 %days could mean the burner has run for half of the day at 50% modulation, or for the full day at 50%, etc…).

  • I called this value “load intensity”, which I’ll feed into some further calculations:
    image
    The resulting curve is not very spectacular at the moment, as i) the last 96 hours are quite warm here with little need for heating, and ii) the last 20 hours have been erased by one of the frequent downtimes of Viessmann’s API - which is also the major draw back of this approach, as an interrupted the ViCare-connection will mean untracked modulation i.e. untracked load intensity i.e. untracked gas consumption…

  • Next I defined a template sensor which will do the math from %days to m³ first (in my templates.yaml):

# Conversion of ViCare Load Intensity to gas consumptions (m³, kWh)...
# ... using Rieman sum integration-based ViCare burner modulation und empirically derived consumption quotient (average of Okt 2022)
- sensor:
    - name: "Gasverbrauch m3"
      unit_of_measurement: "m³"
      device_class: energy
      state_class: total_increasing
      state: >-
        {{ states('sensor.sensor_vicare_load_intensity') |float(0) * 0.46523 | round(4) }}

The interesting part here is the constant value of 0.46523, which I derived by collecting ~20 data pairs (~3 weeks) of HA-/ViCare-calculated “load intensity” and actual gas meter readings in m³: calculating the quotient of the deltas between new and last data points gave me only minor variations (2nd to 3rd digit) after a hand full of readings, and an average converged to the 0.46523 that I ultimately decided to use:


Quotient calulcates as…

(new gas meter reading - old gas meter reading) / (new load intensity - old load intensity)

(Side note: the missing data pair/red quotient mark another Viessmann API down time, where actual gas meter reading and calculated load intensity didn’t match…).
I have no clue if this quotient is the same for all Viessmann heatings with 19kW nominal power (in my case Vitodens 300-W), or if this differs significantly between individual installations?! Let me know…

  • Next I do the math from m³ to kWh, which makes use of information you typically find on your utility’s last gas bill (also in my templates.yaml):
# ... converting m³-consumption into kWh, using "Z-Zahl" 0.9574 and "Brennwert" 11.54:
    - name: "Gasverbrauch kWh"
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing
      state: >-
        {{ states('sensor.gasverbrauch_m3') | float(0) * 0.9574 * 11.54  | round(4) }}

  • Finally, I define a kWh consumption counter using utiliy meter, to let this conveniently take care of the daily resets and long-term statistics (in my configuration.yaml):
utility_meter:
  gas_consumption_vicare:
    source: sensor.gasverbrauch_kwh
    name: Gasverbrauch kWh
    delta_values: false
    cycle: daily
  • Adding this to the energy dashboard gives me a nicely analysed overview about a not so nice, quite expensive topic…^^ (as long as Viessmann keeps there API up and running, otherwise a day like today will drop out of this statistic until I find to fix it).

Not sure if this is the most elegant way to solve it, but the results seem plausible to me so far. Happy to hear about your approaches!

5 Likes

Very interesting, thanks for sharing. Do you also have had meter reading in HA? Have you also tried to have gas usage separately for water heating from house heating?

I am using the Vicare integration for a while. Today i added a new card to my dashboard and noticed that there are two sensors where i dont understand how they work.

The first one is the ViCare Supply Temperature. When i take a look in my Vicare App is this entity the same as “Vorlauftemperatur” for heating circle?

The second one is the sensor: sensor.vicare_heating_gas_consumption_today_cost
The value is currently: 1.29€ but i did no define this sensor and i do not use it in the energy dashboard. How is this sensor value defined automatically from which source?
What does this price show?

In the engery dashboard i am ussing the exact kwh price for my gas.

I do not read the meter automatically, no - thought about it, but realized the meter room would be difficult to reach by any wireless system, and given how easily actual meter readings can be substituted in my case, I’m hesitant to invest the money…
So I decided for a half-way solution: I have a Lovelace card, where I can enter my (human-based) meter reading, and this will then be written to the Google Sheets you saw the screenshot of - together with the “load intensity” value at exactly the same time, so there’s always consistent data pairs.

Regarding split domestic hot water/heating values: this should generally be achievable, as you could allocate any given burner runtime to either one or the other “loat intensity” according to which pump is currently running - at least my boiler broadcasts this information in two different sensors…

I interpret the supply temperature actually as “Vorlauftemperatur”, yes.

And regarding the energy cost: this sensor magically appeared in my case as well, after I had provided my kWh-cost to the energy dashboard. So this seems to be automatically calculated and openly provided, as soon as HA energy dashboard has all the required information together.
Didn’t track it for longer, but in my case it looked as if it did what the name promises: reset at midnight and start counting the incurred cost again starting at zero for the next day.

Hello, I becaming mad, please please help me
I have a strange behaviour, I’m runng an hybrid Viessman system for my home heating, one gas water heater VITODENS 200 and one Heat Pump VITOCAL 200, i cansee both , via Vicare app, for VITODENS i can see diag infos ( temp.burner usage…etc ), and on a daily basis, Kwh of energy used and m3 of gas used, for VITOCAL, diag infos ( temp, pump usage etc) but no energy used.
I then load the integration using the official Viessan I have used both auto and hybrid type but it always found CU401B_S the vitocal heatpump, but no entityes for gas and energy usage. Then I tryes the custom componet ha_vicare from oischinger but i had the same result.
Someone can give me an help please.
Rob

@oischinger I’ve been checking the numbers for m³ and kWh, there seems to be something wrong in the conversion?
For example :
sensor.vicare_energy_consumption_of_gas_heating_current_day : 0.3 kWh
sensor.vicare_heating_gas_consumption_current_day : 1.3 m³

1.3m³ converts to approx 13.2 kWh, not 0.3kWh.

Am I missing something here ??

1 Like

Wow, very interesting approach. The burner modulation value seems to be quite accurate.
I am currently just using the modulation value multiplied by the kW-rating of our burner to approximate the kWh gas consumption. Unfortunately we don’t have a gas meter and I can only check the percentage value of fill level indicator of the gas tank, which is quite inaccurate.
Do the values on your setup match for this calculation with a 19kW burner?

Hello there,

I’m still new and try to learn a lot, but maybe someone has already a solution for me.

As gas gets more and more expensive, I want to set the “climate.vicare_heating” temperature to 50° for 23 hours and to 60° for one hours to kill the Legionella in the system.

I have a Viessmann “E3_Vitodens_050” and maybe someone has already a template for this?

Thank you

nebkas

1 Like

Hi, I read in the Viessmann API documentation that they provide the modification of the heating curve of any circuit:

BASIC plan

heating.circuits.N.heating.curve

Shows the values for slope and shift of the heating curve and provides the commands to modify the values

Is there already a way to do so with this integration? Slope and shift would exactly be the values which I would like to modify by script.

Thanks a lot for that great integration anyway, great work!

Cheers…

Obviously the PyViCare API can access the heating schedule. So i wonder if it would be possible to get the data until when the current mode will be active, e.g. „reduced until 4:00 pm“ like in the ViCare App:

Would be great having this in lovelace.