Python Plugin: Shelly MQTT

Python and python framework

Moderator: leecollings

Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by Quax1507 »

I tried to add Shelly MQTT plugin to my Domotic 2020.2 (Build 12393) but it does not appear under "Hardware" after restart of Domoticz.
There is nothing in the log.

Python3 -V output is:
Python 3.7.3

dpkg --get-selections | grep libpython3 output is:
libpython3-dev:armhf install
libpython3-stdlib:armhf install
libpython3.7:armhf install
libpython3.7-dev:armhf install
libpython3.7-minimal:armhf install
libpython3.7-stdlib:armhf install

Is there missing something?

Edit: fixed - wron directory :-(
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

darrepac wrote: Saturday 02 January 2021 16:54 EDIt: going back 1 hour later without touching anything, I succesfully turned on one light... but then I was not able to turn it off. It is like if there was traffic jam in the commands...
On which Domoticz page do you try to use On/Off commands? On Device page? As i do not see "on/off" nearby the color selector screen.
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

Quax1507 wrote: Sunday 03 January 2021 17:03 Edit: fixed - wron directory :-(
In case you plan to use and update Python plugins you can also use plugin managers:

https://github.com/stas-demydiuk/domoti ... ns-manager
https://github.com/ycahome/pp-manager
darrepac
Posts: 133
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: Python Plugin: Shelly MQTT

Post by darrepac »

Aren’t those 2 buttons on and off??
938DEFFE-22C3-4673-9FE4-3FD8E5CD84BF.jpeg
938DEFFE-22C3-4673-9FE4-3FD8E5CD84BF.jpeg (225.37 KiB) Viewed 2401 times
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

darrepac wrote: Tuesday 05 January 2021 0:02 Aren’t those 2 buttons on and off?
Yes they transmit command on/off as i see in my logs. In my tests my plugin sends this mqtt commands immediately. But the Shelly device state will only change in Domoticz when the device responds with its state.

You can look up your own Domoticz debug log and MQTT transport with MQTT Lens at the same time.
If your mqtt server network bandwidth or cpu is saturated might drop some mqtt messages.
darrepac
Posts: 133
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: Python Plugin: Shelly MQTT

Post by darrepac »

Domoticz log:
2021-01-05 19:18:47.873 Status: User: darrepac (IP: 192.168.0.1) initiated a switch command (212/Shelly-Spot1-RGB/On)
then in mosquitto_sub terminal I see:
shellies/shellycolorbulb-483FDA928411/color/0/status {"ison":false,"source":"mqtt","has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"mode":"color","red":11,"green":14,"blue":255,"white":0,"gain":100,"temp":4750,"brightness":100,"effect":0}
shellies/shellycolorbulb-483FDA928411/light/0/power 0.00
shellies/shellycolorbulb-483FDA928411/light/0/energy 42
shellies/shellycolorbulb-483FDA928411/color/0/command on
shellies/shellycolorbulb-483FDA928411/color/0 off
shellies/shellycolorbulb-483FDA928411/color/0/status {"ison":false,"source":"mqtt","has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"mode":"color","red":11,"green":14,"blue":255,"white":0,"gain":100,"temp":4750,"brightness":100,"effect":0}
shellies/shellycolorbulb-483FDA928411/light/0/power 0.00
shellies/shellycolorbulb-483FDA928411/light/0/energy 42
and nothing happen: so it seems the command is well send by your plugin, isn't it?

I checked in shelly but shellycolorbulb is even not referenced... (https://shelly-api-docs.shelly.cloud/#s ... y-overview)
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Python Plugin: Shelly MQTT

Post by Number8 »

I just want to report that I installed on a separate RaspPI the MQTT broker as per instructions found here https://sancla.com/domoticz/mqtt-for-domoticz/ Then I installed on the master Domoticz (Debian on NUC intel) MQTT gateway and then Shelly MQTT python plugin. 4 Shelly Door/Window 2 (more to come) https://shelly.cloud/products/shelly-do ... on-sensor/are currently triggering a Door contact device smoothly. It is aimed at: (1) shutdown heaters when a window is opened and resume to last know state whenever window is closed, (2) in case of rain or when leaving the place reports readily whether some roof windows are opened (sorry guys these windows are not motorized ;) )
Thank you to the developers for all the hard work that makes it possible
Debian buster on NUC and three RPi with buster.
darrepac
Posts: 133
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: Python Plugin: Shelly MQTT

Post by darrepac »

I think I found out the issue: traffic jam!
I deactivated the MQTT plugin which permit to send out each parameter from domoticz through MQTT (tons of message!) and now everything is working perfectly.

Yet I still have one issue. I have 3 color bulbs that I can drive independently but I would also like to drive them with 1 swicth.
For doing so, I created a dummy color bulb and put it in the slave part of each of the 3 color bulb.
If I press ON on the dummy color bulb, it makes all 3 bulbs ON but no command is send with your plugin through MQTT... Is it normal?
2021-01-06 14_45_18-Window.png
2021-01-06 14_45_18-Window.png (147.51 KiB) Viewed 2356 times
2021-01-06 14_19_59-Window.png
2021-01-06 14_19_59-Window.png (52 KiB) Viewed 2356 times
leby
Posts: 98
Joined: Monday 28 July 2014 9:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Stockholm
Contact:

Re: Python Plugin: Shelly MQTT

Post by leby »

Failed to load the plugin:
Running Domoticz 2020.1.11804-8 on a
Synology NAS DS216j DSM 6.2.3.
Python 3.8.2

I have had the plugin working in the past but now with new installation I cant get the Shelly MQTT to load anymore.

I get this error

Code: Select all

2021-01-07 15:24:43.532 Error: Shelly MQTT hardware (3) thread seems to have ended unexpectedly
2021-01-07 15:27:44.220 Error: (ShellyMQTT) failed to load 'plugin.py', Python Path used was ':/var/packages/py3k/target/usr/local/lib/python38.zip:/var/packages/py3k/target/usr/local/lib/python3.8:/var/packages/py3k/target/usr/local/lib/python3.8/lib-dynload:/var/packages/py3k/target/usr/local/lib/python3.8/site-packages'.
2021-01-07 15:27:44.221 Error: (Shelly MQTT) Module Import failed, exception: 'ModuleNotFoundError'
2021-01-07 15:27:44.221 Error: (Shelly MQTT) Module Import failed: ' Name: plugin'
in line 2 it say "python38.zip" but there is no such file and I don't know if it should be??
The directories is there

Code: Select all

usr@MyNas:/var/packages/py3k/target/usr/local/lib$ dir
total 2548
drwxr-xr-x  3 root root    4096 Jun 29  2020 .
drwxr-xr-x  5 root root    4096 Jun 29  2020 ..
lrwxrwxrwx  1 root root      19 Jun 29  2020 libpython3.8.so -> libpython3.8.so.     1.0
-rwxr-xr-x  1 root root 2588512 Jun 29  2020 libpython3.8.so.1.0
-rwxr-xr-x  1 root root    5352 Jun 29  2020 libpython3.so
drwxr-xr-x 32 root root    4096 Jan  7 11:56 python3.8
and if I'm looking in the log of Domoticz it seems to have loaded Python correct.

Code: Select all

2021-01-07 15:27:41.421 Status: PluginSystem: Started, Python version '3.8.2'
Any suggestion on what is wrong?

EDIT

I did a symlink
ln -s /var/packages/py3k/target/usr/local/lib/python3.8/ /usr/local/lib/python3.8
and made the plugin.py executable
after this I do not get any error but still no ShellyMQTT module :-(

I do have this in the Domoticz logg

Code: Select all

2021-01-07 17:45:43.197 Status: Python EventSystem: Initalizing event module.
But it is not a solution... anyone?
/lennart
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by Quax1507 »

I have enabled Shelly_MQTT a few days ago. Today Domoticz crashed:

Code: Select all

2021-01-07 19:16:31.886  (Shelly) Connected to MQTT Server: 127.0.0.1:1883
2021-01-07 19:16:34.033  Status: MQTT: connected to: localhost:1883
2021-01-07 19:16:34.083  Error: Thread 12 (Thread 0xb01fe220 (LWP 19739)):
2021-01-07 19:16:34.083  Error: #0  __waitpid (options=0, stat_loc=0xb01fbdd0, pid=19765) at ../sysdeps/unix/sysv/linux/waitpid.c:30
2021-01-07 19:16:34.084  Error: #1  __waitpid (pid=19765, stat_loc=0xb01fbdd0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:25
2021-01-07 19:16:34.084  Error: #2  0x002dbcdc in dumpstack_gdb(bool) ()
2021-01-07 19:16:34.084  Error: #3  0x002dc2a8 in signal_handler(int, siginfo_t*, void*) ()
2021-01-07 19:16:34.085  Error: #4  <signal handler called>
2021-01-07 19:16:34.085  Error: #5  raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:50
2021-01-07 19:16:34.085  Error: #6  <signal handler called>
2021-01-07 19:16:34.085  Error: #7  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
2021-01-07 19:16:34.085  Error: #8  0xb69d0230 in __GI_abort () at abort.c:79
2021-01-07 19:16:34.086  Error: #9  0x009a1aa8 in __gnu_cxx::__verbose_terminate_handler() ()
2021-01-07 19:16:34.086  Error: #10 0x00904f44 in __cxxabiv1::__terminate(void (*)()) ()
2021-01-07 19:16:34.086  Error: #11 0x00904fb8 in std::terminate() ()
2021-01-07 19:16:34.086  Error: #12 0x0090fa68 in __cxa_throw ()
2021-01-07 19:16:34.087  Error: #13 0x007161e8 in Json::throwLogicError(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
2021-01-07 19:16:34.087  Error: #14 0x0071ebdc in Json::Value::resolveReference(char const*, char const*) ()
2021-01-07 19:16:34.087  Error: #15 0x0037ffd0 in http::server::CWebServer::GetJSonDevices(Json::Value&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
2021-01-07 19:16:34.087  Error: #16 0x733a6e72 in ?? ()

Any idea how to solve?
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

darrepac wrote: Tuesday 05 January 2021 19:21 I checked in shelly but shellycolorbulb is even not referenced... (https://shelly-api-docs.shelly.cloud/#s ... y-overview)
Yes, i have never seen "shellycolorbulb" before. But the plugin only check if "bulb" included in name, so it should work.
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

darrepac wrote: Wednesday 06 January 2021 14:46 If I press ON on the dummy color bulb, it makes all 3 bulbs ON but no command is send with your plugin through MQTT... Is it normal?
Dummy devices is not handled by Shelly_MQTT plugin, only auto-detected physical Shelly devices. So yes, it wont trigger a shellymqtt command from a Dummy. Unless Domoticz translates that internally to the plugin which handles the slave devices, but as you see that is not the case. (you can see your logs if Domoticz passes ON command to the slaves, but i guess it is simply changes its states internally without triggering the plugin Command action.
Otherwise i have not seen any description in the Domoticz API, to access another hardware devices from a python plugin.

I guess that Domoticz Scene or Group is what you are looking for.
Last edited by lwolf on Friday 08 January 2021 21:06, edited 1 time in total.
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

leby wrote: Thursday 07 January 2021 15:43 Failed to load the plugin:
Running Domoticz 2020.1.11804-8 on a
Synology NAS DS216j DSM 6.2.3.
Python 3.8.2

I have had the plugin working in the past but now with new installation I cant get the Shelly MQTT to load anymore.

I get this error

Code: Select all

2021-01-07 15:24:43.532 Error: Shelly MQTT hardware (3) thread seems to have ended unexpectedly
2021-01-07 15:27:44.220 Error: (ShellyMQTT) failed to load 'plugin.py', Python Path used was ':/var/packages/py3k/target/usr/local/lib/python38.zip:/var/packages/py3k/target/usr/local/lib/python3.8:/var/packages/py3k/target/usr/local/lib/python3.8/lib-dynload:/var/packages/py3k/target/usr/local/lib/python3.8/site-packages'.
2021-01-07 15:27:44.221 Error: (Shelly MQTT) Module Import failed, exception: 'ModuleNotFoundError'
2021-01-07 15:27:44.221 Error: (Shelly MQTT) Module Import failed: ' Name: plugin'
Sorry, I am not familiar with Synology, please lookup Synology topic about installing python on Synology:
viewtopic.php?t=7087&start=340
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

Quax1507 wrote: Thursday 07 January 2021 19:53 I have enabled Shelly_MQTT a few days ago. Today Domoticz crashed:

Code: Select all

2021-01-07 19:16:31.886  (Shelly) Connected to MQTT Server: 127.0.0.1:1883
2021-01-07 19:16:34.033  Status: MQTT: connected to: localhost:1883
2021-01-07 19:16:34.083  Error: Thread 12 (Thread 0xb01fe220 (LWP 19739)):
2021-01-07 19:16:34.083  Error: #0  __waitpid (options=0, stat_loc=0xb01fbdd0, pid=19765) at ../sysdeps/unix/sysv/linux/waitpid.c:30
2021-01-07 19:16:34.084  Error: #1  __waitpid (pid=19765, stat_loc=0xb01fbdd0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:25
2021-01-07 19:16:34.084  Error: #2  0x002dbcdc in dumpstack_gdb(bool) ()
2021-01-07 19:16:34.084  Error: #3  0x002dc2a8 in signal_handler(int, siginfo_t*, void*) ()
2021-01-07 19:16:34.085  Error: #4  <signal handler called>
2021-01-07 19:16:34.085  Error: #5  raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:50
2021-01-07 19:16:34.085  Error: #6  <signal handler called>
2021-01-07 19:16:34.085  Error: #7  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
2021-01-07 19:16:34.085  Error: #8  0xb69d0230 in __GI_abort () at abort.c:79
2021-01-07 19:16:34.086  Error: #9  0x009a1aa8 in __gnu_cxx::__verbose_terminate_handler() ()
2021-01-07 19:16:34.086  Error: #10 0x00904f44 in __cxxabiv1::__terminate(void (*)()) ()
2021-01-07 19:16:34.086  Error: #11 0x00904fb8 in std::terminate() ()
2021-01-07 19:16:34.086  Error: #12 0x0090fa68 in __cxa_throw ()
2021-01-07 19:16:34.087  Error: #13 0x007161e8 in Json::throwLogicError(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
2021-01-07 19:16:34.087  Error: #14 0x0071ebdc in Json::Value::resolveReference(char const*, char const*) ()
2021-01-07 19:16:34.087  Error: #15 0x0037ffd0 in http::server::CWebServer::GetJSonDevices(Json::Value&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool, long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
2021-01-07 19:16:34.087  Error: #16 0x733a6e72 in ?? ()

Any idea how to solve?
Without knowing the system specification, full database, systemlogs and device informations, it is hard as television fortune telling.

It looks like your Domoticz system stopped instantly after connecting to the mqtt server. Your log does not contain any more useful information about the action that triggers this error. Maybe there are some strange (non-latin characters) appeared in the JSON messages or simply too long messages arrived. Or you are using a beta version, or a very old version...

You have got several options:
- make sure you never use Custom MQTT prefix on any of your Shelly devices
- try another Domoticz version (i have no clue which do you use)
- disable all other hardwares in Domo and retest
- disable shellymqtt plugin and retest stability with enabling any other python plugin you wish
- delete all shelly devices and let plugin autodetection find every shelly devices on its own
- delete full domoticz database and recreate from start
poeschel
Posts: 13
Joined: Tuesday 21 April 2020 15:04
Target OS: Linux
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Python Plugin: Shelly MQTT

Post by poeschel »

Hello,
I use 4 shelly 2.5 in roller shutter mode. The Shelly_MQTT-Plugin makes many devices for every shelly. 67 Entries in the Devices were created.
The first two days I get often error-messages like this in the protokoll:

Code: Select all

2021-01-10 18:06:00.353 Error: (Rollo Fionn schräg) Device creation failed, Domoticz settings prevent accepting new devices.
One of the shelly does not working well. I can use the slider, but the buttons doesent work. If I klick on the button I get the message that all is correct, but the roller doesn't work. What can I do, that also the fourth shelly works well? Can anybody help me?
Thanks

PS: The firmware on the shelly is the newest: Current version: 20201228-092242/v1.9.3@ad2bb4e3
You have latest version on your device!
Version: 2021.1
Platform: Ubuntu server 20.04
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

poeschel wrote: Monday 11 January 2021 21:02 The first two days I get often error-messages like this in the protokoll:

Code: Select all

2021-01-10 18:06:00.353 Error: (Rollo Fionn schräg) Device creation failed, Domoticz settings prevent accepting new devices.
"Rollo Fionn schräg"? I hope that "Use custom MQTT prefix" is disabled on all of your shellies, as it messes things a lot.

Disable that function on all shellies, delete all devices that affected, make sure that auto device creation enabled in Domoticz and let shelly_mqtt plugin learn device names properly.
"Device creation failed" message comes from Domoticz system, not from shelly_mqtt plugin.
poeschel
Posts: 13
Joined: Tuesday 21 April 2020 15:04
Target OS: Linux
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Python Plugin: Shelly MQTT

Post by poeschel »

"Rollo Fionn schräg"? I hope that "Use custom MQTT prefix" is disabled on all of your shellies, as it messes things a lot.
Yes, custom MQQTT prefix I disabled on all shellys.
Bild1.JPG
Bild1.JPG (27.04 KiB) Viewed 2238 times
Do I need an entry for every shelly in the hardware list or one for all shellys? Will the shellys then appear in the device list? It's possible, this is my mistake. I had 4 entries in the hardware list for my for shellys.
Thanks
Attachments
Bild2.JPG
Bild2.JPG (16.54 KiB) Viewed 2238 times
Version: 2021.1
Platform: Ubuntu server 20.04
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Python Plugin: Shelly MQTT

Post by Number8 »

In the hardware list you should have one entry for the plugin. In the devices list you have for each Shelly device as many as devices (ie idx) that each of them requires. How many devices depends on Shelly device type. For instance for the Shelly door window sensor there are 6 devices
Debian buster on NUC and three RPi with buster.
poeschel
Posts: 13
Joined: Tuesday 21 April 2020 15:04
Target OS: Linux
Domoticz version: 2021.1
Location: Germany
Contact:

Re: Python Plugin: Shelly MQTT

Post by poeschel »

In the hardware list you should have one entry for the plugin.
Thanks, now it works fine. :D That was my mistake
poeschel
Version: 2021.1
Platform: Ubuntu server 20.04
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Python Plugin: Shelly MQTT

Post by lwolf »

poeschel wrote: Thursday 14 January 2021 20:25
In the hardware list you should have one entry for the plugin.
Thanks, now it works fine. :D That was my mistake
poeschel
Yes, only one plugin entry is needed on Hardware page. That will automatically create Devices based on its name and MQTT packets arriving. Thank you very much for your donation poeschel!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest