sanjoyg / dirigera_platform

HomeAssistant Integration for Dirigera Platform
MIT License
123 stars 16 forks source link

Wrong blinds and environment sensor type mapping #12

Closed slajob closed 8 months ago

slajob commented 8 months ago

When HA was booting up, errors regarding blind position updates appeared:

2024-03-03 21:19:18.724 ERROR (SyncWorker_3) [custom_components.dirigera_platform] error encountered running update on : Kitchen blind
2024-03-03 21:19:18.726 ERROR (SyncWorker_3) [custom_components.dirigera_platform] 6 validation errors for EnvironmentSensor
attributes -> currentTemperature
  field required (type=value_error.missing)
attributes -> currentRH
  field required (type=value_error.missing)
attributes -> currentPM25
  field required (type=value_error.missing)
attributes -> maxMeasuredPM25
  field required (type=value_error.missing)
attributes -> minMeasuredPM25
  field required (type=value_error.missing)
attributes -> vocIndex
  field required (type=value_error.missing)
2024-03-03 21:19:18.728 ERROR (MainThread) [homeassistant.helpers.entity] Update for cover.kitchen_blind fails
Traceback (most recent call last):
  File "/workspaces/core/custom_components/dirigera_platform/cover.py", line 141, in update
    self._json_data = self._hub.get_blinds_by_id(self._json_data.id)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/custom_components/dirigera_platform/dirigera_lib_patch.py", line 54, in get_blinds_by_id
    return dict_to_environment_sensor(blind_sensor, self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/dirigera/devices/environment_sensor.py", line 36, in dict_to_environment_sensor
    return EnvironmentSensor(dirigeraClient=dirigera_client, **data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 341, in __init__
    raise validation_error
pydantic.error_wrappers.ValidationError: 6 validation errors for EnvironmentSensor
attributes -> currentTemperature
  field required (type=value_error.missing)
attributes -> currentRH
  field required (type=value_error.missing)
attributes -> currentPM25
  field required (type=value_error.missing)
attributes -> maxMeasuredPM25
  field required (type=value_error.missing)
attributes -> minMeasuredPM25
  field required (type=value_error.missing)
attributes -> vocIndex
  field required (type=value_error.missing)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/core/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/workspaces/core/homeassistant/helpers/entity.py", line 1261, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/custom_components/dirigera_platform/cover.py", line 145, in update
    raise HomeAssistantError(ex, DOMAIN, "hub_exception")
homeassistant.exceptions.HomeAssistantError: (ValidationError(model='EnvironmentSensor', errors=[{'loc': ('attributes', 'currentTemperature'), 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ('attributes', 'currentRH'), 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ('attributes', 'currentPM25'), 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ('attributes', 'maxMeasuredPM25'), 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ('attributes', 'minMeasuredPM25'), 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ('attributes', 'vocIndex'), 'msg': 'field required', 'type': 'value_error.missing'}]), 'dirigera_platform', 'hub_exception')

And i saw there are some copy-paste error in get_blinds_by_id. The blinds tried to be an environmental sensor, but to no avail. Also environment sensor wrong mapping as OpenCloseSensor.