Andre0512 / Andre0512/pyhOn

AttributeError: 'int' object has no attribute 'items' in rules.py _parse_conditions (model H4F226WDH1)

Aperta
#41 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
499
Fork
1.7k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Description
Setting up the Haier hOn integration fails during appliance/command loading for my freezer (model **H4F226WDH1**). The config entry setup crashes with `AttributeError: 'int' object has no attribute 'items'` inside `pyhon/rules.py`.

The appliance is correctly linked and reachable in the official hOn mobile app, so this is not an authentication or connectivity issue — it fails while parsing the command rules returned by the Haier API for this specific model.

### Environment
- Home Assistant Core, Python 3.14
- Haier hOn custom integration (HACS), version 0.14.1
- Appliance: Haier freezer, model **H4F226WDH1**
- Issue occurs on every setup attempt, including after a full HA restart and removing/re-adding the integration entry

### Steps to reproduce
1. Add the Haier hOn integration in Home Assistant with valid hOn account credentials
2. Integration finds the freezer (H4F226WDH1) but fails while loading its commands

### Traceback
Body (version finale) :

markdown
### Description
Setting up the Haier hOn integration fails during appliance/command loading for my freezer (model **H4F226WDH1**). The config entry setup crashes with `AttributeError: 'int' object has no attribute 'items'` inside `pyhon/rules.py`.

The appliance is correctly linked and reachable in the official hOn mobile app, so this is not an authentication or connectivity issue — it fails while parsing the command rules returned by the Haier API for this specific model.

### Environment
- Home Assistant Core, Python 3.14
- Haier hOn custom integration (HACS), version 0.14.1
- Appliance: Haier freezer, model **H4F226WDH1**
- Issue occurs on every setup attempt, including after a full HA restart and removing/re-adding the integration entry

### Steps to reproduce
1. Add the Haier hOn integration in Home Assistant with valid hOn account credentials
2. Integration finds the freezer (H4F226WDH1) but fails while loading its commands

### Traceback

Error setting up entry [redacted] for hon
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 796, in __async_setup_with_context
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hon/init.py", line 59, in async_setup_entry
hon = await hon.create()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/hon.py", line 77, in create
await self.setup()
File "/usr/local/lib/python3.14/site-packages/pyhon/hon.py", line 111, in setup
await self._create_appliance(appliance, self.api)
File "/usr/local/lib/python3.14/site-packages/pyhon/hon.py", line 95, in _create_appliance
await appliance.load_commands()
File "/usr/local/lib/python3.14/site-packages/pyhon/appliance.py", line 190, in load_commands
await command_loader.load_commands()
File "/usr/local/lib/python3.14/site-packages/pyhon/command_loader.py", line 60, in load_commands
self._get_commands()
~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/pyhon/command_loader.py", line 101, in _get_commands
if command := self._parse_command(data, name):
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/command_loader.py", line 124, in _parse_command
if category := self._parse_categories(data, command_name):
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/command_loader.py", line 134, in _parse_categories
if command := self._parse_command(
~~~~~~~~~~~~~~~~~~~^
value, command_name, category_name=category, categories=categories
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
):
^
File "/usr/local/lib/python3.14/site-packages/pyhon/command_loader.py", line 117, in _parse_command
return HonCommand(
command_name,
...<3 lines>...
categories=categories,
)
File "/usr/local/lib/python3.14/site-packages/pyhon/commands.py", line 40, in init
self._load_parameters(attributes)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/commands.py", line 98, in _load_parameters
self._create_parameters(data, name, key)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/commands.py", line 109, in _create_parameters
self._rules.append(HonRuleSet(self, data["fixedValue"]))
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/rules.py", line 26, in init
self._parse_rule(rule)
~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/rules.py", line 36, in _parse_rule
self._parse_conditions(param_key, trigger_key, trigger_data)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/rules.py", line 58, in _parse_conditions
self._parse_conditions(param_key, extra_key, extra_data, extra)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/pyhon/rules.py", line 47, in _parse_conditions
for multi_trigger_value, param_data in trigger_data.items():
^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'items'

### Suspected cause
In `rules.py`, `_parse_conditions` assumes `trigger_data` is always a dict and calls `.items()` on it. For at least one command's `fixedValue` rule set on the H4F226WDH1, the API appears to return an `int` where a nested dict of conditions is expected, which isn't handled and crashes the whole setup.

Let me know if any additional info would help track this down.

Tiger

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.