Python Plugin: Shelly MQTT

Python and python framework

Moderator: leecollings

josemi
Posts: 31
Joined: Thursday 08 March 2018 16:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by josemi »

Hi
Before opening an issue in github repo, could you watch in your domoticz if your Shelly 2.5 energy devices are updating (Last Seen column)?
My 8 Shelly 2.5 have quit of updating since september 2019.
energy-shelly.JPG
energy-shelly.JPG (44.38 KiB) Viewed 2615 times
My version: 0.4.6
Thank you
MikeyMan
Posts: 237
Joined: Wednesday 17 October 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by MikeyMan »

General question; is there a minimum of power consumption to be measured?

Maeasured my Modem this night; using 12 watts; adding up to (naturally) 12Wh.

Now switched to measuring my router, using 5 watts. However, consumption stays at 0?
pro2call
Posts: 14
Joined: Monday 31 March 2014 16:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: (52.557965, 5.914462)
Contact:

Re: Python Plugin: Shelly MQTT

Post by pro2call »

niekbruggeman wrote: Sunday 05 July 2020 13:53 I can confirm that the new shelly dimmer 2 works correct with Domoticz.
I use the native firmware of the Shelly, and the Shelly MQTT plugin for Domoticz 2020.2.
Yes this is indeed working all OK.
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Python Plugin: Shelly MQTT

Post by fransiefrans »

Hi all,

I have an issue with the hardware plugin.
I'm running domoticz stable.
Version: 2020.2
Build Hash: b63341bc0
Compile Date: 2020-04-26 13:47:55
dzVents Version: 3.0.2
Python Version: None

As you can see Python Version: None.

I tried:

Code: Select all

sudo apt-get install libpython3.5-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpython3.5-dev is already the newest version (3.5.4-4).
The following package was automatically installed and is no longer required:
  rpi-eeprom-images
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Sadly that didn't fix the python issue.

Is there something else I can do to get Shelly Mqtt hardware visible in the domoticz hardware list?


alanf wrote: Sunday 08 December 2019 18:47 When I was trying to get the Shelly MQTT working I came across this: https://www.domoticz.com/forum/viewtopi ... 2&start=20

What worked for me on Pi : Raspbian GNU/Linux 9 (stretch): the build already includes Python 3.5.3 (reported by python3 -V), but it needs libpython3.5-dev, my cut and paste notes from command line at the time have:

Code: Select all

cd domoticz/plugins
git clone https://github.com/enesbcs/Shelly_MQTT
cd Shelly_MQTT/
chmod +x plugin.py
chmod +x mqtt.py
sudo apt-get install libpython3.5-dev
sudo systemctl restart domoticz.service
Then restart Domoticz and check the log, it should include lines:

Code: Select all

[timestamp]Status: PluginSystem: Started, Python version '3.5.3'. 
... and a couple of seconds later
[timestamp]Status: Python EventSystem: Initalizing event module. 
[timestamp]Status: EventSystem: Started 
[timestamp]Status: EventSystem: Queue thread started... 
And Domoticz "About" reports:

Code: Select all

Version: 4.10717
Build Hash: b38b49e5
Compile Date: 2019-05-09 12:04:08
dzVents Version: 2.4.19
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
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 »

fransiefrans wrote: Wednesday 26 August 2020 6:29 And Domoticz "About" reports:

Code: Select all

Version: 4.10717
Build Hash: b38b49e5
Compile Date: 2019-05-09 12:04:08
dzVents Version: 2.4.19
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
Your system may contain several python versions: 3.5, 3.6, 3.7 or 3.8
Delete all except one, or try to select the default.

Code: Select all

python --version
update-alternatives --list python
Atis
Posts: 37
Joined: Monday 30 March 2020 7:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by Atis »

Good plugin
Last edited by Atis on Sunday 20 September 2020 7:15, edited 2 times in total.
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Python Plugin: Shelly MQTT

Post by snellejellep »

Gerwin wrote: Thursday 30 July 2020 20:01 Hello,

The Shelly button is that one impemented ???
does someone knows that

Gerwin
if you mean the i3, yes it is.
just the button is a case for a shelly 1 which obviously is supported
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
fransiefrans
Posts: 59
Joined: Sunday 14 June 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: Netherlands
Contact:

Re: Python Plugin: Shelly MQTT

Post by fransiefrans »

lwolf wrote: Tuesday 01 September 2020 17:06
fransiefrans wrote: Wednesday 26 August 2020 6:29 And Domoticz "About" reports:

Code: Select all

Version: 4.10717
Build Hash: b38b49e5
Compile Date: 2019-05-09 12:04:08
dzVents Version: 2.4.19
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]
Your system may contain several python versions: 3.5, 3.6, 3.7 or 3.8
Delete all except one, or try to select the default.

Code: Select all

python --version
update-alternatives --list python
Thank you for the hint.

I removed Phyton 2.7

Code: Select all

sudo apt-get remove python2.7 --purge
then restarted domoticz and then Phyton Version in domoticz in the about section showed.
Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
Shelly MQTT was visible in Hardware.
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 am quite happy with this plugin: it works well.
Yet, when this plugin has been released the sole solution to get info from Shelly was MQTT but it means to deactivate cloud.
Now, Shelly has introduced other mean to access Shelly data using CoAP and REST and keep cloud connection.
Do you plan to support it?
If not, probably I will give a try to this other plugin supporting it: viewtopic.php?f=65&t=32616

thx
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: Sunday 20 September 2020 18:43 Yet, when this plugin has been released the sole solution to get info from Shelly was MQTT but it means to deactivate cloud.
The one and biggest benefit of the Shelly that i can get rid of the Cloud without changing its firmware.
So no, i have no plans to support other communication forms, as MQTT is the best i know.
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 have some problem with energy: sometimes it goes to 0 while there are power
2020-10-09 16_40_53-Window.png
2020-10-09 16_40_53-Window.png (80.14 KiB) Viewed 2306 times
Any idea how I can debug this? I saw nothing in the log:

Code: Select all

2020-10-09 18:04:18.878 (ShellyMQTT) 3a 30 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. :0}
2020-10-09 18:04:18.879 (ShellyMQTT) MQTT message: shellies/shelly1-B9CB90/relay/0 off
2020-10-09 18:04:18.879 (ShellyMQTT) >>> Looking for device: shelly1-B9CB90-0
2020-10-09 18:04:18.880 (ShellyMQTT) MQTT message: shellies/shelly1-B9CB90/input/0 0
2020-10-09 18:04:18.880 (ShellyMQTT) >>> Looking for device: shelly1-B9CB90-0-input
2020-10-09 18:04:18.880 (ShellyMQTT) MQTT message: shellies/shelly1-B9CB90/input_event/0 {'event': '', 'event_cnt': 0}
2020-10-09 18:04:18.880 (ShellyMQTT) >>> Looking for device: shelly1-B9CB90-input_event0
2020-10-09 18:04:19.282 (ShellyMQTT) Heartbeating...
2020-10-09 18:04:19.282 (ShellyMQTT) MqttClient::ping
2020-10-09 18:04:19.282 (ShellyMQTT) Sending 2 bytes of data
2020-10-09 18:04:19.282 (ShellyMQTT) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-10-09 18:04:19.333 (ShellyMQTT) Received 2 bytes of data
2020-10-09 18:04:19.333 (ShellyMQTT) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-10-09 18:04:29.262 (ShellyMQTT) Heartbeating...
2020-10-09 18:04:29.262 (ShellyMQTT) MqttClient::ping
2020-10-09 18:04:29.262 (ShellyMQTT) Sending 2 bytes of data
2020-10-09 18:04:29.262 (ShellyMQTT) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-10-09 18:04:29.314 (ShellyMQTT) Received 2 bytes of data
2020-10-09 18:04:29.314 (ShellyMQTT) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-10-09 18:04:34.326 (ShellyMQTT) Received 51 bytes of data
2020-10-09 18:04:34.326 (ShellyMQTT) 30 31 00 2a 73 68 65 6c 6c 69 65 73 2f 73 68 65 6c 6c 79 70 01.*shellies/shellyp
2020-10-09 18:04:34.327 (ShellyMQTT) 6c 75 67 2d 73 2d 37 41 33 32 37 39 2f 72 65 6c 61 79 2f 30 lug-s-7A3279/relay/0
2020-10-09 18:04:34.327 (ShellyMQTT) 2f 70 6f 77 65 72 34 30 2e 34 36 .. .. .. .. .. .. .. .. .. /power40.46
2020-10-09 18:04:34.327 (ShellyMQTT) Received 53 bytes of data
2020-10-09 18:04:34.327 (ShellyMQTT) 30 33 00 2b 73 68 65 6c 6c 69 65 73 2f 73 68 65 6c 6c 79 70 03.+shellies/shellyp
2020-10-09 18:04:34.327 (ShellyMQTT) 6c 75 67 2d 73 2d 37 41 33 32 37 39 2f 72 65 6c 61 79 2f 30 lug-s-7A3279/relay/0
2020-10-09 18:04:34.327 (ShellyMQTT) 2f 65 6e 65 72 67 79 31 30 38 37 38 35 .. .. .. .. .. .. .. /energy108785
2020-10-09 18:04:34.327 (ShellyMQTT) Received 42 bytes of data
2020-10-09 18:04:34.327 (ShellyMQTT) 30 28 00 24 73 68 65 6c 6c 69 65 73 2f 73 68 65 6c 6c 79 70 0(.$shellies/shellyp
2020-10-09 18:04:34.328 (ShellyMQTT) 6c 75 67 2d 73 2d 37 41 33 32 37 39 2f 72 65 6c 61 79 2f 30 lug-s-7A3279/relay/0
2020-10-09 18:04:34.328 (ShellyMQTT) 6f 6e .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. on
2020-10-09 18:04:34.328 (ShellyMQTT) Received 49 bytes of data
2020-10-09 18:04:34.328 (ShellyMQTT) 30 2f 00 28 73 68 65 6c 6c 69 65 73 2f 73 68 65 6c 6c 79 70 0/.(shellies/shellyp
2020-10-09 18:04:34.328 (ShellyMQTT) 6c 75 67 2d 73 2d 37 41 33 32 37 39 2f 74 65 6d 70 65 72 61 lug-s-7A3279/tempera
2020-10-09 18:04:34.328 (ShellyMQTT) 74 75 72 65 32 39 2e 38 31 .. .. .. .. .. .. .. .. .. .. .. ture29.81
2020-10-09 18:04:34.328 (ShellyMQTT) Received 51 bytes of data
2020-10-09 18:04:34.328 (ShellyMQTT) 30 31 00 2a 73 68 65 6c 6c 69 65 73 2f 73 68 65 6c 6c 79 70 01.*shellies/shellyp
2020-10-09 18:04:34.328 (ShellyMQTT) 6c 75 67 2d 73 2d 37 41 33 32 37 39 2f 74 65 6d 70 65 72 61 lug-s-7A3279/tempera
2020-10-09 18:04:34.329 (ShellyMQTT) 74 75 72 65 5f 66 38 35 2e 36 35 .. .. .. .. .. .. .. .. .. ture_f85.65
2020-10-09 18:04:34.329 (ShellyMQTT) Received 49 bytes of data
2020-10-09 18:04:34.329 (ShellyMQTT) 30 2f 00 2c 73 68 65 6c 6c 69 65 73 2f 73 68 65 6c 6c 79 70 0/.,shellies/shellyp
2020-10-09 18:04:34.329 (ShellyMQTT) 6c 75 67 2d 73 2d 37 41 33 32 37 39 2f 6f 76 65 72 74 65 6d lug-s-7A3279/overtem
2020-10-09 18:04:34.329 (ShellyMQTT) 70 65 72 61 74 75 72 65 30 .. .. .. .. .. .. .. .. .. .. .. perature0
2020-10-09 18:04:34.330 (ShellyMQTT) MQTT message: shellies/shellyplug-s-7A3279/relay/0/power 40.46
2020-10-09 18:04:34.331 (ShellyMQTT) >>> Looking for device: shellyplug-s-7A3279-0-energy
2020-10-09 18:04:34.331 (Shelly Plug S) Updating device from 0:'41.57;1849.345' to have values 0:'40.46;1849.345'.
2020-10-09 18:04:34.362 (ShellyMQTT) MQTT message: shellies/shellyplug-s-7A3279/relay/0/energy 108785
2020-10-09 18:04:34.362 (ShellyMQTT) >>> Looking for device: shellyplug-s-7A3279-0-energy
2020-10-09 18:04:34.363 (Shelly Plug S) Updating device from 0:'40.46;1849.345' to have values 0:'40.46;1849.345'.
2020-10-09 18:04:34.394 (ShellyMQTT) MQTT message: shellies/shellyplug-s-7A3279/relay/0 on
2020-10-09 18:04:34.394 (ShellyMQTT) >>> Looking for device: shellyplug-s-7A3279-0
2020-10-09 18:04:34.395 (ShellyMQTT) MQTT message: shellies/shellyplug-s-7A3279/temperature 29.81
2020-10-09 18:04:34.395 (ShellyMQTT) >>> Looking for device: shellyplug-s-7A3279-temp
2020-10-09 18:04:34.395 (Plug S) Updating device from 0:'29.81' to have values 0:'29.81'.
2020-10-09 18:04:34.412 (ShellyMQTT) MQTT message: shellies/shellyplug-s-7A3279/temperature_f 85.65
2020-10-09 18:04:34.412 (ShellyMQTT) MQTT message: shellies/shellyplug-s-7A3279/overtemperature 0
2020-10-09 18:05:29.315 (ShellyMQTT) Heartbeating...
2020-10-09 18:05:29.315 (ShellyMQTT) MqttClient::ping
2020-10-09 18:05:29.316 (ShellyMQTT) Sending 2 bytes of data
2020-10-09 18:05:29.316 (ShellyMQTT) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-10-09 18:05:29.366 (ShellyMQTT) Received 2 bytes of data
2020-10-09 18:05:29.366 (ShellyMQTT) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-10-09 18:05:29.366 (ShellyMQTT) Disconnect directive received for '127.0.0.1:1883'.
2020-10-09 18:05:29.366 (ShellyMQTT) Handling TCP disconnect, socket (127.0.0.1:1883) is connected
2020-10-09 18:05:29.367 (ShellyMQTT) Queued asynchronous read aborted (127.0.0.1:1883), [125] Operation canceled.
2020-10-09 18:05:29.417 (ShellyMQTT) Disconnect event received for '127.0.0.1:1883'.
2020-10-09 18:05:29.418 (ShellyMQTT) MqttClient::onDisonnect
2020-10-09 18:05:29.418 (ShellyMQTT) MqttClient::close
2020-10-09 18:05:29.418 (ShellyMQTT) onMQTTDisconnected
2020-10-09 18:05:29.418 (ShellyMQTT) Deallocating connection object '127.0.0.1' (127.0.0.1:1883).
2020-10-09 18:05:29.418 (ShellyMQTT) onStop called
grenouilles
Posts: 2
Joined: Thursday 27 March 2014 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by grenouilles »

Bonjour,
Je viens d'acheter un module Shelly EM et un Shelly HT pour les intégrer dans Domoticz en passant par MQTT.
Pour ce faire, j'ai installé le plug-in Shelly-MQTT.
Le Shelly HT ne remonte pas dans Domoticz et pour le EM je n'ai uniquement la valeur "Voltage".
Je vous remercie pour votre aide.
grenouilles
Posts: 2
Joined: Thursday 27 March 2014 13:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by grenouilles »

Hi,

I have two PI 3B with Domoticz, one with a ShellyEM.
I would like to transfert the Shelly data between PI.
I have MQTT + Node-Red to the 2 PI.
The first PI send Shelly data over MQTT to the second in "Domoticz/in" topic.
The second do not create module automaticly (as if the shelly send data directly to the second PI)

Thx for your help,
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 just got a Shelly EM
In Shelly app, I see the Power Factor, isn't a value you have access through MQTT? (I do not see it populated...)
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 »

grenouilles wrote: Thursday 19 November 2020 19:42 Hi,

I have two PI 3B with Domoticz, one with a ShellyEM.
I would like to transfert the Shelly data between PI.
I have MQTT + Node-Red to the 2 PI.
The first PI send Shelly data over MQTT to the second in "Domoticz/in" topic.
The second do not create module automaticly (as if the shelly send data directly to the second PI)

Thx for your help,
Sorry i do not understand what do you want to achieve. Shellies do not use Domoticz/in topic, neither this plugin.
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: Monday 30 November 2020 18:26 I just got a Shelly EM
In Shelly app, I see the Power Factor, isn't a value you have access through MQTT? (I do not see it populated...)
Power factor is supported in this plugin since Jul 23 2020. In case you upgraded the plugin, did not use MQTT prefix and enabled power reading in plugin setting at hardware page...
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 missed the upgrade part but now I did it (only downloaded the new plugin.py as recommended) and still got nothing.
Except stop/start domoticz during the plugin update, do I have to do something?
I read well power, energy, voltage but do not see power factor
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: Friday 01 January 2021 23:21 I missed the upgrade part but now I did it (only downloaded the new plugin.py as recommended) and still got nothing.
Except stop/start domoticz during the plugin update, do I have to do something?
I read well power, energy, voltage but do not see power factor
Could you check incoming MQTT messages from EM?
It should be something like that: (this example is from EM3 API)
shellies/shellyem3-<deviceid>/emeter/<i>/pf

If your device did not send such an MQTT message, than power factor will never appear on Domoticz side, for sure.
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 »

Here is what Shelly EM deliver (using mosquitto_sub):
shellies/shellyem-C7F472/emeter/0/energy 564
shellies/shellyem-C7F472/emeter/0/returned_energy 0
shellies/shellyem-C7F472/emeter/1/energy 8
shellies/shellyem-C7F472/emeter/1/returned_energy 0
shellies/shellyem-C7F472/emeter/0/power 510.87
shellies/shellyem-C7F472/emeter/0/reactive_power -163.25
shellies/shellyem-C7F472/emeter/0/voltage 241.89
shellies/shellyem-C7F472/emeter/0/total 842430.4
shellies/shellyem-C7F472/emeter/0/total_returned 1887.5
shellies/shellyem-C7F472/emeter/1/power 8.54
shellies/shellyem-C7F472/emeter/1/reactive_power 7.32
shellies/shellyem-C7F472/emeter/1/voltage 241.89
shellies/shellyem-C7F472/emeter/1/total 439115.3
shellies/shellyem-C7F472/emeter/1/total_returned 0.0
So seems, it has to be computed as the reactive power is available
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 have a problem with Shelly duo RGB.
I can get it into domoticz but then if I want to turn it on, it doesn't work. If I turn it on thanks to shelly localwebserver, the status is updated in Domoticz, but then I cannot turn it off in domoticz.
If the light is on, I can change the color in domoticz.
So color changing works but not on/off... I guess I miss something.
2021-01-02 16_52_49-Window.png
2021-01-02 16_52_49-Window.png (118.35 KiB) Viewed 1846 times
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...
EDIT2: I cannot find a reason that sometimes it works, sometimes not
Last edited by darrepac on Sunday 03 January 2021 17:26, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest