ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
267 stars 34 forks source link

Switch not updating. #144

Closed njschwartz closed 1 month ago

njschwartz commented 2 months ago

I just noticed today that my docker switch is no longer updating as expected. The switch still works to control the container, I can start or stop a contained with it as expected. However if I manually stop a container the switch remains on. I know it worked before because I had an automation that would send me a notification if a container stopped unexpectedly for some reason. I see the following error and warning in the HA debug logs:

This error originated from a custom integration.

Logger: custom_components.monitor_docker.helpers
Source: custom_components/monitor_docker/helpers.py:757
integration: Monitor Docker (documentation, issues)
First occurred: 5:22:37 PM (2 occurrences)
Last logged: 5:22:54 PM

[Docker] NodeRed: Container not available anymore (3) (Detected that custom integration 'monitor_docker' calls async_write_ha_state from a thread at custom_components/monitor_docker/switch.py, line 227: self.async_schedule_update_ha_state(). Please report it to the author of the 'monitor_docker' custom integration.)
[Docker] qbittorrent: Container not available anymore (3) (Detected that custom integration 'monitor_docker' calls async_write_ha_state from a thread at custom_components/monitor_docker/switch.py, line 227: self.async_schedule_update_ha_state(). Please report it to the author of the 'monitor_docker' custom integration.)
Traceback (most recent call last):
  File "/config/custom_components/monitor_docker/helpers.py", line 757, in _run
    self._notify()
  File "/config/custom_components/monitor_docker/helpers.py", line 1310, in _notify
    callback()
  File "/config/custom_components/monitor_docker/switch.py", line 227, in event_callback
    self.async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1258, in async_schedule_update_ha_state
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state
    self.hass.verify_event_loop_thread("async_write_ha_state")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'monitor_docker' calls async_write_ha_state from a thread at custom_components/monitor_docker/switch.py, line 227: self.async_schedule_update_ha_state(). Please report it to the author of the 'monitor_docker' custom integration.
Logger: homeassistant.helpers.frame
Source: helpers/frame.py:190
First occurred: 5:22:37 PM (2 occurrences)
Last logged: 5:22:54 PM

Detected that custom integration 'monitor_docker' calls async_write_ha_state from a thread at custom_components/monitor_docker/switch.py, line 227: self.async_schedule_update_ha_state(), please report it to the author of the 'monitor_docker' custom integration

I appreciate any suggestions or fixes ypu might have. This is a great and super useful tool for me so I hope I can get this working again. Appreciate it!

njschwartz commented 2 months ago

For anyone that cares I found a fix to this. In the switch.py file I just had to change the three lines that use self.async_schedule_update_ha_state() and remove the async part. It is something that changed with the latest HA update I guess.

chris-mc1 commented 2 months ago

These Bugs have been fix for a while, but there hasn't been a Release for over two Years. You can install the newest version by manually changing the Version in HACS to "master".

@ualex73 Could you create a new Release?

njschwartz commented 1 month ago

@chris-mc1 Thanks for that info. I did not know that. I will try that too. Hope it gets updated in the future as this is super useful.

ualex73 commented 1 month ago

These Bugs have been fix for a while, but there hasn't been a Release for over two Years. You can install the newest version by manually changing the Version in HACS to "master".

@ualex73 Could you create a new Release?

I just did release v1.15.

ualex73 commented 1 month ago

I released the master as v1.15. I will close this ticket, please reopen if you find another issue.