home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.41k stars 29.9k forks source link

edl21 sometimes freezed due to causing unhandled sensor warnings in the logs and leads to dissappearing entities. #64696

Closed pausenpepe closed 2 years ago

pausenpepe commented 2 years ago

The problem

Sometimes edl21 freezes and is not updating values. In the case edl21 is in the freeze state, this can lead to dissappearing entity (other sensors) Related to: https://github.com/home-assistant/core/issues/61675 https://github.com/home-assistant/core/issues/63247 The log is showing unhandled sensor entries and the following warning: "Detected integration that called async_timeout.timeout with loop keyword argument."

What version of Home Assistant Core has the issue?

core-2021.12.10

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/

Example YAML snippet

#Smart Meter edl21 SML
sensor:
  - platform: edl21
    name: Stromzaehler
    serial_port: /dev/ttyUSB0

template:
  - sensor:
      - name: Energy from Grid
        state: >
          {% set pwrin = states('sensor.stromzaehler_positive_active_energy_total') | float %}
          {{ pwrin / 1000 | round(3) }}
        unit_of_measurement: kWh
        state_class: total_increasing
        device_class: energy

Anything in the logs that might be useful for us?

Logger: homeassistant.components.edl21.sensor
Source: components/edl21/sensor.py:197
Integration: edl21 (documentation, issues)
First occurred: 5:38:41 AM (5 occurrences)
Last logged: 5:38:41 AM

Unhandled sensor 1-0:81.7.1*255 detected. Please report at https://github.com/home-assistant/core/issues?q=is%3Aissue+label%3A"integration%3A+edl21"+
Unhandled sensor 1-0:81.7.2*255 detected. Please report at https://github.com/home-assistant/core/issues?q=is%3Aissue+label%3A"integration%3A+edl21"+
Unhandled sensor 1-0:97.97.0*0 detected. Please report at https://github.com/home-assistant/core/issues?q=is%3Aissue+label%3A"integration%3A+edl21"+
Unhandled sensor 1-0:96.50.1*4 detected. Please report at https://github.com/home-assistant/core/issues?q=is%3Aissue+label%3A"integration%3A+edl21"+
Unhandled sensor 1-0:96.50.4*4 detected. Please report at https://github.com/home-assistant/core/issues?q=is%3Aissue+label%3A"integration%3A+edl21"+

Related to async with loop keyword argument:
Logger: homeassistant.helpers.frame
Source: helpers/frame.py:103
First occurred: 5:38:38 AM (1 occurrences)
Last logged: 5:38:38 AM

Detected integration that called async_timeout.timeout with loop keyword argument. The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2. Please report issue for edl21 using this method at homeassistant/components/edl21/sensor.py, line 163: await self._proto.connect(self._hass.loop)

Problem with energy/info:
Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:89
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:38:36 AM (2 occurrences)
Last logged: 5:38:36 AM

[548421119472] Received invalid command: energy/info

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

edl21 documentation edl21 source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

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)

pausenpepe commented 2 years ago

I just forget to mention that the smart meter is an EFR SGM-C4-4A920L. manufacturer: EFR model: SGM-C4-4A920L The missing sensors are: 1-0:81.7.1255 U(L2) to U(L1) phase angle 1-0:81.7.2255 U(L3) to U(L1) phase angle 1-0:97.97.00 error register 1-0:96.50.14 hardware revision 1-0:96.50.4*4 ??no info ??

I guess the 1-0:81.7* could be handled in the following manner inside the sensor types: ` # C=81: Angles

D=7: Instantaneous value

# E=1:  U(L2) x U(L1)
# E=2:  U(L3) x U(L1)
# E=4:  U(L1) x I(L1)
# E=15: U(L2) x I(L2)
# E=26: U(L3) x I(L3)
SensorEntityDescription(
    key="1-0:81.7.1*255", name="U(L2)/U(L1) phase angle", icon="mdi:sine-wave"
),
SensorEntityDescription(
    key="1-0:81.7.2*255", name="U(L3)/U(L1) phase angle", icon="mdi:sine-wave"
),
SensorEntityDescription(
    key="1-0:81.7.4*255", name="U(L1)/I(L1) phase angle", icon="mdi:sine-wave"
),
SensorEntityDescription(
    key="1-0:81.7.15*255", name="U(L2)/I(L2) phase angle", icon="mdi:sine-wave"
),
SensorEntityDescription(
    key="1-0:81.7.26*255", name="U(L3)/I(L3) phase angle", icon="mdi:sine-wave"
),`

The remaining stuff could be sent to the Blacklist:

` _OBIS_BLACKLIST = {

C=96: Electricity-related service entries

    "1-0:96.50.1*1",  # Manufacturer specific EFR SGM-C4 hardware revision
    "1-0:96.50.1*4",  # Manufacturer specific EFR SGM-C4 hardware revision
    "1-0:96.50.4*4",  # Manufacturer specific
    "1-0:96.90.2*1",  # Manufacturer specific
    "1-0:96.90.2*2",  # Manufacturer specific
    # C=97: Electricity-related service entries
    "1-0:97.97.0*0",  # Manufacturer specific EFR SGM-C4 error register
    # A=129: Manufacturer specific
    "129-129:199.130.3*255",  # Iskraemeco: Manufacturer
    "129-129:199.130.5*255",  # Iskraemeco: Public Key
 }`

I hope i am right

mtdcr commented 2 years ago

Do you have issues with your usbserial converter? Any reconnects happening when it freezes?

Can you please prepare a pull-request for the missing sensors?

pausenpepe commented 2 years ago

@mtdcr Do you have issues with your usbserial converter? Any reconnects happening when it freezes? Not 100% sure i just checked the history files and the logs and it was not occuring again. I did some hardware adaptions like using a USB extension cable for the CONBEE2 and checked the connection to the "USB IR Lesekopf EHZ Lese-Schreib-Kopf Volkszähler Hichi Smartmeter". The missing data of the other sensor was most likely related to a bad zigbee link. I rearranged the zigbee setup and the signal level is much better. I will keep an eye on the logs and check whether the behavior will show up again.

Can you please prepare a pull-request for the missing sensors? I am pretty new to github and still on a "dummmy" level, so i don´t know how to do place it.

By the way is there an way to test it first on my system? Unfortunately i really got lost in searching for the topic how to customize an integration for testing. If you can send me a link to a "quick start" preferable in German would be great. In this case i can test it with my setup first ;)

pausenpepe commented 2 years ago

Small status update: The issues with freezing sensor are dissappeared since the change of the zigbee network setup.

First test with the code for the sensors is running now and looking fine :) No further warnings regarding unhandled sensors in the log.

image No suprise that the phase angles are ~120° to each other, but it is working.

Note to myself: https://developers.home-assistant.io/docs/creating_integration_file_structure

I still dont know how to file in a pull-request.

mtdcr commented 2 years ago

@pausenpepe To create a pull-request, you need to press the fork button while viewing the home-assistant/core repository. Then you can edit files in your fork (pausenpepe/core) and save your work (do a commit), either by using a Git client and a local text editor or by using the text editor of GitHub. After that, GitHub will offer a "create pull request" button. It will show you a diff between your branch and your target branch (should be home-assistant/core:dev). Follow the on-screen instructions from there. Make sure the diff contains only those changes you intended to make.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.