Skip to content

Commit

Permalink
🎮 add log for control device
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Feb 10, 2025
1 parent 7f1a8ba commit 134941c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion custom_components/xiaomi_miot/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,12 @@ async def async_write(self, payload: dict):
result = await self.update_main_status()

if method == 'set_properties':
result = []
params = data.get('params', [])
cloud_params = []
if not self._local_state or self.cloud_only:
cloud_params = params
elif self.miio2miot:
result = []
for param in params:
siid = param['siid']
piid = param['piid']
Expand All @@ -697,6 +697,8 @@ async def async_write(self, payload: dict):
result = await self.local.async_send(method, params)
if self.cloud and cloud_params:
result = await self.cloud.async_set_props(cloud_params)
if err := MiotResults(result).has_error:
self.log.warning('Device write error: %s', err)

if method == 'action':
param = data.get('param', {})
Expand Down
3 changes: 3 additions & 0 deletions custom_components/xiaomi_miot/core/miot_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ class MiotResults:
updater: str = None
updated = None
errors = None
has_error = None

def __init__(self, results=None, mapping=None):
self.mapping = mapping or {}
Expand All @@ -1143,6 +1144,8 @@ def set_results(self, results, mapping=None):
continue
r = MiotResult(v)
self.results.append(r)
if not self.has_error and not r.is_success:
self.has_error = r
self.updated = now()

@property
Expand Down

0 comments on commit 134941c

Please sign in to comment.