Skip to content

TypeError in async_setup_entry — `sequence item 1: expected str instance, int found #1

Description

@jeroen-van-schie

Describe the bug

Setting up the integration fails during async_setup_entry. The device model string is built from registers 111/112, but on my unit register 112 returns an int instead of a str, so " ".join(...) raises a TypeError and the whole config entry setup aborts.

Unit: Zehnder ComfoAir E400
Connection: Modbus TCP via Elfin EW11 gateway (port 502, 19200 baud, 8E1)
Mode: 3-way switch

Traceback

Error setting up entry Zehnder ComfoAir E400 for comfoair
Traceback (most recent call last):
  File ".../config_entries.py", line 798, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/comfoair/__init__.py", line 146, in async_setup_entry
    model_display = " ".join(p for p in model_parts if p) or None
TypeError: sequence item 1: expected str instance, int found

Cause

In __init__.py:

model_parts = ["ComfoAir", hub.data.get("112"), hub.data.get("111")]
model_display = " ".join(p for p in model_parts if p) or None

hub.data.get("112") returns an integer on my unit, and str.join() only accepts strings.

Suggested fix

Cast each part to str before joining:

model_display = " ".join(str(p) for p in model_parts if p) or None

Happy to test a patch if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions