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

Wrong blinds and environment sensor type mapping #12

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

slajob
Copy link
Collaborator

@slajob slajob commented Mar 3, 2024

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.

… an environmental sensor, but to no avail :P

Also environment sensor wrong mapping as OpenCloseSensor
@sanjoyg sanjoyg merged commit 49c85a3 into sanjoyg:main Mar 4, 2024
3 checks passed
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 this pull request may close these issues.

2 participants