Python Plugin: Shelly MQTT

Python and python framework

Moderator: leecollings

nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

Ok i will explain:

1.) if position is closed it means it is 100%

now i set position to example 69%- relay is triggered and shutter moves

than i set position to 30 % shutter moves. Then i set slider to 100 %-shutter moves to 100%.

If i set position to 1% shutter opens to 1 %.

If i set position to 0%- it means open- relay is not triggerd and the shutter stays closed.

EDIT:
i think command for 0% is wrong. mqtt
if state 0% is triggered from shelly web domoticz shows
right value 0% and status closed

U
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 »

nabru99 wrote: Wednesday 02 January 2019 8:20 EDIT:
i think command for 0% is wrong. mqtt
if state 0% is triggered from shelly web domoticz shows
right value 0% and status closed
I see. Maybe i can bypass it somehow. If Command Set Level 0% arrives from Domoticz GUI, than the plugin can send:

Code: Select all

shellies/shellyswitch-<deviceid>/roller/0/command/pos
with payload: 0
then instantly sending

Code: Select all

shellies/shellyswitch-<deviceid>/roller/0/command
with payload: open
This way the opening will be full i think.. could you try this mqtt messages manually before i implement this behaviour into the plugin?
(0% means that blinder is fully opened?)
Or maybe i simply change incoming 0 to outgoing 1 percent in the mqtt payload. Ugly method. :)
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

0% is fully opened
100% is fully closed

this can be changed - someone is using 100% for opened someone for closed.

100% command/slider is ok- it works open or close

0% command/slider IS NOT working open or close

ugly method i think is not ok- it will not show opened/closed

SET POSITION 100 %
2019-01-02 18:19:25.527 (Shelly) shellies/shellyswitch-134D85/roller/0/command/pos Set Level 100
2019-01-02 18:19:25.527 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command/pos (100)
2019-01-02 18:19:25.578 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command/pos 100
2019-01-02 18:19:25.779 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 open
2019-01-02 18:19:25.893 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 14.55
2019-01-02 18:19:26.016 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 103.39

SET POSITION 1%

2019-01-02 18:21:05.217 (Shelly) shellies/shellyswitch-134D85/roller/0/command/pos Set Level 1
2019-01-02 18:21:05.217 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command/pos (1)
2019-01-02 18:21:05.267 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command/pos 1
2019-01-02 18:21:05.468 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 close
2019-01-02 18:21:05.633 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 24.72
2019-01-02 18:21:05.694 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 119.11

SET POSITION 0%
NO MQTT MSG

how can i test?
Last edited by nabru99 on Wednesday 02 January 2019 18: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 »

nabru99 wrote: Wednesday 02 January 2019 17:46 SET POSITION 0%
NO MQTT MSG

how can i test?
Now i think i finally understood it: Blinds percentage from Domoticz will never send a 0% with Set Level.. it's sending an Off command instead. :)
I am playing a little with this device type, and tried again... i hope that the open and close commands are not swapped.
Updated on github.
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

lwolf wrote: Wednesday 02 January 2019 20:30
nabru99 wrote: Wednesday 02 January 2019 17:46 SET POSITION 0%
NO MQTT MSG

how can i test?
Now i think i finally understood it: Blinds percentage from Domoticz will never send a 0% with Set Level.. it's sending an Off command instead. :)
I am playing a little with this device type, and tried again... i hope that the open and close commands are not swapped.
Updated on github.
NOW 0 IS WORKING :D :D :D :D

yes command are swapped :lol:

Image

In this picture blind is closed and status is correct. CLOSED.

If OPEN in pressed now means OFF- should be ON
If CLOSE in pressed now means ON-should be OFF

U
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 »

nabru99 wrote: Wednesday 02 January 2019 21:20 NOW 0 IS WORKING :D :D :D :D

yes command are swapped :lol:

Image

In this picture blind is closed and status is correct. CLOSED.

If OPEN in pressed now means OFF- should be ON
If CLOSE in pressed now means ON-should be OFF

U
Finally, some progress. :)
I had a bad feeling about commands based on your test results, but do not quite understand why it is working reversely as the venetian blind... Updated on github.
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

CLOSED -command is working
2019-01-03 07:13:04.515 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command (open)
2019-01-03 07:13:04.566 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command open
2019-01-03 07:13:04.767 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 open
2019-01-03 07:13:04.886 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 26.02
2019-01-03 07:13:04.999 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 105.99
2019-01-03 07:13:07.065 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 71.78
2019-01-03 07:13:07.128 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/pos 100
2019-01-03 07:13:07.144 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 1.38
2019-01-03 07:13:07.160 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 stop
2019-01-03 07:13:07.373 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 0.0

OPEN- is not working- MQTT WRONG blind not opened
019-01-03 07:15:18.704 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command/pos (100) it should be command (close)
2019-01-03 07:15:18.755 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command/pos 100

SLIDER 0-100% fully functional.

U
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 »

nabru99 wrote: Thursday 03 January 2019 6:21 OPEN- is not working- MQTT WRONG blind not opened
019-01-03 07:15:18.704 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command/pos (100) it should be command (close)
2019-01-03 07:15:18.755 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command/pos 100
Please set shelly plugin to Verbose debugging mode for a while, and describe the Command and Level(?) when issuing the Open command.

With Domoticz v4.9701 i've got the following results with Verbose debugging:

1. Venetian Blind - "Open Blinds"
2019-01-03 20:15:05.672 (shelly) Command: Off (0) Color:
2019-01-03 20:15:05.672 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command (open)

2. Venetian Blind - "Stop Blinds"
2019-01-03 20:16:34.532 (shelly) Command: Stop (0) Color:
2019-01-03 20:16:34.532 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command (stop)

3. Venetian Blind - "Close Blinds"
2019-01-03 20:17:15.351 (shelly) Command: On (0) Color:
2019-01-03 20:17:15.351 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command (close)

4. Percentage Blind - "Open Blinds" (inverted??)
2019-01-03 20:18:22.085 (shelly) Command: Off (50) Color:
2019-01-03 20:18:22.085 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command (close)

5. Percentage Blind - "Close Blinds" (inverted??)
2019-01-03 20:19:04.968 (shelly) Command: On (50) Color:
2019-01-03 20:19:04.968 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command (open)

6. Percentage Blind - "0%"
2019-01-03 20:19:39.218 (shelly) Command: Off (0) Color:
2019-01-03 20:19:39.218 (shelly) shellies/shellyswitch-32BF87/roller/0/command/pos Off 0
2019-01-03 20:19:39.218 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command/pos (0)

7. Percentage Blind - "100%"
2019-01-03 20:20:30.686 (shelly) Command: Set Level (100) Color:
2019-01-03 20:20:30.686 (shelly) shellies/shellyswitch-32BF87/roller/0/command/pos Set Level 100
2019-01-03 20:20:30.686 (shelly) MqttClient::Publish shellies/shellyswitch-32BF87/roller/0/command/pos (100)
Attachments
Testing Shelly Blind devices
Testing Shelly Blind devices
shelly_sw.png (41.65 KiB) Viewed 3948 times
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

DOMOTICZ version 4.9700 RPI

Blind is CLOSED
Image
Settings SHELLY:
Image

Status DOMOTICZ:
Image

TEST:
Image

1.)OPEN --NOT WORKING
2019-01-04 07:42:12.232 (Shelly) shellies/shellyswitch-134D85/roller/0/command/pos Off 100
2019-01-04 07:42:12.232 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command/pos (100)
2019-01-04 07:42:12.283 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command/pos 100

2.) CLOSE WORKING
2019-01-04 07:44:01.863 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command (open)
2019-01-04 07:44:01.914 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command open
2019-01-04 07:44:02.115 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 open
2019-01-04 07:44:02.230 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 9.98
2019-01-04 07:44:02.344 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 107.19

3.)SLIDER WORKING

2019-01-04 07:45:27.046 (Shelly) shellies/shellyswitch-134D85/roller/0/command/pos Set Level 85
2019-01-04 07:45:27.046 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command/pos (85)
2019-01-04 07:45:27.097 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command/pos 85
2019-01-04 07:45:27.298 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 close
2019-01-04 07:45:27.412 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 11.49
2019-01-04 07:45:27.525 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 123.79
2019-01-04 07:45:29.841 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 stop
2019-01-04 07:45:29.905 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/pos 85
2019-01-04 07:45:29.970 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 100.21
2019-01-04 07:45:30.078 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 0.0
2019-01-04 07:45:40.704 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 1.02
2019-01-04 07:45:40.818 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 0.0


4.)VENETIAN OPEN WORKING BUT INVERTED

2019-01-04 07:46:49.163 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command (open)
2019-01-04 07:46:49.214 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command open
2019-01-04 07:46:49.415 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 open
2019-01-04 07:46:49.580 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 21.37
2019-01-04 07:46:49.642 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 105.51
2019-01-04 07:46:52.060 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 97.82
2019-01-04 07:46:52.123 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/pos 100
2019-01-04 07:46:52.138 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 1.36
2019-01-04 07:46:52.153 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 stop
2019-01-04 07:46:52.367 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 0.0

5.) VENETIAN STOP WORKING
2019-01-04 07:48:27.213 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command (stop)
2019-01-04 07:48:27.264 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command stop
2019-01-04 07:48:27.264 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/pos 29
2019-01-04 07:48:27.280 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 stop
2019-01-04 07:48:27.448 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 35.4
2019-01-04 07:48:27.510 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 0.0


6.) VENETIAN CLOSE WORKING BUT INVERTED

2019-01-04 07:48:14.751 (Shelly) MqttClient::Publish shellies/shellyswitch-134D85/roller/0/command (close)
2019-01-04 07:48:14.753 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0/command close
2019-01-04 07:48:15.004 (Shelly) MQTT message: shellies/shellyswitch-134D85/roller/0 close
2019-01-04 07:48:15.220 (Shelly) MQTT message: shellies/shellyswitch-134D85/relay/power 119.33




Only command for OPEN is wrong in this case when Blinds percentage is used.
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 »

nabru99 wrote: Friday 04 January 2019 8:18 Only command for OPEN is wrong in this case when Blinds percentage is used.
I see, posted code updates to github.
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

lwolf wrote: Friday 04 January 2019 20:13
nabru99 wrote: Friday 04 January 2019 8:18 Only command for OPEN is wrong in this case when Blinds percentage is used.
I see, posted code updates to github.
ALL OK -tested-working

:D :D
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

is it possible to measure power usage as in tasmota with mqtt.

shelly is recognized as usage,electric
sonoff with tasmota fw as general,kwh

diffeence is in logging and data.

u
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 »

nabru99 wrote: Monday 07 January 2019 16:28 is it possible to measure power usage as in tasmota with mqtt.

shelly is recognized as usage,electric
sonoff with tasmota fw as general,kwh

diffeence is in logging and data.
I can modify the device type as you wish.
Shelly reports two values :
1. shellies/shellyswitch-<deviceid>/relay/power reports instantaneous power consumption rate in Watts
- I saw that "Usage" has a unit of Watt so it was a logical decision to add a Usage device.. what is the benefit of the "General" device type?
2. shellies/shellyswitch-<deviceid>/relay/energy reports amount of energy consumed in [10 * Wh]
- plugin creates a device with TypeName="kWh" so i do not see any problem. You can see yourself at https://github.com/enesbcs/Shelly_MQTT/ ... /plugin.py in line 179.
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

Hello,

this is difference:

you can leave that both devices are created..

GENERAL TASMOTA ______________________________ ______________ SHELLY2
Image Image

GENERAL TASMOTA:
Image

SHELLY2:

Image
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 »

nabru99 wrote: Monday 07 January 2019 19:03 Hello,

this is difference:

you can leave that both devices are created..
Interesting. But i have no idea, how to solve it.
https://github.com/enesbcs/Shelly_MQTT/issues/2
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

Image
Tasmota:
04:57:29 MQT: domoticz/in = {"idx":115,"nvalue":0,"svalue":"233;1144498.4","Battery":88,"RSSI":9}
04:57:29 MQT: tele/sonoff_RACK/SENSOR = {"Time":"2019-01-08T04:57:29","ENERGY":{"TotalStartTime":"2018-12-23T06:31:08","Total":1144.498,"Yesterday":5.811,"Today":1.214,"Period":4,"Power":233,"ApparentPower":259,"ReactivePower":112,"Factor":0.90,"Voltage":220,"Current":1.174}}
Domoticz:
2019-01-08 05:02:29.396 MQTT: Topic: domoticz/in, Message: {"idx":115,"nvalue":0,"svalue":"238;1144518.7","Battery":88,"RSSI":9}
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 »

nabru99 wrote: Tuesday 08 January 2019 5:04 Domoticz:
2019-01-08 05:02:29.396 MQTT: Topic: domoticz/in, Message: {"idx":115,"nvalue":0,"svalue":"238;1144518.7","Battery":88,"RSSI":9}
idx:115 is what kind of Device in Domoticz?
nabru99
Posts: 16
Joined: Monday 06 November 2017 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Shelly MQTT

Post by nabru99 »

i noticed that value is recived from device:

Image
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 »

Hi, @Iwolf I'm new to MQTT and how to set it up.

In point 4 you say "Set your MQTT server address and port to plugin settings" how do I know what that is, Localhost? port: 1883?
Thx/Leby
/lennart
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: Sunday 20 January 2019 11:13 In point 4 you say "Set your MQTT server address and port to plugin settings" how do I know what that is, Localhost? port: 1883?
If you do not know your MQTT server address, then you do not have an MQTT server, so install one, for example mosquitto. Default port is 1883, yes, after installation.
http://mosquitto.org/blog/2013/01/mosqu ... epository/
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest