MQTT plugin for Tellstick ZNet Lite v2?

Moderator: Telldus

Post Reply
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

I just upgraded from Tellstick Net to a ZNet Lite v2

Is there any plugin or LUA, etc script available so that I can have my new Tellstick hardware to publish sensordata via MQTT?

My broker sit on a Raspberry PI on local LAN so I would prefer if the Tellstick made a local "publish" instead of going via some cloud service.

I don't mind programming a bit, e.g having Tellstick LUA to post sensor data to a Raspberry Python script which makes MQTT publish is also a viable solution (but MQTT "publish" from the Tellstick straight to the MQTT broker on my LAN would "rock"!)

Any ideas are welcome!

Cheers!
/f
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

I have come a bit further on the MQTT topic by studying the https://media.readthedocs.org/pdf/tells ... server.pdf.

So I took a Raspberry PI and downloaded the Tellstick Server and Tellstick Server Plugins from GitHub

$ git clone https://github.com/telldus/tellstick-server.git
$ git clone https://github.com/telldus/tellstick-server-plugins.git

The ./tellstick.sh setup threw an error about "npm not found" so I installed it:
$ sudo apt-get install npm

I also installed virtualenv (sudo apt-get install python virtualenv) and re-ran ./tellstick.sh setup but there were still a quite some errors thrown by npm.

npm WARN package.json tellstick-local-access@0.1.0 No description
npm WARN package.json tellstick-local-access@0.1.0 No repository field.
npm WARN package.json tellstick-local-access@0.1.0 No README data
npm WARN package.json tellstick-local-access@0.1.0 No license field.
npm ERR! TypeError: Request path contains unescaped characters
npm ERR! at new ClientRequest (_http_client.js:127:13)
...
...
...



Anyway, I guessed that I could still build the MQTT Client egg locally despite this error, right or wrong?

I then ran gpg and punched in my name /email and updated the mqtt-client/setup.py to have same values.
$ gpg --gen-key

Finally I ran build-plugin
$ ./tellstick.sh build-plugin plugins/mqtt-client

This output a 76 kb large MQTT_Client-1.0.zip which I subsequently attempted to upload to my Tellstick ZNet Lite v2

Unfortunately, there seem to be something wrong with the PGP / publisher info - the "accept unverified" dialog does not output any publisher data and when clicking the Yes button a script error is thrown at row 248 in plugins.js (Unhandled Promise Rejection: ReferenceError: Can't find variable: reject)?

Skärmavbild 2019-01-20 kl. 15.48.10.png
Skärmavbild 2019-01-20 kl. 15.48.10.png (69.79 KiB) Viewed 14869 times

The manifest.yml of the ZIP file contains the author and email I entered into gpg and a key.pub file is there as well.

author: my name
author-email: my email
category: notifications
color: '#660066'
description: Plugin to connect to a MQTT broker
icon: mqtt.png
key: key.pub
name: MQTT Client
package-version: 1
packages:
- paho_mqtt-1.4.0-py2.7.egg
- MQTT_Client-1.0-py2.7.egg
version: '1.0'


Can someone shed some light on my wrong doings please?

Does Telldus provide a pre-compiled version I can use instead of making this home brew?
jeremyc
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by jeremyc »

How did you solve this? I have come as far as you describe in your message and stuck at the same place.

viewtopic.php?f=1&t=14954&sid=6dd5b0724 ... 956#p50199
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

Two years later...
... after having run into some issues with two recently added ZWave-devices which I got back running by removing and adding them to the Tellstick I found that the MQTT topic from the Tellstick had become silent.

The MQTT Client plugin has been running well for over two years... something did not look all right (e.g. I could not get to the setting of the broker IP, username, etc.) so I decided to erase the plugin from the Tellstick and upload it again.

Then I discovered that my PGP key had expired about a month ago. So I set out to renew my PGP key and get Telldus Support to add it which is now done.

However, I can no longer build the MQTT Plugin on my build server (A Raspberry PI still running Debian Stretch). I did start off with an apt-get update + upgrade, maybe my mistake?

Now I get to this error on the old git repo but also a new I have downloaded in parallel (the MQTT plugin is now v1.1 compared to the 2019 version).

Can anyone shed some light on what I should try next?


$ sudo ./tellstick.sh build-plugin plugins/mqtt-client
Building plugin /home/pi/tellstick/tellstick-server.old/plugins/mqtt-client

Traceback (most recent call last):
File "setup.py", line 22, in <module>
extras_require=dict(cREQ='Base>=0.1\nTelldus>=0.1'),
File "/home/pi/tellstick/tellstick-server/build/env/local/lib/python2.7/site-packages/setuptools/__init__.py", line 162, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/pi/tellstick/tellstick-server/sdk/sdk/plugin.py", line 95, in run
requirements = self.__downloadRequirements(prebuiltPackages)
File "/home/pi/tellstick/tellstick-server/sdk/sdk/plugin.py", line 171, in __downloadRequirements
cmd = DownloadCommand()
File "/home/pi/tellstick/tellstick-server/build/env/local/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 195, in __init__
super(RequirementCommand, self).__init__(*args, **kw)
TypeError: __init__() takes at least 3 arguments (1 given)
running telldus_plugin
Could not build plugin
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

jeremyc wrote: Thu May 09, 2019 10:57 am How did you solve this? I have come as far as you describe in your message and stuck at the same place.

viewtopic.php?f=1&t=14954&sid=6dd5b0724 ... 956#p50199
Sorry for not detecting this question until now. The answer is: I never found out. I could press "Yes" and the plugin was installed.
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

Har nu provat med en helt omladdad Raspberry med aktuell version av Debian Buster och nyhämtade project från GitHub.

# uname -a
Linux rpi6 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l GNU/Linux

# lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster


Tyvärr återstår problemet...

root@rpi6:/home/pi/src/tellstick-server# ./tellstick.sh build-plugin /home/pi/src/tellstick-server-plugins/mqtt-client
Building plugin /home/pi/src/tellstick-server-plugins/mqtt-client
Traceback (most recent call last):
File "setup.py", line 22, in <module>
extras_require=dict(cREQ='Base>=0.1\nTelldus>=0.1'),
File "/home/pi/src/tellstick-server/build/env/local/lib/python2.7/site-packages/setuptools/__init__.py", line 163, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/pi/src/tellstick-server/sdk/sdk/plugin.py", line 97, in run
requirements = self.__downloadRequirements(prebuiltPackages)
File "/home/pi/src/tellstick-server/sdk/sdk/plugin.py", line 173, in __downloadRequirements
cmd = DownloadCommand()
File "/home/pi/src/tellstick-server/build/env/local/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 195, in __init__
super(RequirementCommand, self).__init__(*args, **kw)
TypeError: __init__() takes at least 3 arguments (1 given)
running telldus_plugin
Could not build plugin


Något med den egna PIP versionen strular när den skall ladda ned/hem det som krävs för att bygga ägget. :banghead:
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

One more failed attempt... dang :banghead: :banghead: :banghead:

S O S...

I downloaded an older Debian Stretch from https://downloads.raspberrypi.org/raspbian/images
Since I was able to build the MQTT Plugin roughly two years ago I decided to load the 2018-NOV-15 release some months ahead of that time and install it on a fresh SD card in the same Raspberry where I succeeded two years ago.

https://downloads.raspberrypi.org/raspbian/images/

Which resulted in this + a slightly older Python version compared to what Debian Buster comes with from scratch, 2.7.13

uname -a
Linux raspberrypi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

root@raspberrypi:/home/pi/src/tellstick-server# lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch

root@raspberrypi:/home/pi/src/tellstick-server# python -V
Python 2.7.13


Without updating anything (except for running an apt-get update to be able to download the prerequisites) I just pulled down the prerequisites and the two Telldus projects from GitHub and let go.

The RSA error was there yesterday as well. Can't tell if that is what is bugging my? I don't think so.

sudo -i
apt-get update
apt-get install npm python-dev libffi-dev virtualenv
mkdir /home/pi/src
cd /home/pi/src
git clone https://github.com/telldus/tellstick-server
git clone https://github.com/telldus/tellstick-server-plugins
cd tellstick-server
./tellstick.sh setup
Collecting rsa
Downloading rsa-4.7.1.tar.gz (38 kB)
ERROR: Package 'rsa' requires a different Python: 2.7.13 not in '>=3.5, <4'

./tellstick.sh build-plugin /home/pi/src/tellstick-server-plugins/mqtt-client
Building plugin /home/pi/src/tellstick-server-plugins/mqtt-client
Traceback (most recent call last):
File "setup.py", line 22, in <module>
extras_require=dict(cREQ='Base>=0.1\nTelldus>=0.1'),
File "/home/pi/src/tellstick-server/build/env/local/lib/python2.7/site-packages/setuptools/__init__.py", line 162, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/pi/src/tellstick-server/sdk/sdk/plugin.py", line 95, in run
requirements = self.__downloadRequirements(prebuiltPackages)
File "/home/pi/src/tellstick-server/sdk/sdk/plugin.py", line 171, in __downloadRequirements
cmd = DownloadCommand()
File "/home/pi/src/tellstick-server/build/env/local/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 195, in __init__
super(RequirementCommand, self).__init__(*args, **kw)
TypeError: __init__() takes at least 3 arguments (1 given)
running telldus_plugin
Could not build plugin
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

I can now add, an attempt to build the mqtt-plugin, fresh from https://github.com/telldus/tellstick-server-plugins on a freshly installed Ubuntu Server 20.04 on VMware Workstation 16 running on Windows 10 failed in the exact same spot as it have done on Raspbian Debian Stretch and Buster.
Last edited by flyvert on Thu Apr 08, 2021 5:18 am, edited 1 time in total.
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

I can also add that an attempt to replace the embedded pip version at tellstick-server/build/env/local/lib/python2.7/site-packages with the one coming with the standard Python package for Debian has made the tellstick.sh build script to take a few more steps.

I now get the Python .egg output files but without any PGP hashes calculated. This is likely something I can overcome by running PGP manually on the .egg files, then put everything into a .zip and attempt to upload to the Tellstick.

However, I would buy the person who tells me how to build the MQTT Client Tellstick plugin using minimal changes to the GitHub distro nor surroundings as it was made to work at the time this was working for me (early 2019) can expect funding of a couple of good beers via Swish.
flyvert
Posts: 16
Joined: Fri Mar 17, 2023 9:45 am

Re: MQTT plugin for Tellstick ZNet Lite v2?

Post by flyvert »

I have managed to put together the MQTT Plugin for Tellstick ZNet Lite v2 again.

Here's the story; thanks to Quazzie who provided some useful hints.

The Tellstick Server repository on GitHub is outdated (I have filed a bug report!) and can't build the MQTT Client plugin no more, however it leaves enough results so the job can be finished manually.

The functions of tellstick.sh have stopped working, likely due to the evolution of Debian, Python and all the subcomponents used in Tellstick Server.


Here is what it takes to piece it together:

1. Clone the Tellstick Server and Tellstick Server Plugins repositories to your build machine (Debian, Ubuntu, etc.)
2. Fulfill the setup of Tellstick Server and plugin (don't forget to edit the plugin's setup.py with your email and name)
3. Make sure you have setup the build environment active (. ~/src/tellstick-server/build/env/bin/activate)
4. Downgrade the embedded "pip" version from v23 down to v10 by using pip itself: pip install pip==10
5. Create a personal PGP key (gpg ...) and have it registered with Telldus Support to allow uploading the plugin in the final steps.
6. Attempt to build the plugin which will fail, but leave the job almost complete in the "package" subfolder it creates below the plugin folder

(env) pi@rpi:~/src/tellstick-server/tellstick.sh build-plugin ~/src/tellstick-server-plugins/mqtt-client

(env) pi@rpi:~/src/tellstick-server-plugins/mqtt-client $ ls -l package/
total 84
-rw-r--r-- 1 pi pi 304 Apr 13 22:28 manifest.yml
-rw-r--r-- 1 pi pi 4019 Apr 13 22:28 MQTT_Client-1.1-py2.7.egg
-rw-r--r-- 1 pi pi 74620 Apr 13 22:28 paho_mqtt-1.5.1-py2.7.egg


7. Use gpg to create PGP signatures (.asc) files for the two .egg files (this requires you to have created a PGP key, see step 5)
(env) pi@rpi: gpg --armor --detach-sign paho_mqtt-1.5.1-py2.7.egg
(env) pi@rpi: gpg --armor --detach-sign MQTT_Client-1.1-py2.7.egg


8. Top up with adding your public PGP key
(env) pi@rpi: gpg --armor --output key.pub --export your.email.address

9. Copy the .png from the root folder of the plugin
(env) pi@rpi:~/src/tellstick-server-plugins/mqtt-client $ ls -l package/
total 108
-rw-r--r-- 1 pi pi 1782 Apr 13 23:16 key.pub
-rw-r--r-- 1 pi pi 304 Apr 13 22:28 manifest.yml
-rw-r--r-- 1 pi pi 4019 Apr 13 22:28 MQTT_Client-1.1-py2.7.egg
-rw-r--r-- 1 pi pi 488 Apr 13 23:12 MQTT_Client-1.1-py2.7.egg.asc
-rw-r--r-- 1 pi pi 11235 Apr 13 23:00 mqtt.png
-rw-r--r-- 1 pi pi 74620 Apr 13 22:28 paho_mqtt-1.5.1-py2.7.egg
-rw-r--r-- 1 pi pi 488 Apr 13 23:13 paho_mqtt-1.5.1-py2.7.egg.asc

10. Put the above seven files in a .zip file and upload to the Tellstick (you may have to install zip first; unsure if Tellstick eats gzip files)

(env) pi@rpi: zip MQTT_Client-1.1.zip *
adding: key.pub (deflated 26%)
adding: manifest.yml (deflated 32%)
adding: MQTT_Client-1.1-py2.7.egg (deflated 18%)
adding: MQTT_Client-1.1-py2.7.egg.asc (deflated 20%)
adding: mqtt.png (stored 0%)
adding: paho_mqtt-1.5.1-py2.7.egg (deflated 1%)
adding: paho_mqtt-1.5.1-py2.7.egg.asc (deflated 20%)

(env) pi@rpi: ls -l MQTT_Client-1.1.zip
-rw-r--r-- 1 pi pi 91671 13 Apr 23:33 MQTT_Client-1.1.zip
Post Reply