Page 31 of 48

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Wednesday 28 August 2019 12:43
by moroen
olleman wrote: Wednesday 28 August 2019 10:31
moroen wrote: Saturday 20 October 2018 18:23
Mambobuzzz wrote: Saturday 20 October 2018 18:11 Hi there,

is it worth installing on Windnows Domoticz? Is it stable?
I haven't used Windows for years, so I really don't know. I would guess it should work, at least if you create a docker image with the adapter.

Regards,
M
Somebody tried with windows? I've had my Domoticz installation on windows for years and it would be a major hassle to move to an RPi3 now...
I've managed to get the "new/aiocoap" version of the adapter running in a container on Windows, take a look at https://github.com/moroen/ikea-tradfri for instructions. I've never bothered with trying to get domoticz running on windows, but as long as you have a working version with support for python plugins, installing the plugin into plugins\IKEA-Tradfri should work, there is no need to run setup.py for the plugin as long as you have a functioning image of the adapter...

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Wednesday 28 August 2019 14:15
by olleman

I've managed to get the "new/aiocoap" version of the adapter running in a container on Windows, take a look at https://github.com/moroen/ikea-tradfri for instructions. I've never bothered with trying to get domoticz running on windows, but as long as you have a working version with support for python plugins, installing the plugin into plugins\IKEA-Tradfri should work, there is no need to run setup.py for the plugin as long as you have a functioning image of the adapter...

Regards,
M
Ok, sounds doable then. Thanks a lot!

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Sunday 15 September 2019 20:00
by prijt
After weeks and weeks trying to figure out why the IKEA lights stopped working from Domoticz earlier in the year, I finally figured it out...

My install was one from the beginning and I never needed to move to the plugin solution. In the days past, I tried and tried, even installed the docker solution, but never succeeded. When earlier this evening the tradfri.tac file was nowhere to be found, I gave up. I decided to investigate my original installation by making a CLI call like: "tradfri <ID> COMMAND"

Then lightning struck: the API had changed to: "tradfri COMMAND <ID>"

Bingo! With that knowledge I adjusted my Domoticz script and all was well again. Perhaps I missed this change in this lengthy list of responses. But perhaps this info helps someone... (https://github.com/moroen/ikea-tradfri) a changed API...

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Tuesday 17 September 2019 12:43
by moroen
prijt wrote: Sunday 15 September 2019 20:00 After weeks and weeks trying to figure out why the IKEA lights stopped working from Domoticz earlier in the year, I finally figured it out...

My install was one from the beginning and I never needed to move to the plugin solution. In the days past, I tried and tried, even installed the docker solution, but never succeeded. When earlier this evening the tradfri.tac file was nowhere to be found, I gave up. I decided to investigate my original installation by making a CLI call like: "tradfri <ID> COMMAND"

Then lightning struck: the API had changed to: "tradfri COMMAND <ID>"

Bingo! With that knowledge I adjusted my Domoticz script and all was well again. Perhaps I missed this change in this lengthy list of responses. But perhaps this info helps someone... (https://github.com/moroen/ikea-tradfri) a changed API...
Sorry about that, I didn't realise that someone used the tradfri python script directly from domoticz, in hindsight I should have thought about it, but glad it worked out. The primary function of the tradfri script is to act as the COAP adapter for the plugin, the CLI is primarily for testing the various functions in my ikea-tradfri library and ggrevlingen's pytradfri. I do plan to continue developing it as a standalone tool as well, I don't think the API will change again, but if it does, I'll make sure to post info about it here...

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Tuesday 17 September 2019 13:18
by prijt
No problem, and after all the long hours you have put in from your free time, I can only thank you for your efforts! Yes, I struggled, but then finding the solution is very rewarding :)
Btw, I think that the basic install/setup of Tradfri has gotten too complex for the average Joe. Especially the python upgrade when u r not on the latest ux release. And with my large and complex setup, upgrading is always a nightmare... I'd like to set&forget ;)

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Tuesday 17 September 2019 13:38
by moroen
prijt wrote: Tuesday 17 September 2019 13:18 No problem, and after all the long hours you have put in from your free time, I can only thank you for your efforts! Yes, I struggled, but then finding the solution is very rewarding :)
Btw, I think that the basic install/setup of Tradfri has gotten too complex for the average Joe. Especially the python upgrade when u r not on the latest ux release. And with my large and complex setup, upgrading is always a nightmare... I'd like to set&forget ;)
The plugin/command line tool combination works on python 3.5.x onwards, so there should be any need to upgrade the distro version of python. The latest update to the plugin tries to handle all the dependencies using the setup.py file, unless on 3.5.x, where pip using the requirements.txt file is needed. It might be a way to make this easier, but I really have no idea at the moment how to make it easier, any suggestions is more than welcome! ;)

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Wednesday 18 September 2019 22:45
by free_nsc
Can I just check if you're planning to add port config instead of hard coding it to 1234? I am using port elsewhere so I tried changing it in the two files but somehow it was still looking to run the server on 1234.

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 19 September 2019 7:21
by redfirebrooks
Hello

I tried to update the plugin and now i have this error in domoticz

Code: Select all

2019-09-19 07:19:41.186 (IKEA TRADFRI) Failed to connect to IKEA tradfri COAP-adapter! Status: 111 Description: Connection refused
2019-09-19 07:19:41.186 (IKEA TRADFRI) Device has disconnected
What I did for the update is...

Code: Select all

pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo pip3 install --upgrade pytradfri
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pytradfri
  Downloading https://www.piwheels.org/simple/pytradfri/pytradfri-6.3.0-py3-none-any.whl
Installing collected packages: pytradfri
  Found existing installation: pytradfri 6.0.1
    Uninstalling pytradfri-6.0.1:
      Successfully uninstalled pytradfri-6.0.1
Successfully installed pytradfri-6.3.0
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ git reset --hard HEAD
HEAD est maintenant à cf4a1db Update Dockerfile
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo git reset --hard HEAD
HEAD est maintenant à cf4a1db Update Dockerfile
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo git pull
Mise à jour cf4a1db..a58c41d
Fast-forward
 .bumpversion.cfg              |   9 ++
 .gitignore                    | 100 ++++++++++++++++++++++
 Dockerfile                    |  34 --------
 DockerfileRPI                 |  36 --------
 GW_config                     |   2 -
 README.md                     | 148 ++++++++++++++++-----------------
 adapter_start.sh              |   6 --
 colors.py                     |  72 ++++++++++++++++
 configure.py                  | 137 ------------------------------
 create.sh                     |  17 ----
 devices.ini                   |  40 ---------
 docker-compose.yml            |   9 --
 ikea-tradfri.service.tpl      |  17 ----
 ikeatradfri/colors.py         |  70 ----------------
 ikeatradfri/device_classes.py | 191 ------------------------------------------
 ikeatradfri/version.py        |   2 -
 install-coap-client.sh        |   7 --
 plugin.py                     | 505 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
 requirements.txt              |  12 +++
 setup.py                      |  16 ++++
 shell.sh                      |  29 -------
 start.sh                      |  25 ------
 tradfri.tac                   | 455 ----------------------------------------------------------------------------------------------------
 23 files changed, 648 insertions(+), 1291 deletions(-)
 create mode 100644 .bumpversion.cfg
 delete mode 100644 Dockerfile
 delete mode 100644 DockerfileRPI
 delete mode 100644 GW_config
 delete mode 100755 adapter_start.sh
 create mode 100644 colors.py
 delete mode 100755 configure.py
 delete mode 100755 create.sh
 delete mode 100644 devices.ini
 delete mode 100644 docker-compose.yml
 delete mode 100644 ikea-tradfri.service.tpl
 delete mode 100644 ikeatradfri/colors.py
 delete mode 100644 ikeatradfri/device_classes.py
 delete mode 100644 ikeatradfri/version.py
 delete mode 100755 install-coap-client.sh
 create mode 100644 requirements.txt
 create mode 100644 setup.py
 delete mode 100755 shell.sh
 delete mode 100755 start.sh
 delete mode 100755 tradfri.tac
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo systemctl start ikea-tradfri.service
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo systemctl status ikea-tradfri.service
● 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 Thu 2019-09-19 07:17:12 CEST; 1s ago
  Process: 5560 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-T
 Main PID: 5560 (code=exited, status=1/FAILURE)

sept. 19 07:17:12 domoticz systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
sept. 19 07:17:12 domoticz systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
sept. 19 07:17:12 domoticz systemd[1]: Stopped IKEA Tradfri COAP-adapter.
sept. 19 07:17:12 domoticz systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
sept. 19 07:17:12 domoticz systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
sept. 19 07:17:12 domoticz systemd[1]: ikea-tradfri.service: Unit entered failed state.
sept. 19 07:17:12 domoticz systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
I can manually start the service but it stops after few seconds

Code: Select all

pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo systemctl start ikea-tradfri.service
pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo systemctl status ikea-tradfri.service
● ikea-tradfri.service - IKEA Tradfri COAP-adapter
   Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-09-19 07:44:22 CEST; 65ms ago
 Main PID: 11547 (twistd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/ikea-tradfri.service
           └─11547 /usr/bin/python3 /usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plug

sept. 19 07:44:22 domoticz systemd[1]: Started IKEA Tradfri COAP-adapter.

pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ sudo systemctl status ikea-tradfri.service
● 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 Thu 2019-09-19 07:44:26 CEST; 2s ago
  Process: 11562 ExecStart=/usr/local/bin/twistd --nodaemon --rundir=/home/pi/domoticz/plugins/IKEA-Tradfri --pidfile=/home/pi/domoticz/plugins/IKEA-
 Main PID: 11562 (code=exited, status=1/FAILURE)

sept. 19 07:44:26 domoticz systemd[1]: ikea-tradfri.service: Failed with result 'exit-code'.
sept. 19 07:44:26 domoticz systemd[1]: ikea-tradfri.service: Service hold-off time over, scheduling restart.
sept. 19 07:44:26 domoticz systemd[1]: Stopped IKEA Tradfri COAP-adapter.
sept. 19 07:44:26 domoticz systemd[1]: ikea-tradfri.service: Start request repeated too quickly.
sept. 19 07:44:26 domoticz systemd[1]: Failed to start IKEA Tradfri COAP-adapter.
sept. 19 07:44:26 domoticz systemd[1]: ikea-tradfri.service: Unit entered failed state.
So I restarted form scratch following the readme.md. Everything looks fine, service is started and "tradfri list" gives me all my devices.
I have deleted the previous IKEA device from Domcoticz and recreated a new one...
But I have still the ikea-tradfri.service: Failed with result 'exit-code'

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 19 September 2019 13:11
by moroen
free_nsc wrote: Wednesday 18 September 2019 22:45 Can I just check if you're planning to add port config instead of hard coding it to 1234? I am using port elsewhere so I tried changing it in the two files but somehow it was still looking to run the server on 1234.
Yes, setting another port for the TCP server is already implemented on the "ikea-tradfri" side, but due to limitations in the python framework on the Domoticz side, I'm running out of configuration "slots" on the hardware page for the plugin. I see two rather obvious solutions, either put "behind-the-scenes"-config options in a json file in the plugin-directory, or changing the format of the "Adaptor IP Address" field on the hardware-page to IP:PORT, which do you prefer? I tend to prefer the latter for solving the need to set an optional port, but introducing the config.json file, gives me much more flexibility for implementing other settings as well...

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 19 September 2019 13:14
by moroen
redfirebrooks wrote: Thursday 19 September 2019 7:21 So I restarted form scratch following the readme.md. Everything looks fine, service is started and "tradfri list" gives me all my devices.
I have deleted the previous IKEA device from Domcoticz and recreated a new one...
But I have still the ikea-tradfri.service: Failed with result 'exit-code'
Have you tried stopping the service, and then run tradfri from the command line? If you use the -vv flag, you'll get a lot more information. Feel free to post the output here, and I'll take a look!

Code: Select all

$ tradfri -vv server
Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 19 September 2019 13:37
by moroen
As as side note... I'm constantly trying to improve the plugin, and am considering a few alternative solutions.

The best would be to implement suppport for COAPS as a protocol in the framework, but I'm not a C++ developer, and I don't have the C++ chops to implement such a solution.

I do have a sceleton solution that works within the current framework. This solution removes the need for running a separate process as a service all togheter. The downside is that it introduces a small amount of latency to domoticz, in such a way that the plugin framework (and as far as I can tell, domoticz itself) freezes for the duration it takes to send a request to the Ikea gateway and get a response.

I've noticed that there are other python plugins that implement similar, blocking sync calls, so it might not be such a big hassle as I imagine... On my own network, this latency is barely noticable at all, but if the connection to the gateway lags or fails, it will introduce a latency that will be noticable. Another downside is that this solutions completely removes any hope of getting proper observation of state changes (using a remote, the IKEA app etc), but stable observation has eluded me in the current solution as well, so polling seems to be the way to go anyway...

I don't want to spend too much time on this alternative, if the current, latency free solution is prefered, so what do you all think?

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 19 September 2019 20:02
by redfirebrooks
moroen wrote: Thursday 19 September 2019 13:14
redfirebrooks wrote: Thursday 19 September 2019 7:21 So I restarted form scratch following the readme.md. Everything looks fine, service is started and "tradfri list" gives me all my devices.
I have deleted the previous IKEA device from Domcoticz and recreated a new one...
But I have still the ikea-tradfri.service: Failed with result 'exit-code'
Have you tried stopping the service, and then run tradfri from the command line? If you use the -vv flag, you'll get a lot more information. Feel free to post the output here, and I'll take a look!

Code: Select all

$ tradfri -vv server
Regards,
M
Thanks a lot for your support.
This is what I got.

Code: Select all

pi@domoticz:~ $  tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
INFO:Starting IKEA-Tradfri TCP server 0.2.0 on 127.0.0.1:1234
Then I thought it could come from a bad configuration... indeed... the IP in domoticz was not set to localhost.
My mistake.

UPDATE

It looks that I still have a problem. After few minutes the plugin seems to loose the connection to the gateway. I can't control anymore my bulb through the domoticz devices. I have to stop/start the service or enable/disable the debug option in the plugin settings.

For example the debug when I try to turn on a group called Salon

Code: Select all

2019-09-24 07:14:19.005 Status: User: Admin initiated a switch command (1686/Salon IKEA/On)
2019-09-24 07:14:21.446 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:21.476 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:21.477 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:21.477 (PLUGIN MANAGER) Pushing 'WriteDirective' on to queue
2019-09-24 07:14:21.477 (PLUGIN MANAGER) Processing 'WriteDirective' message
2019-09-24 07:14:21.477 (PLUGIN MANAGER) Sending 69 bytes of data
2019-09-24 07:14:21.477 (PLUGIN MANAGER) 7b 22 67 72 6f 75 70 73 22 3a 20 22 54 72 75 65 22 2c 20 22 {"groups":."True",."
2019-09-24 07:14:21.477 (PLUGIN MANAGER) 62 61 74 74 65 72 79 5f 6c 65 76 65 6c 73 22 3a 20 22 54 72 battery_levels":."Tr
2019-09-24 07:14:21.477 (PLUGIN MANAGER) 75 65 22 2c 20 22 61 63 74 69 6f 6e 22 3a 20 22 67 65 74 43 ue",."action":."getC
2019-09-24 07:14:21.477 (PLUGIN MANAGER) 68 61 6e 67 65 73 22 7d 0a .. .. .. .. .. .. .. .. .. .. .. hanges"}.
2019-09-24 07:14:23.446 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:23.481 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:23.481 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:24.038 (RFLINK) Temp + Humidity (Sonde 433)
2019-09-24 07:14:25.447 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:25.487 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:25.487 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:27.447 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:27.491 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:27.491 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:29.448 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:29.494 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:29.494 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:31.448 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:31.498 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:31.498 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:33.448 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:14:33.454 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:14:33.454 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:14:35.449 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
and when it works

Code: Select all

2019-09-24 07:17:23.208 (PLUGIN MANAGER) 35 22 7d 0a .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 5"}.
2019-09-24 07:17:23.164 Status: User: master initiated a switch command (1686/Salon IKEA/Set Level)
2019-09-24 07:17:24.676 (PLUGIN MANAGER) Pushing 'ReadEvent' on to queue
2019-09-24 07:17:24.711 (PLUGIN MANAGER) Processing 'ReadEvent' message
2019-09-24 07:17:24.711 (PLUGIN MANAGER) Received 195 bytes of data
2019-09-24 07:17:24.711 (PLUGIN MANAGER) 7b 22 73 74 61 74 75 73 22 3a 20 22 4f 6b 22 2c 20 22 61 63 {"status":."Ok",."ac
2019-09-24 07:17:24.711 (PLUGIN MANAGER) 74 69 6f 6e 22 3a 20 22 73 65 74 4c 65 76 65 6c 22 2c 20 22 tion":."setLevel",."
2019-09-24 07:17:24.711 (PLUGIN MANAGER) 72 65 73 75 6c 74 22 3a 20 5b 7b 22 44 65 76 69 63 65 49 44 result":.[{"DeviceID
2019-09-24 07:17:24.711 (PLUGIN MANAGER) 22 3a 20 31 33 31 30 37 35 2c 20 22 43 6f 6c 6f 72 73 70 61 ":.131075,."Colorspa
2019-09-24 07:17:24.712 (PLUGIN MANAGER) 63 65 22 3a 20 22 57 53 22 2c 20 22 44 69 6d 6d 61 62 6c 65 ce":."WS",."Dimmable
2019-09-24 07:17:24.712 (PLUGIN MANAGER) 22 3a 20 74 72 75 65 2c 20 22 4c 65 76 65 6c 22 3a 20 31 32 ":.true,."Level":.12
2019-09-24 07:17:24.712 (PLUGIN MANAGER) 37 2c 20 22 54 79 70 65 22 3a 20 22 47 72 6f 75 70 22 2c 20 7,."Type":."Group",.
2019-09-24 07:17:24.712 (PLUGIN MANAGER) 22 48 65 78 22 3a 20 22 66 31 65 30 62 35 22 2c 20 22 53 74 "Hex":."f1e0b5",."St
2019-09-24 07:17:24.712 (PLUGIN MANAGER) 61 74 65 22 3a 20 74 72 75 65 2c 20 22 4e 61 6d 65 22 3a 20 ate":.true,."Name":.
2019-09-24 07:17:24.712 (PLUGIN MANAGER) 22 53 61 6c 6f 6e 20 49 4b 45 41 22 7d 5d 7d .. .. .. .. .. "Salon.IKEA"}]}
2019-09-24 07:17:24.712 (PLUGIN MANAGER) Pushing 'onMessageCallback' on to queue
2019-09-24 07:17:24.712 (PLUGIN MANAGER) Processing 'onMessageCallback' message
2019-09-24 07:17:24.712 (PLUGIN MANAGER) Calling message handler 'onMessage'.
2019-09-24 07:17:24.712 (PLUGIN MANAGER) updateDeviceState [{'Hex': 'f1e0b5', 'DeviceID': 131075, 'State': 'true', 'Level': 127, 'Name': 'Salon IKEA', 'Colorspace': 'WS', 'Dimmable': 'true', 'Type': 'Group'}]
2019-09-24 07:17:24.712 (PLUGIN MANAGER) Level: 127
2019-09-24 07:17:24.712 (Salon IKEA) Updating device from 0:'50' to have values 1:'50'.
2019-09-24 07:17:24.719 (PLUGIN MANAGER - Salon IKEA - Color) Updating device from 0:'20' to have values 1:'20'.
2019-09-24 07:17:24.773 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:17:24.779 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
2019-09-24 07:17:24.779 (PLUGIN MANAGER) Calling message handler 'onHeartbeat'.
2019-09-24 07:17:26.774 (PLUGIN MANAGER) Pushing 'onHeartbeatCallback' on to queue
2019-09-24 07:17:26.785 (PLUGIN MANAGER) Processing 'onHeartbeatCallback' message
My settings are (I am using Python Plugin Manager):

Nom: IKEA TRADFRI
Type: IKEA Tradri
Délai d'inactivité: Désactivé
Adaptor IP Address: 127.0.0.1
Observe changes: yes
Polling interval (seconds): 300
Transition time (tenth of a second):
Add groups as devices: yes
Monitor battry levels: no
Debug: no

I can control my bulbs through the Ikea Home Smart app or Apple Home.

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Wednesday 02 October 2019 21:33
by plukie
Hey folks, sorry for jumping in with the out of the blue question but couldn't find it being addressed on this long thread here:

is there any way to detect when Tradfri lights are physically (wall switch) powered on and off?

Old habits die hard and me and my family like to keep using the wall switch to control the lights. The bridge is always plugged in. With Domoticz and this plugin I'd like to put the lights colour temperature on a schedule though. Cold in the mornings, warmer in the evenings, etc.

The simplest solution is to ping the bridge every minute or so with the right command. If the lights happen to be powered on, it all goes through. If they are _just_ powered on, the worst we'll wait a minute or so until the right colours kick in. If they are off... well, it goes nowhere then.

I'd like it to be smarter though and kick off the script on the event when the lights are powered on and kill it when they are powered off.

Observing changes and polling intervals in the Hardware setup are only (somewhat) good for getting the on/off states when the lights are controlled remotely while still are physically powered on. When they are physically powered off (go "offline"), the bridge doesn't seem to relay that information to the script, does it?

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 03 October 2019 22:16
by moroen
redfirebrooks wrote: Thursday 19 September 2019 20:02
moroen wrote: Thursday 19 September 2019 13:14
redfirebrooks wrote: Thursday 19 September 2019 7:21 So I restarted form scratch following the readme.md. Everything looks fine, service is started and "tradfri list" gives me all my devices.
I have deleted the previous IKEA device from Domcoticz and recreated a new one...
But I have still the ikea-tradfri.service: Failed with result 'exit-code'
Have you tried stopping the service, and then run tradfri from the command line? If you use the -vv flag, you'll get a lot more information. Feel free to post the output here, and I'll take a look!

Code: Select all

$ tradfri -vv server
Regards,
M
Thanks a lot for your support.
This is what I got.

Code: Select all

pi@domoticz:~ $  tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
INFO:Starting IKEA-Tradfri TCP server 0.2.0 on 127.0.0.1:1234
Then I thought it could come from a bad configuration... indeed... the IP in domoticz was not set to localhost.
My mistake.

UPDATE

It looks that I still have a problem. After few minutes the plugin seems to loose the connection to the gateway. I can't control anymore my bulb through the domoticz devices. I have to stop/start the service or enable/disable the debug option in the plugin settings.
As usual, the most valuable log is from the adapter, when run from the command line. Use -vv and see what happens on the adapter side when the plugin fails! :)

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 03 October 2019 22:29
by moroen
plukie wrote: Wednesday 02 October 2019 21:33 Hey folks, sorry for jumping in with the out of the blue question but couldn't find it being addressed on this long thread here:

is there any way to detect when Tradfri lights are physically (wall switch) powered on and off?

Old habits die hard and me and my family like to keep using the wall switch to control the lights. The bridge is always plugged in. With Domoticz and this plugin I'd like to put the lights colour temperature on a schedule though. Cold in the mornings, warmer in the evenings, etc.

The simplest solution is to ping the bridge every minute or so with the right command. If the lights happen to be powered on, it all goes through. If they are _just_ powered on, the worst we'll wait a minute or so until the right colours kick in. If they are off... well, it goes nowhere then.

I'd like it to be smarter though and kick off the script on the event when the lights are powered on and kill it when they are powered off.

Observing changes and polling intervals in the Hardware setup are only (somewhat) good for getting the on/off states when the lights are controlled remotely while still are physically powered on. When they are physically powered off (go "offline"), the bridge doesn't seem to relay that information to the script, does it?
As far as I know, there is no way to determine if a bulb is connected to power or not using COAP-requests to the gateway. There is a "last seen" available in the IKEA app, I've not been able to find the corresponding entry in the available data from the gateway, and I really don't know if this field is updated frequently enough to be of any help anyway... As a matter of fact, if a command to switch on/off a physically powered off device is sent to the gateway, the gateway duly reports the new state regardless of whether the bulb is available or not, so I can't see how to implement some kind of "send command, check if state is as requested, if not wait and send the command again until the state is as desired"-function...

So I guess the solution is to relearn old habits (or physically disable the wall switch... 8-) )

Regards,
M

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Friday 04 October 2019 10:32
by plukie
moroen wrote: Thursday 03 October 2019 22:29
As far as I know, there is no way to determine if a bulb is connected to power or not using COAP-requests to the gateway. There is a "last seen" available in the IKEA app, I've not been able to find the corresponding entry in the available data from the gateway, and I really don't know if this field is updated frequently enough to be of any help anyway... As a matter of fact, if a command to switch on/off a physically powered off device is sent to the gateway, the gateway duly reports the new state regardless of whether the bulb is available or not, so I can't see how to implement some kind of "send command, check if state is as requested, if not wait and send the command again until the state is as desired"-function...

So I guess the solution is to relearn old habits (or physically disable the wall switch... 8-) )

Regards,
M
Thank you M for confirming my suspicions and saving time in digging through this!

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Monday 07 October 2019 12:00
by JimmyH1969
Just a quick question, not sure if it's asked before, but will this plugin work in the Windows version of Domoticz with the correct Python installed?

edit: Already found it... it was on top of this page :D

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Thursday 10 October 2019 20:19
by JimmyH1969
Using Python on Windows... i have no idea how get this part done:

4. Install tradfri command line tool and required python packages... any tips?

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Friday 11 October 2019 18:52
by moroen
JimmyH1969 wrote: Thursday 10 October 2019 20:19 Using Python on Windows... i have no idea how get this part done:

4. Install tradfri command line tool and required python packages... any tips?
That's the part that makes using the plugin on windows such a hassle, you can't... At least not easily, as getting DTLSSocket installed on windows is far from trivial. That's why it's recommended to use the tradfri command line tool as a docker image, take a look at the readme for instructions: https://github.com/moroen/ikea-tradfri

I'm working on a different version of the plugin, where there's no need for the adapter at all, and without the need for DTLSSocket. I haven't tried it on Windows, but as far as I can figure, it should work. If you (or someone else) want to give this a try, feel free to send me a PM.

Regards,
M

BTW: You could try to install and run domoticz and the plugin in Windows Subsystem for Linux, I've seen a couple of howtos on how to start a WSL service on WIndows startup!

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Posted: Saturday 12 October 2019 17:35
by jeroenze
Hi! Also from the NL and starting with Domoticz, however with a little bit of Linux knowledge... but your manual is pretty good to follow.

I have installed everything and I also get response from the Tradfri gateway & it displays as a plugin in the Domoticz interface. However it doesn't list any devices.

In the debug via ssh it says the following:

Code: Select all

(myvenv) pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8086
ERROR:Task exception was never retrieved
future: <Task finished coro=<tcp_server.main() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py:244> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 1235): address already in use")>
Traceback (most recent call last):
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py", line 249, in main
    self.handle_echo, hostConfig["Server_ip"], hostConfig["Tcp_port"]
  File "/usr/lib/python3.7/asyncio/streams.py", line 114, in start_server
    return await loop.create_server(factory, host, port, **kwds)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 1235): address already in use
ERROR:Task exception was never retrieved
future: <Task finished coro=<start() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py:18> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 8086): address already in use")>
Traceback (most recent call last):
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py", line 38, in start
    await site.start()
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/aiohttp/web_runner.py", line 102, in start
    reuse_port=self._reuse_port)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 8086): address already in use
As you can see I already tried to change the ports to have it working, but that did not solve the issue.