Python and python framework
Moderator: leecollings
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Monday 01 April 2019 1:35
schulpr wrote: ↑ Sunday 31 March 2019 21:33
Hello M,
Your suggestion brought me a bit further. Next error:
pi@raspberrypi3:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.8.7 started (command line)!
Couldn't listen on any [Errno 98] Address already in use.
Even killed the complete Domoticz directory and started all over.
Kind regards, Rob
The port is already in use, probably already running the adapter, perhaps started as a service? Try:
Code: Select all
$ sudo systemctl stop ikea-tradfri
$ python3 tradfri.tac
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Monday 01 April 2019 6:48
Hi M.,
The same (first) error is back again. I will try a complete clean Stretch installation now.
Thanks for now!
Regards, Rob
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Monday 01 April 2019 12:27
Hi M.,
Fresh install, no errors during setup process. After adding the plugin the error is still the same.
Kind regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Monday 01 April 2019 20:44
schulpr wrote: ↑ Monday 01 April 2019 12:27
Hi M.,
Fresh install, no errors during setup process. After adding the plugin the error is still the same.
Kind regards, Rob
Fails on configure?
Try:
Code: Select all
$ python3 configure.py --debug config IP KEY
and post the result...
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Monday 01 April 2019 20:52
Hi M.,
The result: Config created!
Regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Monday 01 April 2019 22:08
schulpr wrote: ↑ Monday 01 April 2019 20:52
Hi M.,
The result: Config created!
Regards, Rob
And it still doesn't work? What is the error you're seeing?
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Monday 01 April 2019 22:12
When I'm enabling the plugin then this is in the log:
2019-04-01 22:10:13.090 Status: (Tradfri) Started.
2019-04-01 22:10:13.271 Error: (IKEA-Tradfri) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/IKEA-Tradfri/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-04-01 22:10:13.271 Error: (Tradfri) Module Import failed, exception: 'ImportError'
2019-04-01 22:10:13.271 Error: (Tradfri) Module Import failed: ' Name: ikeatradfri'
2019-04-01 22:10:13.271 Error: (Tradfri) Error Line details not available.
Regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 0:32
schulpr wrote: ↑ Monday 01 April 2019 22:12
When I'm enabling the plugin then this is in the log:
2019-04-01 22:10:13.090 Status: (Tradfri) Started.
2019-04-01 22:10:13.271 Error: (IKEA-Tradfri) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/IKEA-Tradfri/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-04-01 22:10:13.271 Error: (Tradfri) Module Import failed, exception: 'ImportError'
2019-04-01 22:10:13.271 Error: (Tradfri) Module Import failed: ' Name: ikeatradfri'
2019-04-01 22:10:13.271 Error: (Tradfri) Error Line details not available.
Regards, Rob
Another silly mistake in my part, I feel some of that git mojo just fading away...
So, if you have any patience left for this, I would humbly ask you to pull the latest master...
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Tuesday 02 April 2019 7:19
Hi M.,
The good news first
, the error is gone. After git pull, and after that, a complete re-installation of the plugin, the connection is (and stays) refused:
2019-04-02 07:15:09.043 (Tradfri) Failed to connect to IKEA tradfri COAP-adapter! Status: 111 Description: Connection refused
2019-04-02 07:15:09.043 (Tradfri) Device has disconnected
Regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 9:22
schulpr wrote: ↑ Tuesday 02 April 2019 7:19
Hi M.,
The good news first
, the error is gone. After git pull, and after that, a complete re-installation of the plugin, the connection is (and stays) refused:
2019-04-02 07:15:09.043 (Tradfri) Failed to connect to IKEA tradfri COAP-adapter! Status: 111 Description: Connection refused
2019-04-02 07:15:09.043 (Tradfri) Device has disconnected
Regards, Rob
What happens when you try running the adapter from the command line?
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Tuesday 02 April 2019 10:46
Then all the lights are added to Domoticz and I can control them. When I close Putty it doesn't work anymore.
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 12:18
schulpr wrote: ↑ Tuesday 02 April 2019 10:46
Then all the lights are added to Domoticz and I can control them. When I close Putty it doesn't work anymore.
Ah, you need to enable the adapter as a service, then it will start automatically on power-on, and persist when closing the ssh-connection.
Please look at the readme (
https://github.com/moroen/IKEA-Tradfri- ... /README.md ) for instructions on configuring and enabling the service.
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Tuesday 02 April 2019 13:57
Hi M.,
I tried that but without success. I keep getting the message 'Failed to connect to IKEA tradfri COAP-adapter! Status: 111 Description: Connection refused'.
I don't know what to do anymore.
Regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 14:26
schulpr wrote: ↑ Tuesday 02 April 2019 13:57
Hi M.,
I tried that but without success. I keep getting the message 'Failed to connect to IKEA tradfri COAP-adapter! Status: 111 Description: Connection refused'.
I don't know what to do anymore.
Regards, Rob
Since you're able to manually start the adapter, and it works until you close the connection, the service isn't running. Could you please provide the output of (run the command while in the IKEA-Tradfri directory):
and then try:
Code: Select all
$ sudo systemctl status ikea-tradfri
$ sudo systemctl stop ikea-tradfri
$ sudo systemctl start ikea-tradfri
$ sudo systemctl status ikea-tradfri
and post the output from each?
It would also be helpfull if you provide the complete path to your domotics/plugin directory...
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Tuesday 02 April 2019 15:08
Hi M.,
Remark for cat ikea-tradfri.service: I also tried user pi.
Result after stop and start makes no difference.
The path to the plugins is default: ~/domoticz/plugins/IKEA-Tradfri
pi@raspberrypi3:~/domoticz/plugins/IKEA-Tradfri $ cat ikea-tradfri.service
[Unit]
Description=IKEA Tradfri COAP-adapter
[Service]
Type=simple
ExecStart=/usr/local/bin/twistd --nodaemon \
--rundir=/home/pi/domoticz/plugins/IKEA-Tradfri \
--pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twistd.pid \
--python=/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri.tac
User=domoticz
Group=domogroup
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl status ikea-tradfri
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-02 14:57:13 CEST; 2min 20s ago
Process: 2432 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twis
Main PID: 2432 (code=exited, status=217/USER)
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
Apr 02 14:57:13 raspberrypi3 systemd[1]: Stopped IKEA Tradfri COAP-adapter.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
Apr 02 14:57:13 raspberrypi3 systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
sudo systemctl status ikea-tradfri
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-02 15:00:39 CEST; 3s ago
Process: 2893 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twis
Main PID: 2893 (code=exited, status=217/USER)
Apr 02 15:00:38 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
Apr 02 15:00:39 raspberrypi3 systemd[1]: Stopped IKEA Tradfri COAP-adapter.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
Apr 02 15:00:39 raspberrypi3 systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Thanks for your patience with me.
Regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 15:20
schulpr wrote: ↑ Tuesday 02 April 2019 15:08
Hi M.,
Remark for cat ikea-tradfri.service: I also tried user pi.
Result after stop and start makes no difference.
The path to the plugins is default: ~/domoticz/plugins/IKEA-Tradfri
pi@raspberrypi3:~/domoticz/plugins/IKEA-Tradfri $ cat ikea-tradfri.service
[Unit]
Description=IKEA Tradfri COAP-adapter
[Service]
Type=simple
ExecStart=/usr/local/bin/twistd --nodaemon \
--rundir=/home/pi/domoticz/plugins/IKEA-Tradfri \
--pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twistd.pid \
--python=/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri.tac
User=domoticz
Group=domogroup
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl status ikea-tradfri
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-02 14:57:13 CEST; 2min 20s ago
Process: 2432 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twis
Main PID: 2432 (code=exited, status=217/USER)
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
Apr 02 14:57:13 raspberrypi3 systemd[1]: Stopped IKEA Tradfri COAP-adapter.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
Apr 02 14:57:13 raspberrypi3 systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 14:57:13 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
sudo systemctl status ikea-tradfri
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-02 15:00:39 CEST; 3s ago
Process: 2893 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twis
Main PID: 2893 (code=exited, status=217/USER)
Apr 02 15:00:38 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
Apr 02 15:00:39 raspberrypi3 systemd[1]: Stopped IKEA Tradfri COAP-adapter.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
Apr 02 15:00:39 raspberrypi3 systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 15:00:39 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Thanks for your patience with me.
Regards, Rob
No problem!
So with both user and group as pi, you still have the same result?
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Tuesday 02 April 2019 15:31
This is the output with user pi:
cat ikea-tradfri.service
[Unit]
Description=IKEA Tradfri COAP-adapter
[Service]
Type=simple
ExecStart=/usr/local/bin/twistd --nodaemon \
--rundir=/home/pi/domoticz/plugins/IKEA-Tradfri \
--pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twistd.pid \
--python=/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri.tac
User=pi
Group=pi
Restart=always
[Install]
WantedBy=multi-user.target
And the status:
sudo systemctl status ikea-tradfri
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-02 15:27:36 CEST; 3min 16s ago
Process: 646 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twist
Main PID: 646 (code=exited, status=1/FAILURE)
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Main process exited, code=exited, status=1/FAILURE
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
Apr 02 15:27:36 raspberrypi3 systemd[1]: Stopped IKEA Tradfri COAP-adapter.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
Apr 02 15:27:36 raspberrypi3 systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 19:46
schulpr wrote: ↑ Tuesday 02 April 2019 15:31
This is the output with user pi:
cat ikea-tradfri.service
[Unit]
Description=IKEA Tradfri COAP-adapter
[Service]
Type=simple
ExecStart=/usr/local/bin/twistd --nodaemon \
--rundir=/home/pi/domoticz/plugins/IKEA-Tradfri \
--pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twistd.pid \
--python=/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri.tac
User=pi
Group=pi
Restart=always
[Install]
WantedBy=multi-user.target
And the status:
sudo systemctl status ikea-tradfri
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-04-02 15:27:36 CEST; 3min 16s ago
Process: 646 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twist
Main PID: 646 (code=exited, status=1/FAILURE)
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Main process exited, code=exited, status=1/FAILURE
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
Apr 02 15:27:36 raspberrypi3 systemd[1]: Stopped IKEA Tradfri COAP-adapter.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
Apr 02 15:27:36 raspberrypi3 systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Unit entered failed state.
Apr 02 15:27:36 raspberrypi3 systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
Ok, as the pi user, try the adapter invocation:
Code: Select all
$ /usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-Tradfri/twistd.pid --python=/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri.tac
and let me know the output..
Regards,
M
schulpr
Posts: 137 Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:
Post
by schulpr » Tuesday 02 April 2019 20:00
Hi M.,
Herewith:
Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/twisted/application/app.py", line 674, in run
runApp(config)
File "/usr/local/lib/python3.5/dist-packages/twisted/scripts/twistd.py", line 25, in runApp
runner.run()
File "/usr/local/lib/python3.5/dist-packages/twisted/application/app.py", line 381, in run
self.application = self.createOrGetApplication()
File "/usr/local/lib/python3.5/dist-packages/twisted/application/app.py", line 453, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- <exception caught here> ---
File "/usr/local/lib/python3.5/dist-packages/twisted/application/app.py", line 464, in getApplication
application = service.loadApplication(filename, style, passphrase)
File "/usr/local/lib/python3.5/dist-packages/twisted/application/service.py", line 416, in loadApplication
application = sob.loadValueFromFile(filename, 'application')
File "/usr/local/lib/python3.5/dist-packages/twisted/persisted/sob.py", line 177, in loadValueFromFile
eval(codeObj, d, d)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri.tac", line 19, in <module>
from ikeatradfri.device_classes import ikeaGroup, ikeaLight, ikeaSocket
builtins.ImportError: No module named 'ikeatradfri'
Failed to load application: No module named 'ikeatradfri'
I did a quick installation of Domoticz and the plugin on a clean micro SD card and got exactly the same error.
Regards, Rob
moroen
Posts: 408 Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:
Post
by moroen » Tuesday 02 April 2019 20:14
@schulpr,
.. or you could pull the latest master, while I go to sit ashamed in the corner...
Regards,
M
Users browsing this forum: Google [Bot] and 1 guest