ksheumaker / homeassistant-apsystems_ecur

Home Assistant custom component for local querying of APSystems ECU-R Solar System
Apache License 2.0
178 stars 43 forks source link

RuntimeWarning on HA 2021.12.6 #26

Closed dclobato closed 2 years ago

dclobato commented 2 years ago

During startup, the following message is printed on the logfile

/config/custom_components/apsystems_ecur/__init__.py:141: RuntimeWarning: coroutine 'DataUpdateCoordinator.async_refresh'
was never awaited coordinator.async_refresh()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

No further error occurs...

HAEdwin commented 2 years ago

Does this occur consistently when restarting HA? I can't reproduce this so expect it to be a confluence of HA startup conditions. Possible performance or conflict. Are you calling the service to stop the query on HA startup?

dclobato commented 2 years ago

Yes, I am... There is an automation to call stop query when the HA starts and the sun is below horizon :-/

- id: '1640668287934'
  alias: APSystems -- Parar de consultar a ECU durante a noite
  description: ''
  trigger:
  - platform: sun
    event: sunset
  condition: []
  action:
  - service: apsystems_ecur.stop_query
  mode: single
- id: '1640668350315'
  alias: APSystems -- Retomar as consultas aa ECU durante o dia
  description: ''
  trigger:
  - platform: sun
    event: sunrise
  condition: []
  action:
  - service: apsystems_ecur.start_query
  mode: single
- id: '1640668829124'
  alias: APSystems -- Ajustar as consultas aa ECU no inicio do servidor
  description: ''
  trigger:
  - platform: homeassistant
    event: start
  condition: []
  action:
  - service: apsystems_ecur.start_query
  - choose:
    - conditions:
      - condition: state
        entity_id: sun.sun
        state: below_horizon
      sequence:
      - delay:
          hours: 0
          minutes: 0
          seconds: 45
          milliseconds: 0
      - service: apsystems_ecur.stop_query
    default: []
  mode: single
HAEdwin commented 2 years ago

Is it an option for you to add a delay to stop the query also at startup? This way HA can startup and servicecall to stop the query will execute after that? It is known that you can let the integration query the ECU without interruption 24/7. This only results in error log lines because the ECU does some maintenance between 02:45 and 03:15 in the early morning and closes port 8899 but this does not result in further problems, the integration picks it up later on when 8899 becomes available again. I'm thinking it would be a nice addition to the integration to make error handling optional or suppress notifications if they occur more than x times. Currently I tweak the integration by remarking lines self.cache_count += 1 in init.py and remarking current_attempt += 1 in APSystemsECUR.py (to keep the code line count intact for reference).

dclobato commented 2 years ago

I was starting/stopping to suppress errors on log. I'll keep the service querying... thanks