Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid zone mode 'error' #22

Open
JP-Ellis opened this issue Oct 2, 2024 · 4 comments · May be fixed by #23
Open

Invalid zone mode 'error' #22

JP-Ellis opened this issue Oct 2, 2024 · 4 comments · May be fixed by #23

Comments

@JP-Ellis
Copy link

JP-Ellis commented Oct 2, 2024

I have a newly set up iZone system, and after integrating with Home Assistant, I noticed there was an issue with a mode apparently missing from some enum: 'error'.

See for example this traceback:

2024-10-02 15:25:16.268 ERROR (MainThread) [homeassistant.helpers.dispatcher] Exception in zone_update when dispatching 'izone_zone_update': (<pizone.controller.Controller object at 0x721efb50dd90>, <pizone.zone.Zone object at 0x721ef3386f30>)
Traceback (most recent call last):
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/components/izone/climate.py", line 502, in zone_update
    self.async_write_ha_state()
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1063, in __async_calculate_state
    capability_attr = self.capability_attributes
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/components/climate/__init__.py", line 323, in __getattribute__
    return super().__getattribute__(__name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/components/climate/__init__.py", line 488, in capability_attributes
    supported_features = self.supported_features
                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/components/climate/__init__.py", line 327, in __getattribute__
    _supported_features: ClimateEntityFeature = super().__getattribute__(
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/components/izone/climate.py", line 126, in wrapped_f
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/components/izone/climate.py", line 517, in supported_features
    if self._zone.mode == Zone.Mode.AUTO:
       ^^^^^^^^^^^^^^^
  File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/pizone/zone.py", line 71, in mode
    return self.Mode(self._get_zone_state("Mode"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'error' is not a valid Zone.Mode

The 'obvious' fix here is the add the undocumented error mode to the enum:

pizone/pizone/zone.py

Lines 26 to 35 in ef2eeb2

class Mode(Enum):
"""This indicates the current mode the zone is in. Possible values are:
'open' – the zone is currently open
'close' – the zone is currently closed
'auto' – the zone is currently in temperature control mode
"""
OPEN = "open"
CLOSE = "close"
AUTO = "auto"

There's no mention of this mode in the PDF docs, so I can understand not adding it; though having a runtime error is also less than ideal.

I'm not familiar with the codebase, so I'm not sure what potential ramifications there might be to adding this enum.

@Swamp-Ig
Copy link
Owner

Swamp-Ig commented Oct 3, 2024

Feel free to create a PR. I haven't really been developing the integration recently, I need someone else to get approved to review PRs really. Let me know if you'd be able to do this and would be interested.

@JP-Ellis
Copy link
Author

JP-Ellis commented Oct 3, 2024

If you aren't developing it much lately, I'm more than happy to contribute to it. What would be best? Would it be easier for me to simply fork your repository? Or do you want me to contribute into this repo?

@JP-Ellis JP-Ellis linked a pull request Oct 3, 2024 that will close this issue
@paulojr
Copy link
Collaborator

paulojr commented Oct 3, 2024

Hi JP-Ellis are you able to provide more info on how you encountered the "error" value in the field. What izone unit and firmware would be useful and also the data that is posted back when you hit the CB_IP/SystemSettings and CB_IP/Zones1_4, CB_IP/Zones5_8 and CB_IP/Zones9_12 for zones (remove any personal data such as your system ID)
BTW I am happy to help test, but don't recall ever seeing this particular code returned so not sure how to reproduce that, perhaps it only occurs on a mis-configured system or something in a newer firmware. Also may be wort raising a izone case to clarify why the documentation does not mention it.

@Swamp-Ig
Copy link
Owner

Swamp-Ig commented Oct 4, 2024

Probably the best bet if you want to actively contribute to development is to contact me on the home assistant discord, my username is @Penny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants