alryaz / hass-hekr-component

Hekr integration using python-hekr
Other
35 stars 11 forks source link

Updates stop #10

Open gennadys72 opened 3 years ago

gennadys72 commented 3 years ago

Hello,

I use this integration with my 3-phase power meter. It works really great, with one exception. From time to time updates just stop, until I reload the integration component. The meter values in HA just freeze, but I've seen a few times when they're marked as "unavailable" This usually happens after WiFi disconnections, but sometimes it just stops without any apparent reason. Would it be possible to implement some kind reconnection mechanism in order to prevent these freezes?

Thanks!

alryaz commented 3 years ago

I'm having a similar issue myself ever since I changed my WiFi router. Could you check whether the device is pingable after the disconnect occurs? If not, I'm afraid it's a firmware issue.

As far as I remember, reconnection is embedded into the component, albeit silent. You'll want to set debug logging to hekrapi:

logging:
  default: warn
  logs:
    custom_components.hekr: debug
    hekrapi: debug

It should produce a lot more data related to connections.

I'll look into this anyway alongside the new energy panel, though.

gennadys72 commented 3 years ago

Hi!

Thanks for the prompt response. Yes, the component is definitely pingable. Always. Moreover, the updates freeze even when there’re no disconnections at all.

All other WiFi-enabled devices on Hassio continue working without a hitch. I’ll enable the debug, and will check if anything meaningful pops up there.

Regards,

Gennady

From: Alexander Ryazanov @.> Sent: Friday, September 3, 2021 20:10 To: alryaz/hass-hekr-component @.> Cc: gennadys72 @.>; Author @.> Subject: Re: [alryaz/hass-hekr-component] Updates stop (#10)

I'm having a similar issue myself ever since I changed my WiFi router. Could you check whether the device is pingable after the disconnect occurs? If not, I'm afraid it's a firmware issue.

As far as I remember, reconnection is embedded into the component, albeit silent. You'll want to set debug logging to hekrapi:

logging: default: warn logs: custom_components.hekr: debug hekrapi: debug

It should produce a lot more data related to connections.

I'll look into this anyway alongside the new energy panel, though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alryaz/hass-hekr-component/issues/10#issuecomment-912685219 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ALTL5UQQC4SIIMTUIHR73I3UAD6NRANCNFSM5DL32APA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/ALTL5USCXVTKL2UD3HAZNZTUAD6NRA5CNFSM5DL32APKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGZTHRIY.gif

alryaz commented 3 years ago

Then the logs will definitely be useful. Please, send them via email (alryaz@xavux.com) or Telegram (@alryaz).

gennadys72 commented 3 years ago

Hello Alexander,

Just enabled the debug and waited until the sensor update hangs. There’s nothing in the logs at all. The component just sits, and the sensors are not updated.

Reloading the integration fixed the problem, as usual.

Starting from yesterday it hangs every hour or so. Before it was once per day. I’ve upgraded firmware on my Ubiquity APs yesterday, so it must be related.

However, all other components seem to work correctly. I’ll continue to check, and revert if there’s something meaningful.

Regards,

Gennady

From: Alexander Ryazanov @.> Sent: Friday, September 3, 2021 20:29 To: alryaz/hass-hekr-component @.> Cc: gennadys72 @.>; Author @.> Subject: Re: [alryaz/hass-hekr-component] Updates stop (#10)

Then the logs will definitely be useful. Please, send them via email @. @.> ) or Telegram @.*** https://github.com/alryaz ).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alryaz/hass-hekr-component/issues/10#issuecomment-912696183 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ALTL5UXPKL35N6SRM35REQ3UAEAW3ANCNFSM5DL32APA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/ALTL5UTW4HIKDNZRJTKUKYDUAEAW3A5CNFSM5DL32APKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGZTKG5Y.gif

gennadys72 commented 3 years ago

Sorry, looked at the wrong logs. It froze at 21:40:03

2021-09-03 21:40:03 DEBUG (MainThread) [custom_components.hekr] Handling data update for HekrSensor entity [sensor.powermeter_detailed_information] with data: {'current_1': 12.538, 'current_2': 18.471, 'current_3': 15.787, 'voltage_1': 226.6, 'voltage_2': 223.6, 'voltage_3': 225.0, 'total_reactive_power': -4.3958, 'reactive_power_1': -1.8536, 'reactive_power_2': -1.4749, 'reactive_power_3': -1.0671, 'total_active_power': 9340.2, 'active_power_1': 2.1252, 'active_power_2': 3.8501, 'active_power_3': 3.3648, 'total_power_factor': 0.886, 'power_factor_1': 0.747, 'power_factor_2': 0.931, 'power_factor_3': 0.946, 'current_frequency': 49.97, 'total_energy_consumed': 128731.94, 'active_energy_import': 128731.94, 'active_energy_export': 0.0, 'mean_current': 15.599, 'total_current': 46.796, 'mean_voltage': 225.1, 'state': 'ok'}

2021-09-03 21:40:03 DEBUG (MainThread) [custom_components.hekr] Handling data update for HekrSensor entity [sensor.powermeter_power_factor] with data: {'current_1': 12.538, 'current_2': 18.471, 'current_3': 15.787, 'voltage_1': 226.6, 'voltage_2': 223.6, 'voltage_3': 225.0, 'total_reactive_power': -4.3958, 'reactive_power_1': -1.8536, 'reactive_power_2': -1.4749, 'reactive_power_3': -1.0671, 'total_active_power': 9340.2, 'active_power_1': 2.1252, 'active_power_2': 3.8501, 'active_power_3': 3.3648, 'total_power_factor': 0.886, 'power_factor_1': 0.747, 'power_factor_2': 0.931, 'power_factor_3': 0.946, 'current_frequency': 49.97, 'total_energy_consumed': 128731.94, 'active_energy_import': 128731.94, 'active_energy_export': 0.0, 'mean_current': 15.599, 'total_current': 46.796, 'mean_voltage': 225.1, 'state': 'ok'}

2021-09-03 21:40:03 DEBUG (MainThread) [custom_components.hekr] Handling data update for HekrSensor entity [sensor.powermeter_active_power] with data: {'current_1': 12.538, 'current_2': 18.471, 'current_3': 15.787, 'voltage_1': 226.6, 'voltage_2': 223.6, 'voltage_3': 225.0, 'total_reactive_power': -4.3958, 'reactive_power_1': -1.8536, 'reactive_power_2': -1.4749, 'reactive_power_3': -1.0671, 'total_active_power': 9340.2, 'active_power_1': 2.1252, 'active_power_2': 3.8501, 'active_power_3': 3.3648, 'total_power_factor': 0.886, 'power_factor_1': 0.747, 'power_factor_2': 0.931, 'power_factor_3': 0.946, 'current_frequency': 49.97, 'total_energy_consumed': 128731.94, 'active_energy_import': 128731.94, 'active_energy_export': 0.0, 'mean_current': 15.599, 'total_current': 46.796, 'mean_voltage': 225.1, 'state': 'ok'}

2021-09-03 21:40:03 DEBUG (MainThread) [custom_components.hekr] Handling data update for HekrSensor entity [sensor.powermeter_mean_voltage] with data: {'current_1': 12.538, 'current_2': 18.471, 'current_3': 15.787, 'voltage_1': 226.6, 'voltage_2': 223.6, 'voltage_3': 225.0, 'total_reactive_power': -4.3958, 'reactive_power_1': -1.8536, 'reactive_power_2': -1.4749, 'reactive_power_3': -1.0671, 'total_active_power': 9340.2, 'active_power_1': 2.1252, 'active_power_2': 3.8501, 'active_power_3': 3.3648, 'total_power_factor': 0.886, 'power_factor_1': 0.747, 'power_factor_2': 0.931, 'power_factor_3': 0.946, 'current_frequency': 49.97, 'total_energy_consumed': 128731.94, 'active_energy_import': 128731.94, 'active_energy_export': 0.0, 'mean_current': 15.599, 'total_current': 46.796, 'mean_voltage': 225.1, 'state': 'ok'}

2021-09-03 21:40:03 DEBUG (MainThread) [custom_components.hekr.hekr_data] Update complete!

2021-09-03 21:40:08 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running updater for device "ESP_2M_BCDDC23C5D0

A" with commands: queryData, queryDev

2021-09-03 21:40:08 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running update command: queryData

2021-09-03 21:40:08 DEBUG (MainThread) [hekrapi.device] Composed request for device <Hekr:Device(ESP_2M_BCDDC23C5D0A)>, content: {"msgId": 372, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "", "appTid": "hass_hekr_python", "data": {"raw": "480602730ACD"}}}

2021-09-03 21:40:08 DEBUG (MainThread) [hekrapi.device] Sending request via <HekrApi:LocalConnector(192.168.89.30:10000)

with content: {"msgId": 372, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "a31789c937a3

48a9b2335035d77d25b9", "appTid": "hass_hekr_python", "data": {"raw": "480602730ACD"}}}

2021-09-03 21:40:08 DEBUG (MainThread) [custom_components.hekr.hekr_data] Sleeping for 4 seconds before running command:

queryDev

2021-09-03 21:40:12 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running update command: queryDev

2021-09-03 21:40:12 DEBUG (MainThread) [hekrapi.device] Composed request for device <Hekr:Device(ESP_2M_BCDDC23C5D0A)>,

content: {"msgId": 373, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "", "appTi

d": "hass_hekr_python", "data": {"raw": "4806027400C4"}}}

2021-09-03 21:40:12 DEBUG (MainThread) [hekrapi.device] Sending request via <HekrApi:LocalConnector(192.168.89.30:10000)

with content: {"msgId": 373, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "a31789c937a3

48a9b2335035d77d25b9", "appTid": "hass_hekr_python", "data": {"raw": "4806027400C4"}}}

2021-09-03 21:40:23 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running updater for device "ESP_2M_BCDDC23C5D0

A" with commands: queryData, queryDev

2021-09-03 21:40:23 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running update command: queryData

2021-09-03 21:40:23 DEBUG (MainThread) [hekrapi.device] Composed request for device <Hekr:Device(ESP_2M_BCDDC23C5D0A)>, content: {"msgId": 374, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "", "appTid": "hass_hekr_python", "data": {"raw": "480602750ACF"}}}

2021-09-03 21:40:23 DEBUG (MainThread) [hekrapi.device] Sending request via <HekrApi:LocalConnector(192.168.89.30:10000)> with content: {"msgId": 374, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "appTid": "hass_hekr_python", "data": {"raw": "480602750ACF"}}}

2021-09-03 21:40:23 DEBUG (MainThread) [hekrapi.device] Sending request via <HekrApi:LocalConnector(192.168.89.30:10000)> with content: {"msgId": 374, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "appTid": "hass_hekr_python", "data": {"raw": "480602750ACF"}}}

2021-09-03 21:40:23 DEBUG (MainThread) [custom_components.hekr.hekr_data] Sleeping for 4 seconds before running command: queryDev

2021-09-03 21:40:27 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running update command: queryDev

2021-09-03 21:40:27 DEBUG (MainThread) [hekrapi.device] Composed request for device <Hekr:Device(ESP_2M_BCDDC23C5D0A)>, content: {"msgId": 375, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "", "appTid": "hass_hekr_python", "data": {"raw": "4806027600C6"}}}

2021-09-03 21:40:27 DEBUG (MainThread) [hekrapi.device] Sending request via <HekrApi:LocalConnector(192.168.89.30:10000)

with content: {"msgId": 375, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "a31789c937a3

48a9b2335035d77d25b9", "appTid": "hass_hekr_python", "data": {"raw": "4806027600C6"}}}

2021-09-03 21:40:38 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running updater for device "ESP_2M_BCDDC23C5D0A" with commands: queryData, queryDev

2021-09-03 21:40:38 DEBUG (MainThread) [custom_components.hekr.hekr_data] Running update command: queryData

2021-09-03 21:40:38 DEBUG (MainThread) [hekrapi.device] Composed request for device <Hekr:Device(ESP_2M_BCDDC23C5D0A)>, content: {"msgId": 376, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "", "appTid": "hass_hekr_python", "data": {"raw": "480602770AD1"}}}

2021-09-03 21:40:38 DEBUG (MainThread) [hekrapi.device] Sending request via <HekrApi:LocalConnector(192.168.89.30:10000)> with content: {"msgId": 376, "action": "appSend", "params": {"devTid": "ESP_2M_BCDDC23C5D0A", "ctrlKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "appTid": "hass_hekr_python", "data": {"raw": "480602770AD1"}}}

2021-09-03 21:40:38 DEBUG (MainThread) [custom_components.hekr.hekr_data] Sleeping for 4 seconds before running command: queryDev

From: Gennady Sorokopud @.> Sent: Friday, September 3, 2021 21:57 To: 'alryaz/hass-hekr-component' @.>; 'alryaz/hass-hekr-component' @.> Cc: 'Author' @.> Subject: RE: [alryaz/hass-hekr-component] Updates stop (#10)

Hello Alexander,

Just enabled the debug and waited until the sensor update hangs. There’s nothing in the logs at all. The component just sits, and the sensors are not updated.

Reloading the integration fixed the problem, as usual.

Starting from yesterday it hangs every hour or so. Before it was once per day. I’ve upgraded firmware on my Ubiquity APs yesterday, so it must be related.

However, all other components seem to work correctly. I’ll continue to check, and revert if there’s something meaningful.

Regards,

Gennady

From: Alexander Ryazanov @. @.> > Sent: Friday, September 3, 2021 20:29 To: alryaz/hass-hekr-component @. @.> > Cc: gennadys72 @. @.> >; Author @. @.> > Subject: Re: [alryaz/hass-hekr-component] Updates stop (#10)

Then the logs will definitely be useful. Please, send them via email @. @.> ) or Telegram @.*** https://github.com/alryaz ).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alryaz/hass-hekr-component/issues/10#issuecomment-912696183 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ALTL5UXPKL35N6SRM35REQ3UAEAW3ANCNFSM5DL32APA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/ALTL5UTW4HIKDNZRJTKUKYDUAEAW3A5CNFSM5DL32APKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGZTKG5Y.gif

alryaz commented 3 years ago

I might have found the culprit, but I can't confirm it as our issues differ. The underlying library does attempt to reconnect, but doesn't try to reauthenticate unless the endpoint is completely closed.

I will have to work on the issue for a bit more to rule out a better solution to this issue.

gennadys72 commented 3 years ago

Thanks for sharing. Let me know if you need me to test your changes. In the meantime, I use simple automation to reload the integration:

alias: Powermeter stuck

description: ''

trigger:

condition: []

action:

mode: single

rest_command:

reload_hekr:

url: http://192.168.XX.YY:8123/api/config/config_entries/entry/60208354e40b1f8d8ccf9972ab8770f1/reload

method: POST

headers:

  authorization: 'Bearer xxxxx'

  Content-Type: 'application/json'

From: Alexander Ryazanov @.> Sent: Wednesday, September 15, 2021 18:24 To: alryaz/hass-hekr-component @.> Cc: gennadys72 @.>; Author @.> Subject: Re: [alryaz/hass-hekr-component] Updates stop (#10)

I might have found the culprit, but I can't confirm it as our issues differ. The underlying library does attempt to reconnect, but doesn't try to reauthenticate unless the endpoint is completely closed.

I will have to work on the issue for a bit more to rule out a better solution to this issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/alryaz/hass-hekr-component/issues/10#issuecomment-920119859 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ALTL5UT4PLUKRPZJBIS7ZELUCC3ANANCNFSM5DL32APA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/ALTL5UVSEAYVM4V6BREXGMDUCC3ANA5CNFSM5DL32APKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG3L6UMY.gif

sebaq3 commented 2 years ago

Hi, I have exactly the same symptoms. Could this be resolved?