Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Fix onetimecharge
Browse files Browse the repository at this point in the history
  • Loading branch information
oischinger committed Aug 13, 2023
1 parent 99a88c8 commit eee4e88
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions custom_components/vicare/switch.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
"""Viessmann ViCare switch device."""
from __future__ import annotations

import datetime
import logging
from contextlib import suppress
from dataclasses import dataclass
import datetime
import logging

import requests
from PyViCare.PyViCareUtils import (
PyViCareInternalServerError,
PyViCareInvalidDataError,
PyViCareNotSupportedFeatureError,
PyViCareRateLimitError,
)
import requests

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
Expand Down Expand Up @@ -127,7 +128,7 @@ def is_on(self) -> bool:
"""Return true if device is on."""
return self._state

async def async_update(self):
def update(self):
"""update internal state"""
now = datetime.datetime.utcnow()
"""we have identified that the API does not directly sync the represented state, therefore we want to keep
Expand All @@ -140,7 +141,7 @@ async def async_update(self):
try:
with suppress(PyViCareNotSupportedFeatureError):
_LOGGER.debug("Fetching DHW One Time Charging Status")
self._state = await self.hass.async_add_executor_job(self.entity_description.value_getter, self._api)
self._state = self.entity_description.value_getter(self._api)
except requests.exceptions.ConnectionError:
_LOGGER.error("Unable to retrieve data from ViCare server")
except ValueError:
Expand Down

1 comment on commit eee4e88

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.