core: Insteon python3.8 error

The problem

After updating to Python 3.8.x, this error message started to occur. The error only occurs when starting HASS. The error does not occur with Python 3.7. When upgraded, I followed the normal procedure by creating a new virtual environment and executing a new install command.

Environment

  • Home Assistant Core release with the issue: 0.115.6
  • Last working Home Assistant Core release (if known): 0.115.6
  • Operating environment (OS/Container/Supervised/Core): venv
  • Integration causing this issue: Insteon

Problem-relevant configuration.yaml

Configuration not set via yaml. 

2448A7 USB stick

Traceback/Error logs

Oct 14 17:49:04 hasstardis hass[838]: 2020-10-14 17:49:04 DEBUG (MainThread) [homeassistant.components.insteon] Insteon device count: 28
Oct 14 17:49:04 hasstardis hass[838]: 2020-10-14 17:49:04 DEBUG (MainThread) [homeassistant.components.insteon.utils] Insteon Services registered
Oct 14 17:49:04 hasstardis hass[838]: 2020-10-14 17:49:04 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry  for insteon
Oct 14 17:49:04 hasstardis hass[838]: Traceback (most recent call last):
Oct 14 17:49:04 hasstardis hass[838]:   File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/config_entries.py", line 228, in async_setup
Oct 14 17:49:04 hasstardis hass[838]:     result = await component.async_setup_entry(hass, self)  # type: ignore
Oct 14 17:49:04 hasstardis hass[838]:   File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/insteon/__init__.py", line 162, in async_setup_entry
Oct 14 17:49:04 hasstardis hass[838]:     model=f"{devices.modem.model} (0x{devices.modem.cat:02x}, 0x{devices.modem.subcat:02x})",
Oct 14 17:49:04 hasstardis hass[838]:   File "/usr/local/lib/python3.8/enum.py", line 669, in __format__
Oct 14 17:49:04 hasstardis hass[838]:     return cls.__format__(val, format_spec)
Oct 14 17:49:04 hasstardis hass[838]: ValueError: Unknown format code 'x' for object of type 'str'

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Ah, right the line should be:

        model=f"{devices.modem.model} ({devices.modem.cat!r}, 0x{devices.modem.subcat:02x})",

without the 0x before the {

Same fix was needed on lines 64-66, in pyinsteon/aldb/aldb_record.py where strings are sometimes being passed to the formatter.

If you have seen errors with ALDB record formatting, can you please open a separate issue.