krahabb / meross_lan

Home Assistant integration for Meross devices
MIT License
443 stars 47 forks source link

Object of type DhcpServiceInfo is not JSON serializable #129

Closed purcell-lab closed 2 years ago

purcell-lab commented 2 years ago

Version of the custom_component

v2.4.2 - current version

Configuration


All auto discovered - no yaml

System Health

version core-2021.12.0b3
installation_type Home Assistant Supervised
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.7
os_name Linux
os_version 4.9.277-118
arch aarch64
timezone Australia/Sydney
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4783 Installed Version | 1.18.0 Stage | running Available Repositories | 976 Installed Repositories | 30
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | December 15, 2021, 11:00 AM relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | ap-southeast-1-0.ui.nabu.casa can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | pending
Home Assistant Supervisor host_os | Ubuntu 20.04.3 LTS -- | -- update_channel | beta supervisor_version | supervisor-2021.12.0 docker_version | 20.10.7 disk_total | 114.4 GB disk_used | 53.9 GB healthy | true supported | failed to load: Unsupported supervisor_api | ok version_api | ok installed_addons | Studio Code Server (3.7.0), Check Home Assistant configuration (3.9.0), Mosquitto broker (6.0.1), Terminal & SSH (9.2.1), File editor (5.3.3)
Lovelace dashboards | 2 -- | -- resources | 8 views | 11 mode | storage

Describe the bug

Error message in the logs, functionality appears to be unaffected.

Debug log


This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/meross_lan/config_flow.py:110
Integration: Meross LAN (documentation, issues)
First occurred: 11:31:25 AM (7 occurrences)
Last logged: 11:31:25 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 203, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 230, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/meross_lan/config_flow.py", line 110, in async_step_dhcp
    LOGGER.debug("received dhcp discovery: %s", json.dumps(discovery_info))
  File "/usr/local/lib/python3.9/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type DhcpServiceInfo is not JSON serializable
krahabb commented 2 years ago

Hello @purcell-lab , Thank you for signaling this...my tests configuration is lame to say the less... I'd say this is likely impairing the ability to correctly discover meross devices through the dhcp protocol integration. The error itself would not be critical since it's only related to a debug log message. Nevertheless, even if debug logging is not activated the code itself will fail at runtime and interrupt the dhcp discovery process so this is very annoying. At the time I still can't get the reason behind: I've seen HA core received some 'strict typing' in latest devs that are, at least in this case, impacting what should be a relatively failsafe json.dumps I still can't get if this is a 'transient' bug or something which I should take care of (guess the latter would be safer) Nevertheless I'll definitely patch this annoying line of logging since it would anyway be lame to crash because of a 'malformed' log message