tjntomas / HADashboard-widgets

Widgets for HADashboard / Appdaemon
MIT License
52 stars 26 forks source link

ERROR: unable to find docker module #12

Closed juan11perez closed 4 years ago

juan11perez commented 4 years ago

good day thank you for sharing the app. I'm getting the following error seems it cant read sensor from ha any guidance is appreciated


2020-02-02 21:00:00.030924 WARNING docker: ------------------------------------------------------------
2020-02-02 21:00:00.031765 WARNING docker: Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/appdaemon/threading.py", line 766, in worker
    funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/conf/apps/dock/dock.py", line 89, in get_containers
    r =ha.set_state(DOMAIN_DOCKER + name, state, args)
NameError: name 'ha' is not defined

2020-02-02 21:00:00.032163 WARNING docker: ------------------------------------------------------------
2020-02-02 21:00:44.945097 WARNING Error: ------------------------------------------------------------
2020-02-02 21:00:44.945220 WARNING Error: Unexpected error loading module: /conf/apps/dock/dock.py:
2020-02-02 21:00:44.945314 WARNING Error: ------------------------------------------------------------
2020-02-02 21:00:44.945609 WARNING Error: Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/appdaemon/app_management.py", line 788, in check_app_updates
    await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
  File "/usr/local/lib/python3.8/site-packages/appdaemon/utils.py", line 276, in run_in_executor
    response = future.result()
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/appdaemon/app_management.py", line 566, in read_app
    importlib.reload(self.modules[module_name])
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 604, in _exec
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/dock/dock.py", line 4, in <module>
    import sensor as ha
ModuleNotFoundError: No module named 'sensor'
tjntomas commented 4 years ago

Sorry about that, I have fixed the missing reference. Please dowload the updated dock.pyfile and it should work.

juan11perez commented 4 years ago

@tjntomas thank you very much for your prompt reply. It works now. I see the sensors in homeassistant; is there a way to create a switch in home assistant itself?

tjntomas commented 4 years ago

I am using custom service calls in Appdaemon and those are not available in Home Assistant. I could have the app listen for a few custom events also, and then you could send these events from a script or an automation in Home Assistant.

juan11perez commented 4 years ago

Thank you. If it's not much hassle it would be great. There's a few custom components out there to pull docker info, but yours has the right amount of data and can be used to pull from any machine. I use unraid and some vms and it works very well. Thank you

tjntomas commented 4 years ago

Done. I have added the ability to start, stop and restart a container through events from Home Assistant. The events are docker_start, docker_stopand docker_restart. The only data needed is the entity_id.

juan11perez commented 4 years ago

uff, thank you very much. already tried it and works great !!!