Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion custom_components/meross_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ async def async_update(self):
await super().async_update()

_LOGGER.debug(f"Refreshing instant metrics for device {self.name}")
self._daily_consumption = await self._device.async_get_daily_power_consumption(channel=self._channel_id)
try:
self._daily_consumption = await self._device.async_get_daily_power_consumption(channel=self._channel_id)
except CommandTimeoutError:
log_exception(logger=_LOGGER, device=self._device)

@property
def native_value(self) -> StateType:
Expand Down
13 changes: 10 additions & 3 deletions custom_components/meross_cloud/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
from meross_iot.controller.mixins.dnd import SystemDndMixin
from meross_iot.controller.mixins.toggle import ToggleXMixin, ToggleMixin
from meross_iot.manager import MerossManager
from meross_iot.model.exception import CommandTimeoutError
from meross_iot.model.http.device import HttpDeviceInfo
from meross_iot.model.enums import DNDMode

# Conditional import for switch device
from homeassistant.components.switch import SwitchEntity
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from . import MerossDevice
from .common import (DOMAIN, MANAGER, DEVICE_LIST_COORDINATOR, HA_SWITCH)
from .common import (DOMAIN, MANAGER, DEVICE_LIST_COORDINATOR, HA_SWITCH, log_exception)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,10 +62,16 @@ async def async_update(self):

# If the device supports power reading, update it
if isinstance(self._device, ElectricityMixin):
self._last_power_sample = await self._device.async_get_instant_metrics(channel=self._channel_id)
try:
self._last_power_sample = await self._device.async_get_instant_metrics(channel=self._channel_id)
except CommandTimeoutError:
log_exception(logger=_LOGGER, device=self._device)

if isinstance(self._device, ConsumptionXMixin):
self._daily_consumption = await self._device.async_get_daily_power_consumption(channel=self._channel_id)
try:
self._daily_consumption = await self._device.async_get_daily_power_consumption(channel=self._channel_id)
except CommandTimeoutError:
log_exception(logger=_LOGGER, device=self._device)

@property
def is_on(self) -> bool:
Expand Down