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

Fix onetimecharge #152

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading