ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
289 stars 35 forks source link

Switch error #20

Closed malinduta closed 4 years ago

malinduta commented 4 years ago

Works to start/stop containers, but throws error when starting HA.

Configuration:

monitor_docker:
  - name: Docker
    containers:
      - urbackup
    rename:
      urbackup: UrBackup
    monitored_conditions:
      - version
      - containers_running
      - containers_total
      - state
      - status
      - memory

Log:

Log Details (ERROR)
Logger: homeassistant.config
Source: config.py:756
First occurred: 1:17:19 AM (1 occurrences)
Last logged: 1:17:19 AM

Invalid config for [switch]: expected a dictionary. Got True. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/switch

This is the notification:

ualex73 commented 4 years ago

The error itself doesn't describe where the problem is.

Can you add the following to your logging configuration: custom_components.monitor_docker: debug

Then restart and share the logfile with me.

malinduta commented 4 years ago

Done. The log is identical.

ualex73 commented 4 years ago

The debug log will be difficult, can you supply that? Otherwise I have no idea where this error is coming from.

malinduta commented 4 years ago

I would supply, but how?

malinduta commented 4 years ago

I thing I found something. Hope it helps.

2020-07-13 08:43:34 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for monitor_docker which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] Docker version: 19.03.12
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] addon_core_configurator: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_multicast: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] Version: 19.03.12, Containers: 10, Running: 8, CPU: None%, Memory: NoneMB, None%
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_cli: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_audio: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_dns: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] homeassistant: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_supervisor: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] urbackup: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] duckdns: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] urbackup: Exited (0) 6 hours ago
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] portainer: Container Monitored
2020-07-13 08:43:38 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] duckdns: Exited (0) 6 hours ago
2020-07-13 08:43:39 ERROR (MainThread) [homeassistant.config] Invalid config for [switch]: expected a dictionary. Got True. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/switch
2020-07-13 08:43:39 INFO (MainThread) [custom_components.monitor_docker.sensor] Initializing Docker sensor 'version'
2020-07-13 08:43:39 INFO (MainThread) [custom_components.monitor_docker.sensor] Initializing Docker sensor 'containers_running'
2020-07-13 08:43:39 INFO (MainThread) [custom_components.monitor_docker.sensor] Initializing Docker sensor 'containers_total'
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.sensor] urbackup: Adding component Sensor(s)
2020-07-13 08:43:39 INFO (MainThread) [custom_components.monitor_docker.sensor] urbackup: Initializing sensor with parameter: State
2020-07-13 08:43:39 INFO (MainThread) [custom_components.monitor_docker.sensor] urbackup: Initializing sensor with parameter: Status
2020-07-13 08:43:39 INFO (MainThread) [custom_components.monitor_docker.sensor] urbackup: Initializing sensor with parameter: Memory
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.switch] urbackup: Adding component Switch
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.helpers] urbackup: Added callback to container, entity: switch
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.helpers] urbackup: Added callback to container, entity: state
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.sensor] urbackup: Received callback for: State
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.helpers] urbackup: Added callback to container, entity: status
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.sensor] urbackup: Received callback for: Status
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.helpers] urbackup: Added callback to container, entity: memory
2020-07-13 08:43:39 DEBUG (MainThread) [custom_components.monitor_docker.sensor] urbackup: Received callback for: Memory
2020-07-13 08:43:39 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] addon_core_configurator: CPU Usage=None%. Memory Usage=14.16MB, 0.36%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_cli: CPU Usage=None%. Memory Usage=1.82MB, 0.05%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_audio: CPU Usage=None%. Memory Usage=6.79MB, 0.17%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_dns: CPU Usage=None%. Memory Usage=8.0MB, 0.2%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] homeassistant: CPU Usage=None%. Memory Usage=64.62MB, 1.65%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_supervisor: CPU Usage=None%. Memory Usage=38.61MB, 0.99%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] portainer: CPU Usage=None%. Memory Usage=9.17MB, 0.23%
2020-07-13 08:43:40 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] hassio_multicast: CPU Usage=None%. Memory Usage=2.15MB, 0.06%
2020-07-13 08:43:48 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] urbackup: Exited (0) 6 hours ago
2020-07-13 08:43:48 DEBUG (Thread-2) [custom_components.monitor_docker.helpers] urbackup: Send notify (4) to container
2020-07-13 08:43:48 DEBUG (Thread-2) [custom_components.monitor_docker.sensor] urbackup: Received callback for: State
2020-07-13 08:43:48 DEBUG (Thread-2) [custom_components.monitor_docker.sensor] urbackup: Received callback for: Status
2020-07-13 08:43:48 DEBUG (Thread-2) [custom_components.monitor_docker.sensor] urbackup: Received callback for: Memory
ualex73 commented 4 years ago

Yes, it at least shows where the problem is not. It isn't in the "switch" code.

Can you make some manual changes to the code, and see if the problem goes away?

Change in the file const.py from:

CONF_SWITCH = "switch"

to:

CONF_SWITCHX = "switchx"

Change in the init.py from:

_CONF_SWITCH,
vol.Optional(CONF_SWITCH, default=True): cv.boolean,

to:

CONF_SWITCHX,
vol.Optional(CONF_SWITCHX, default=True): cv.boolean,

Change in the switch.py from:

CONF_SWITCH,
if not config[CONF_SWITCH]:

to:

CONF_SWITCHX,
if not config[CONF_SWITCHX]:
malinduta commented 4 years ago

Replaced. No errors. Working fine. "_CONF_SWITCH," was a typo on post above.

ualex73 commented 4 years ago

Yes, sorry "_CONF_SWITCH" was a typo, the underscore should not be there.

Ok, the "switch: True" option in the configuration seems to give an issue, I will rename this one to "switchenable" or something nice. Thanks for testing!

ualex73 commented 4 years ago

The fix is committed and should be able in HACS in a few hours.

ualex73 commented 4 years ago

Can you confirm the error is gone with version 1.2 or 1.3?

malinduta commented 4 years ago

Manually regrabbed the latest files. No errors. Working fine. I confirm.

ualex73 commented 4 years ago

Thanks for the confirmation!