Skip to content

Group selection regex fails for my Siemens oven #214

@simonheng

Description

@simonheng

The problem

The feature mapping xml for my Siemens oven has one entry that causes the integration to fail to adopt it:
<feature refUID="1893">Cooking.Oven.Status.Cavity.001.RemainingProgramTime.AutoCounting</feature>

Leading to the error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 751, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/homeconnect_ws/__init__.py", line 162, in async_setup_entry
    available_entities = get_available_entities(appliance)
  File "/config/custom_components/homeconnect_ws/entity_descriptions/__init__.py", line 68, in get_available_entities
    dynamic_descriptions: _EntityDescriptionsType = descriptions_fn(appliance)
                                                    ~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/config/custom_components/homeconnect_ws/entity_descriptions/cooking.py", line 34, in generate_oven_status
    group_name = f" {int(group[0])}"
                     ~~~^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '001.RemainingProgramTime'

This is because it expects the keys to be like this: Cooking.Oven.Status.Cavity.001.RemainingProgramTime
in this regex (line 90 in entity_descriptions/cooking.py).

   [ pattern = re.compile(r"^Cooking\.Hob\.Status\.Zone\.([0-9]*)\..*$")
    groups = get_groups_from_regex(appliance, pattern)](url)

The extra section (.AutoCounting) is what is making it fail to strip away the text from the integer.
I think this regex: r"^Cooking\.Oven\.Status\.Cavity\.(\d+)\..*$" could fix the issue, as it removes everything after the integer.

Diagnostics information

``

Debug log

No response

Description files

385010390189016929_FeatureMapping.xml

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