Plugins not becoming active in a Docker container

Python and python framework

Moderator: leecollings

Post Reply
DomoJacko
Posts: 4
Joined: Sunday 13 October 2019 13:40
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Plugins not becoming active in a Docker container

Post by DomoJacko »

Hi,

I have recently switched from an older Domoticz version (3.5849) that was made available via App central of my NAS manufacturer (Asustor), to a version (4.1137) of Domoticz running a Docker container (with Portainer as UI).
The main reason is that I want to control the control heating pump based boiler activety and boiler temperature. This all works when I test with a light on a Philips Hue.

What I don't get to work is the connection to a switch (smart plug).
I could either do this indirectly by making a connection with my Homewizard, or directly via a Dlink DSP-W215 Home Smart Plug.
Both should be possible with plugins.

The latter (Dlink DSP-W215) is available in the example folder of plugins. So, seems easy.
However, whatever I try, I don't get Domoticz to show the Dlink device in the Hardware overview.

I have put the plugin in the Plugins folder and in its own folder. Given the plugin read/write/execute rights ('chmon 77'7). Copied it to a standard name 'plugin.py'. 'Stopped' and 'started' the container of course. But also restarted the NAS.
I also tried another example (DenonMarantz).
But no new hardware is appearing.

What I am doing wrong or what am I missing?

[Edit:]
Maybe I am on to something.
Plugins require Python 3.4 or higher.
When I start Domoticz, I see this line in the log file:
Status: PluginSystem: Started, Python version '3.7.3'.
So, I assumed that that was the Python version running and that all was OK
However, when I type “python” in the command prompt (via the Console function of Portainer), I get:
Python 2.7.16 (default, May 6 2019, 19:28:45) [GCC 8.3.0] on linux2
So, I could very well be that Python is too old.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugins not becoming active in a Docker container

Post by Dnpwwo »

@DomoJacko,

The Python version should be fine. Try typing 'python3 --version' at the command line at it should confirm Python 3.7.3.

You need to post the startup log if you need more help.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
DomoJacko
Posts: 4
Joined: Sunday 13 October 2019 13:40
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Plugins not becoming active in a Docker container

Post by DomoJacko »

HI,
You're right. With 'python' it shows '2.7.16', but with 'python3' is shows 3.7.3, which is the same as what Domoticz is reporting in the log (see below).
To me it seems that the whole plugin system is up and running.

2019-10-14 10:32:29.945 Status: Domoticz V4.11337 (c)2012-2019 GizMoCuz
2019-10-14 10:32:29.945 Status: Build Hash: c3a517bff, Date: 2019-09-23 15:39:16
2019-10-14 10:32:29.957 Status: Startup Path: /var/lib/domoticz/
2019-10-14 10:32:30.134 Sunrise: 08:01:00 SunSet: 18:45:00
2019-10-14 10:32:30.135 Day length: 10:44:00 Sun at south: 13:23:00
2019-10-14 10:32:30.135 Civil twilight start: 07:26:00 Civil twilight end: 19:20:00
2019-10-14 10:32:30.135 Nautical twilight start: 06:46:00 Nautical twilight end: 19:60:00
2019-10-14 10:32:30.135 Astronomical twilight start: 06:06:00 Astronomical twilight end: 20:40:00
2019-10-14 10:32:30.282 Active notification Subsystems: (0/13)
2019-10-14 10:32:30.346 Starting shared server on: 0.0.0.0:6144
--->2019-10-14 10:32:30.277 Status: PluginSystem: Started, Python version '3.7.3'.<---
2019-10-14 10:32:30.278 Status: Philips Hue: Using poll interval of 5 secs.
2019-10-14 10:32:30.319 Status: WebServer(HTTP) started on address: 0.0.0.0 with port 8080
2019-10-14 10:32:30.343 Status: WebServer(SSL) started on address: 0.0.0.0 with port 1443
2019-10-14 10:32:30.347 Status: TCPServer: shared server started...
2019-10-14 10:32:30.347 Status: RxQueue: queue worker started...
2019-10-14 10:32:32.348 Status: Philips Hue: Worker started...
2019-10-14 10:32:32.353 Status: EventSystem: reset all events...
2019-10-14 10:32:32.353 Status: EventSystem: reset all device statuses...
2019-10-14 10:32:32.384 Status: OTGW: connected to: 192.168.178.12:6637
2019-10-14 10:32:32.508 Status: Python EventSystem: Initalizing event module.
2019-10-14 10:32:32.508 Status: EventSystem: Started
2019-10-14 10:32:32.508 Status: EventSystem: Queue thread started...
--->2019-10-14 10:32:32.640 Status: PluginSystem: Entering work loop.<---
DomoJacko
Posts: 4
Joined: Sunday 13 October 2019 13:40
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Plugins not becoming active in a Docker container

Post by DomoJacko »

In all honestly, I knew my way around with MSDOS back in the day, but I am inexperienced (so struggling...) with Linux. And running Domoticz a container on the NAS doesn't seem to make things easier (preferably I don't add more devices to my home like a Rashberry Pi).

After a lot of findling around, I seem to have sorted it out.

The trick seems to be (I have tried many things):
- Start the console of the Domoticz container
- Make a directory "plugins/'Dlink DSP-W215'" in the "/config" directory of the container,
- Copy the 'Dlink DSP-W215.py' file from the /var/lib/domoticz/plugins/examples to that folder
- Rename it to 'plugin.py'
- Make it executable with 'chmod +x plugin.py'

Now that I see the device, I only need to get it work...
DomoJacko
Posts: 4
Joined: Sunday 13 October 2019 13:40
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Plugins not becoming active in a Docker container

Post by DomoJacko »

I had the Dlink smart plug working soon afterwards.
And 10 minutes later I also had the Homewizard connected. That does not work flawlessly, but for now good enough.

The log file shows that the smart plug is regularly disconnected (sometimes every minute, sometimes it a few hours OK)
2019-10-16 00:21:51.664 (Pomp vloerverwarming) Device has disconnected
2019-10-16 00:21:51.915 (Pomp vloerverwarming) Smart plug authentication successful.

Apparently, this happens more often with this device.
A message like this (in red in the log file), looks more serious:
2019-10-15 23:17:38.374 Error: (Pomp vloerverwarming) No transport, write directive to 'DLink' ignored.
Any suggestions what I could do?
PS: There is no interference with other wifi. My laptop does not even see networks of the neighbours.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugins not becoming active in a Docker container

Post by Dnpwwo »

@DomoJacko,

In my experience a number of devices with embedded web servers do not link having long term connections and disconnect periodically.

From memory the DLink is one of those. Nothing you can do because it the device itself dropoping the connection.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest