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

edl21 reports issue adding entities #70121

Closed
weidi opened this issue Apr 15, 2022 · 4 comments · Fixed by #74838
Closed

edl21 reports issue adding entities #70121

weidi opened this issue Apr 15, 2022 · 4 comments · Fixed by #74838

Comments

@weidi
Copy link

weidi commented Apr 15, 2022

The problem

One of two edl21 sensors is not very reliable and there is an error reported in homeassistant log.
It sounds like a problem implemented with #64926
Think the phase angle measured in ° is not handled correctly.

What version of Home Assistant Core has the issue?

core-2022.4.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

edl21

Link to integration documentation on our website

https://www.home-assistant.io/integrations/edl21

Diagnostics information

No response

Example YAML snippet

sensor:
  - platform: edl21
    serial_port: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
    name: Haushaltsstrom
  - platform: edl21
    serial_port: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0045-if00-port0
    name: Heizungsstrom

Anything in the logs that might be useful for us?

2022-04-15 21:13:22 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform edl21
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 525, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 397, in unit_of_measurement
    native_unit_of_measurement = self.native_unit_of_measurement
  File "/usr/src/homeassistant/homeassistant/components/edl21/sensor.py", line 456, in native_unit_of_measurement
    return SENSOR_UNIT_MAPPING[unit]
KeyError: '°'

2022-04-15 21:13:24 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform edl21
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 525, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 397, in unit_of_measurement
    native_unit_of_measurement = self.native_unit_of_measurement
  File "/usr/src/homeassistant/homeassistant/components/edl21/sensor.py", line 456, in native_unit_of_measurement
    return SENSOR_UNIT_MAPPING[unit]
KeyError: '°'

Additional information

No response

@probot-home-assistant
Copy link

edl21 documentation
edl21 source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @mtdcr, mind taking a look at this issue as it has been labeled with an integration (edl21) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@weidi
Copy link
Author

weidi commented Apr 15, 2022

might be just adding DEGREE "°"

from homeassistant.const import (
    CONF_NAME,
    ELECTRIC_CURRENT_AMPERE,
    ELECTRIC_POTENTIAL_VOLT,
    ENERGY_KILO_WATT_HOUR,
    ENERGY_WATT_HOUR,
    POWER_WATT,
    DEGREE,
)


SENSOR_UNIT_MAPPING = {
    "Wh": ENERGY_WATT_HOUR,
    "kWh": ENERGY_KILO_WATT_HOUR,
    "W": POWER_WATT,
    "A": ELECTRIC_CURRENT_AMPERE,
    "V": ELECTRIC_POTENTIAL_VOLT,
    "°": DEGREE,
}

@ufozone
Copy link

ufozone commented Apr 29, 2022

Same issue, but other KeyError:

2022-04-29 21:57:24 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform edl21
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 525, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 397, in unit_of_measurement
    native_unit_of_measurement = self.native_unit_of_measurement
  File "/usr/src/homeassistant/homeassistant/components/edl21/sensor.py", line 456, in native_unit_of_measurement
    return SENSOR_UNIT_MAPPING[unit]
KeyError: 0
2022-04-29 21:57:26 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 525, in _async_add_entity
    unit_of_measurement=entity.unit_of_measurement,
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 397, in unit_of_measurement
    native_unit_of_measurement = self.native_unit_of_measurement
  File "/usr/src/homeassistant/homeassistant/components/edl21/sensor.py", line 456, in native_unit_of_measurement
    return SENSOR_UNIT_MAPPING[unit]
KeyError: 0

StephanU added a commit to StephanU/home-assistant that referenced this issue Jul 9, 2022
frenck pushed a commit that referenced this issue Jul 9, 2022
@balloob balloob mentioned this issue Jul 10, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants