iloveicedgreentea / jvc_projector_python

Python library to control JVC projectors
MIT License
9 stars 2 forks source link

Library doesn't correctly match NX5 model to family #18

Closed bsknox closed 1 year ago

bsknox commented 1 year ago

Thanks for maintaining this library. I'm trying to integrate my DLA-NX5 with HomeAssistant and have run into an issue. My projector returns "B2A3" for the model.value, which is confirmed in the Service Manual, p.8 (https://www.manualslib.com/manual/2124871/Jvc-D-Ila-Dla-N11bc.html?page=8&term=B2A3&selected=1#manual).

Since the existing library doesn't match the model code I get the following error when attempting to start HA:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 438, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 709, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 804, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 600, in _async_write_ha_state
    attr.update(self.extra_state_attributes or {})
  File "/config/custom_components/jvc_projectors/remote.py", line 116, in extra_state_attributes
    if "NZ" in self._model_family:
TypeError: argument of type 'NoneType' is not iterable

Adding "B2A3": "NX5" to the models { } list recognizes it and allows it to correct properly. It appears that B2A2 and B2A1 are valid model codes for the NX7 and NX9, respectively, as well.

iloveicedgreentea commented 1 year ago

thanks sorry I didnt see this. I added those codes and safeguard to not crash on unsupported models. I got the existing NX codes from jvc docs but I guess they have multiple. Released a new version with these changes