ha-emporia-vue icon indicating copy to clipboard operation
ha-emporia-vue copied to clipboard

1MIN sensors become inactive

Open ejkreboot opened this issue 2 years ago • 26 comments

After running for a while (maybe a couple hours?) my _1MIN sensors become inactive, even though the mains sensor continue to work. So for the mains I see:

image

But for a specific sensor I see:

image

Here is another look at the data:

image

The _1D and _1MON sensors continue to work as expected.

Any idea what the problem could be or what additional debugging info I can provide? Thank you!

ejkreboot avatar May 18 '22 16:05 ejkreboot

After uninstalling and reinstalling the add on it has now been working properly for the last 12 hours.

ejkreboot avatar May 21 '22 14:05 ejkreboot

After working well for several days, the problem has recurred. Any pointers as to how to help debug? Thank you!

ejkreboot avatar May 24 '22 11:05 ejkreboot

I am having the same issues as well. I have to reload the integration to get them to come back online.

RyanAHolland avatar May 24 '22 16:05 RyanAHolland

@ejkreboot If you are looking for a work around, you can use the reload entity command in an automation. If you sensor becomes unavailable, you can run the following

service: homeassistant.reload_config_entry
data: {]
target:
  entity_id: sensor.dryer_1_1min

RyanAHolland avatar May 24 '22 16:05 RyanAHolland

For debugging, check if there are any errors in the logs for the emporia_vue component (url is usually something like https://localhost:8123/config/logs). There will almost definitely be a couple from the API being unreliable, but there shouldn't be any that have tens or hundreds of occurrences under normal circumstances. If there are any like that, those would be interesting to see.

Also you could try out the v0.8 pre-release to see if it's any more stable. There are a number of changes in there including a couple bugfixes that might help.

If the logs aren't giving you enough info, you can call a service to set the log level to more verbose for the emporia_vue component. At the info level there's a decent amount of raw API output, especially at startup, that might be useful for debugging.

service: logger.set_level
data:
  custom_components.emporia_vue: info

magico13 avatar May 24 '22 17:05 magico13

@RyanAHolland thanks for the tip! That does indeed seem to get things working again for a while

@magico13 I tried the pre-release and had the same problem. I set the logger to debug level and did not see any problems.

(Is it possible I am just getting blacklisted by the Emporia vue API by requesting the minute data on every device at the same time? Or does the integration throttle that on the back end?)

ejkreboot avatar May 25 '22 03:05 ejkreboot

I have the same issue. I have a few automations that stop working because all of the sensors with 1 MIN stop responding. Reloading the integration seems to work but I'd pretty much have to do that every day it seems.

efbick avatar Jun 04 '22 20:06 efbick

Yes I have an automation that checks every 15 minutes and if they are unavailable I call the homeassistant.reload_config_entry service mentioned above. Another solution is to define a "Utility Meter" helper on the 1 Day sensors. These sensors record data at brief intervals over the course of the day to get the cumulative usage for the day, so if I create a Utility Meter helper for this sensor that resets to zero every few minutes I get the (nearly) instantaneous energy utilization.

ejkreboot avatar Jun 05 '22 13:06 ejkreboot

I’m running into this issue any time I restart homeassistant. Reloading the integration manually fixes it. I’ll add an automation to check and reload.

apetryk2 avatar Jul 19 '22 17:07 apetryk2

I think I get this problem too.

I've tried putting utility meter helpers around both the 1 day and 1 minute sensors, but it doesn't seem to make a difference.

I'll try out an automated reload of the integration, but feels like it'll be laggy.

Here's the error logged when the 1 minute sensors go inactive:

This error originated from a custom integration.

Logger: homeassistant Source: custom_components/emporia_vue/sensor.py:90 Integration: Emporia Vue (documentation) First occurred: 09:31:12 (119 occurrences) Last logged: 11:57:50

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state if (state := self.state) is None: File "/config/custom_components/emporia_vue/sensor.py", line 90, in state usage = self.coordinator.data[self._id]["usage"] KeyError: '90425-16-1MIN'

joeljeffery avatar Aug 29 '22 11:08 joeljeffery

I think I get this problem too.

I've tried putting utility meter helpers around both the 1 day and 1 minute sensors, but it doesn't seem to make a difference.

I'll try out an automated reload of the integration, but feels like it'll be laggy.

Here's the error logged when the 1 minute sensors go inactive:

This error originated from a custom integration. Logger: homeassistant Source: custom_components/emporia_vue/sensor.py:90 Integration: Emporia Vue (documentation) First occurred: 09:31:12 (119 occurrences) Last logged: 11:57:50 Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 110, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 348, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state if (state := self.state) is None: File "/config/custom_components/emporia_vue/sensor.py", line 90, in state usage = self.coordinator.data[self._id]["usage"] KeyError: '90425-16-1MIN'

I'm also having this same issue. The hr and month stats continue to work

Can you share how you've scripted an auto restart?

billytkid avatar Sep 05 '22 16:09 billytkid

Hi @billytkid!

First, I created an area called “Emporia Vue”, and stuck all the Emporia 1 minute entities in it.

Here’s the automation:

alias: Emporia Sensor Poker
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      area_id: emporia_vue
mode: single

I had it set to hourly, but it the sensors were still bugging out, so it now runs every 15 minutes. :(

Also, I’ve not played around to see what is the minimum number of entities I actually need to reload.

Hope this works for you in the meantime!

Joel

joeljeffery avatar Sep 05 '22 16:09 joeljeffery

Great, thank you!

billytkid avatar Sep 12 '22 10:09 billytkid

Having the same issure here, all sensors become unavailable after some time,. after a restart of the integration the sensors are available again for about a day

nad22 avatar Sep 20 '22 07:09 nad22

Hi, I've put this automation in place, it seems you only need to reload one sensor: `alias: Emporia Sensor Reboot description: "" trigger:

  • platform: time_pattern hours: "1" minutes: "0" seconds: "0" condition: [] action:
  • service: homeassistant.reload_config_entry data: {} target: entity_id: sensor.car_charger_10_1min mode: single `

billytkid avatar Sep 20 '22 07:09 billytkid

@billytkid - I have an automation that uses the 1 minute sensors to decide how to charge various home batteries, the car, etc, based on the amount of solar I've got spare. I found that reloading the sensors every hour didn't quite cut it. I was still losing data. In the end I have a repeat-every-14-minutes schedule for the Emporia reloader. Is the hour reload definitely working for you?

I've taken your advice above, and now I'm just reloading a single sensor (every 14 mins). I'll keep an eye on that and report back :)

joeljeffery avatar Sep 20 '22 08:09 joeljeffery

@joeljeffery the reboot is working, however the issue I've got is that the trigger sometimes fails - not sure why HA isnt running this every hour. I've updated mine to 14 mins too

billytkid avatar Sep 20 '22 08:09 billytkid

... found out the answer. Do NOT put in '0' in hours and minutes, leave those blank, and in the minute trigger put /14 :)

billytkid avatar Sep 20 '22 11:09 billytkid

@billytkid Seconded :)

image

joeljeffery avatar Sep 20 '22 11:09 joeljeffery

I've noticed this as well. It's not definite, but it seems to work fine until I open the Emporia app on my phone, and then shortly afterwards the 1 Min sensors become inactive. Force kill the app on my phone, and the sensors seem to come back after a while.

So, I've started trying to use Home Assistant to view the data rather than the Emporia app

pscs avatar Oct 12 '22 16:10 pscs

I've noticed this issue most often when restarting Home Assistant, so I created an automation that reloads the integration (1) when Home Assistant starts and (2) when one of my 1MIN sensors is unknown or unavailable for more than 2 minutes.

Any leads on addressing the underlying issue rather than relying on this workaround?

krazos avatar Nov 06 '22 14:11 krazos

I've noticed this issue most often when restarting Home Assistant, so I created an automation that reloads the integration (1) when Home Assistant starts and (2) when one of my 1MIN sensors is unknown or unavailable for more than 2 minutes.

Any leads on addressing the underlying issue rather than relying on this workaround?

Hi, could you share the yaml code that you used in the automation? Thank!!!

sekonicpr avatar Nov 17 '22 22:11 sekonicpr

I've noticed this issue most often when restarting Home Assistant, so I created an automation that reloads the integration (1) when Home Assistant starts and (2) when one of my 1MIN sensors is unknown or unavailable for more than 2 minutes.

Any leads on addressing the underlying issue rather than relying on this workaround?

Hi, could you share the yaml code that you used in the automation? Thank!!!

Here's the automation I'm using currently. For the triggers, I picked one of my 1 MIN sensors because they typically all go unavailable/unknown at the same time. You could pick more than one sensor to be safe, if you like. I also recently added a repeat because occasionally one reload wouldn't do the trick.

EDIT: Code wall removed. See Gist instead:

GitHub Gist - krazos / ha_emporia_vue_reload.yaml

krazos avatar Nov 17 '22 23:11 krazos

I've noticed this issue most often when restarting Home Assistant, so I created an automation that reloads the integration (1) when Home Assistant starts and (2) when one of my 1MIN sensors is unknown or unavailable for more than 2 minutes.

Any leads on addressing the underlying issue rather than relying on this workaround?

Hi, could you share the yaml code that you used in the automation? Thank!!!

Here's the automation I'm using currently. For the triggers, I picked one of my 1 MIN sensors because they typically all go unavailable/unknown at the same time. You could pick more than one sensor to be safe, if you like. I also recently added a repeat because occasionally one reload wouldn't do the trick.

alias: Reload Emporia Vue Integration
description: ""
trigger:
  - platform: homeassistant
    event: start
  - platform: state
    entity_id:
      - sensor.solar_1_1min
    to: unavailable
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - platform: state
    entity_id:
      - sensor.solar_1_1min
    to: unknown
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition: []
action:
  - repeat:
      while:
        - condition: or
          conditions:
            - condition: state
              entity_id: sensor.solar_1_1min
              state: unavailable
            - condition: state
              entity_id: sensor.solar_1_1min
              state: unknown
      sequence:
        - service: homeassistant.reload_config_entry
          data: {}
          target:
            entity_id: sensor.solar_1_1min
        - service: notify.telegram
          data:
            message: Emporia Vue integration reloaded
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
mode: single

@krazos Thanks for the help, I had been doing the manual reload for a long time practically every day.

sekonicpr avatar Nov 17 '22 23:11 sekonicpr

@krazos Thanks for the help, I had been doing the manual reload for a long time practically every day.

It occurred to me that I should limit the number of loops in case Emporia's cloud service is down or otherwise unreachable (e.g., power or internet outage). I will likely continue to tweak the automation, so I have created a Gist in case anyone is interested in those refinements:

GitHub Gist - krazos / ha_emporia_vue_reload.yaml

krazos avatar Nov 18 '22 13:11 krazos

@magico13 Is this happening on the API side too or is there something that could be done with the integration to (a) stop the 1min sensors from going unavailable and/or (b) return to the available state once the API starts reporting valid data?

Thanks for making this integration available!

GitHubGoody avatar Feb 11 '23 12:02 GitHubGoody