[NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Moderator: leecollings

hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

[NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

Update 29-05-2020: Go to post 8, for the working flow. If only using domoticz/tasmota controle, no switch input on device

The flow on 29-05-2020 doesn't work when you use switch input on the device.

=================================================================================================

The Original post, where the thread started with;

I got very stuck with a shelly 2.5, which is flashed with tasmota en setup as shutter device.
It works on the webpage of the device. But can't control it by domoticz.

The tasmota has a domoticz setup page. But this doesn't work for the shutter.
When i use it for the shutter, the shutter closes and after that immediatly it opens.

Now i wanted to try it with node-red. I thoughed i found a good instruction how to use it.
Installed node-red and imported the flow. But got an error. Found out that the response of a JSON was not complete.
Changed it to 1 device which state is asked, but than other errors popped-up
But how to fix i don't know.

Therefor i googled for idea's how to start getting knowledge of node-red. But it is a pain in the ***
I can't find good examples which works with the basic of domoticz/out mqtt payload.
Found enough info, but i think it is to much info that i don't know where to start.

I am hoping somebody here knows how Node-red works and can help me.
It isn't that i am searching for a finished flow (but that wouldn't be a problem :lol: ), but to get me on the way to a solution.

What do i like to make:
- Shelly 2.5 puts it's state to mqtt. When controlled the state looks like this, and i want to update a domoticz dummy device with the position info

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[54] 
 "{"Shutter1":{"Position":64,"Direction":0,"Target":64}}"
- When domoticz slider is changed, i want to that to position of the shelly is moved to the svalue of the dummy

Code: Select all

domoticz/out : msg.payload : string[272]
"{↵   "Battery" : 255,↵   "RSSI" : 12,↵   "description" : "",↵   "dtype" : "Light/Switch",↵   "id" : "0001426C",↵   "idx" : 540,↵   "name" : "Shelly-Aukje",↵   "nvalue" : 2,↵   "stype" : "Switch",↵   "svalue1" : "58",↵   "switchType" : "Blinds Percentage",↵   "unit" : 1↵}↵"
Can somebody please help me, or give me some links where usefull information for this question can be found?
Last edited by hoeby on Saturday 30 May 2020 10:15, edited 3 times in total.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by FireWizard »

Hi,

@hoeby

Sure we can try.

I assume, that the data is published on a local MQTT server, which is installed on the same hardware as Node Red and Domoticz.
If not, you have to configure the MQTT node to match your IP address/Port and, if used, username/password.

Further I assume that the data is published under the topic: stat/DZ_SH_A/RESULT
If not, you have to change it.

In parallel, I used an "Inject" node, to be able to test it
If you change the topic in the MQTT node, you have to do that in the "Inject" node as well.

Questions?
What is the type of sensor you want to use?
Do you want only a virtual sensor for "Position" or also for "Direction" and "Target".
What is (are) the IDX of the sensor, you want to use (540?)

Can you try this flow and publish the contents of the "Debug" node.

Try this flow:

Code: Select all

[{"id":"d3418ad3.a2e88","type":"mqtt in","z":"e89de1ec.ee866","name":"Shutter In","topic":"stat/DZ_SH_A/RESULT","qos":"2","datatype":"json","broker":"5e04d49d.064d9c","x":220,"y":660,"wires":[["42726978.110d28"]]},{"id":"42726978.110d28","type":"debug","z":"e89de1ec.ee866","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":660,"wires":[]},{"id":"81405029.629ce8","type":"inject","z":"e89de1ec.ee866","name":"Inject Shutter","topic":"stat/DZ_SH_A/RESULT","payload":"{\"Shutter1\":{\"Position\":64,\"Direction\":0,\"Target\":64}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":720,"wires":[["42726978.110d28"]]},{"id":"5e04d49d.064d9c","type":"mqtt-broker","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":15,"cleansession":true,"birthQos":"0","willQos":"0"}]
Let me know.

Regards
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by hoeby »

Thanks for that quick support
The idea is that i can control shutters by domoticz. But also with the manual controll switch near the shutters.
Communication needs to be 2-ways/

Tested it an this is the debug, when i controll the tasmota in its webbrowser

Code: Select all

28-5-2020 22:11:06node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
{ POWER2: "ON" }
28-5-2020 22:11:07node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
{ ShutterPosition1: 54 }
28-5-2020 22:11:07node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
{ Shutter1: object }
28-5-2020 22:11:07node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
{ Shutter1: object }
28-5-2020 22:11:08node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
{ POWER2: "OFF" }
28-5-2020 22:11:08node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
{ Shutter1: object }
This is the response when it trigger the inject

Code: Select all

28-5-2020 22:12:22node: a52f3297.8bc6e
stat/DZ_SH_A/RESULT : msg.payload : Object
object
Shutter1: object
Position: 64

I found a shelly relay json for nodered online, of course after i opened this thread.
I modified the script. I got it working. To move the slider in domoticz and it moves the shelly 2.5 tasmota shutter to that position.
Getting the shelly 2.5 tasmota shutter to move the domoticz slider, that doesn't work. Need to find out how to get the position payload out of the shelly payload. Is it wise to go on with this, or would you say: please stop with it?

Code: Select all

[{"id":"638a85e3.ce91cc","type":"tab","label":"shelly generic","disabled":false,"info":""},{"id":"8bb85714.bb4258","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":290,"y":180,"wires":[["90342cf9.e9727"]]},{"id":"bc5348ac.393518","type":"mqtt in","z":"638a85e3.ce91cc","name":"","topic":"domoticz/out","qos":"2","broker":"6211af79.02186","x":130,"y":180,"wires":[["8bb85714.bb4258"]]},{"id":"9e8b8d53.2286d","type":"mqtt in","z":"638a85e3.ce91cc","name":"shelly/out","topic":"stat/+/RESULT","qos":"2","datatype":"auto","broker":"6211af79.02186","x":120,"y":260,"wires":[["d33d0662.4180f8"]]},{"id":"720304a2.459d1c","type":"function","z":"638a85e3.ce91cc","name":"idx <-> shelly","func":"var idx_shelly_table = [\n    //[ domoticz idx, shelly name topic, relay ],   // syntax\n    [540, \"DZ_SH_A\", 0],    // shelly 2.5\n];\n\nif ( msg.src == 'shelly' ) {\n    var matches = msg.topic.match( /cmnd\\/(.*)\\/shutterposition\\/(\\d)/ );\n    if ( matches.length == 3 ) {\n        var shelly_id = matches[1];\n        var shelly_relay = parseInt( matches[2] );\n        \n        for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n            if ( idx_shelly_table[i][1] == shelly_id ) {\n                // convert to domoticz stuff\n                var val = msg.payload == \"on\" ? 1 : 0;\n                msg = {\n                    payload:\n                    {\n                        svalue: val,\n                        command: \"udevice\",\n                        idx: idx_shelly_table[i][0],\n                    }\n                }\n                \n                return [msg, null, null];\n            }\n        }\n        \n        // shelly not found in table\n        msg.shelly_id = shelly_id;\n        msg.relay = shelly_relay;\n        return [null, null, msg];\n    }\n}\n\nif ( msg.src == 'domoticz' ) {\n    for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n        if ( idx_shelly_table[i][0] == parseInt(msg.payload.idx) ) {\n                var aval = (msg.payload.svalue1);\n                msg.payload = aval;\n            //msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition/\" + idx_shelly_table[i][2] + \"/command\";\n            msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition\";\n            return [null, msg, null ];\n        }\n    }\n}\n\n// dismiss\nreturn [null, null, null];","outputs":3,"noerr":0,"x":676,"y":189,"wires":[["55333a53.9885d4"],["b20758ef.196b48"],[]]},{"id":"90342cf9.e9727","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'domoticz';\n\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":180,"wires":[["720304a2.459d1c"]]},{"id":"d33d0662.4180f8","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'shelly';\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":260,"wires":[["720304a2.459d1c"]]},{"id":"55333a53.9885d4","type":"mqtt out","z":"638a85e3.ce91cc","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"6211af79.02186","x":950,"y":100,"wires":[]},{"id":"b20758ef.196b48","type":"mqtt out","z":"638a85e3.ce91cc","name":"","topic":"","qos":"","retain":"","broker":"6211af79.02186","x":910,"y":240,"wires":[]},{"id":"8c42a907.02ed98","type":"debug","z":"638a85e3.ce91cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":655.3402862548828,"y":100.16667175292969,"wires":[]},{"id":"6211af79.02186","type":"mqtt-broker","z":"","name":"mqtt home","broker":"localhost","port":"1883","clientid":"node-red","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by FireWizard »

Hi,

@hoeby

My first idea was to publish first the data from the Shelly to Domoticz.
Therefore I created this small test in order to check the output from the Shelly.

I see it is more than only the position.
I see:
{ POWER2: "ON" }
{ ShutterPosition1: 54 }
{ Shutter1: object } ====> What is the contents of the object? Probably what has been shown in the previous picture I see it 2 times.
{ POWER2: "OFF" }

The response of the Inject is OK

What type of virtual sensor are you using?
I modified the script. I got it working. To move the slider in domoticz and it moves the shelly 2.5 tasmota shutter to that position.
So, that part is OK.

In the function node is a small error. You have to correct that.

But it is OK to continue.

Regards
Last edited by FireWizard on Sunday 12 July 2020 18:21, edited 1 time in total.
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by hoeby »

FireWizard wrote: Thursday 28 May 2020 22:45 { Shutter1: object } ====> What is the contents of the object? Probably wat has been shown in the previous picture I see it 2 times.
Sorry i don't know (yet). Need to search for it.
Will have a look later this day , if i can find it
FireWizard wrote: Thursday 28 May 2020 22:45What type of virtual sensor are you using?
Using a "blind percentage" virtual switch
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by hoeby »

I modified the flow. The error is gone, but it does not work.

The modified flow

Code: Select all

[{"id":"720304a2.459d1c","type":"function","z":"638a85e3.ce91cc","name":"idx <-> shelly","func":"var idx_shelly_table = [\n    //[ domoticz idx, shelly name topic, relay ],   // syntax\n    [540, \"DZ_SH_A\", 0],    // shelly 2.5\n];\n\nif ( msg.src == 'shelly' ) {\n    var matches = msg.topic.match( /stat\\/(.*)\\/RESULT/ );\n    \n    if ( matches.length == 2 ) {\n        var shelly_id = matches[1];\n    \n        for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n            if ( idx_shelly_table[i][1] == shelly_id ) {\n                var val = (msg.payload.Shutterposition1)\n                msg = {\n                    payload:\n                    {\n                        \"command\": \"switchlight\", \n                        \"idx\": idx_shelly_table[i][0], \n                        \"switchcmd\": \"Set Level\", \n                        \"level\": val,\n                      \n                    }\n                }\n                \n                return [msg, null, null];\n            }\n        }\n        \n        // shelly not found in table\n        msg.shelly_id = shelly_id;\n        msg.relay = shelly_relay;\n        return [null, null, msg];\n    }\n}\n\nif ( msg.src == 'domoticz' ) {\n    for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n        if ( idx_shelly_table[i][0] == parseInt(msg.payload.idx) ) {\n                var aval = (msg.payload.svalue1);\n                if (aval == 0) {\n                    msg.payload = 100;\n                } \n                else if (aval == 100) { \n                    msg.payload = 0;\n                }\n                else msg.payload = aval;\n            //msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition/\" + idx_shelly_table[i][2] + \"/command\";\n            msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition\";\n            return [null, msg, null ];\n        }\n    }\n}\n\n// dismiss\nreturn [null, null, null];","outputs":3,"noerr":0,"x":676,"y":189,"wires":[[],["b20758ef.196b48"],[]]}]
Where i am stuck, is to get the value out from "ShutterPosition1"
When i move the slider on tasmota this is the payload.
I would love to get the value of "ShutterPosistion1: out of this payload and set it as variable val
But is between { and }, where i need to find a solution for

Code: Select all

29-5-2020 08:20:09node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[22]
"{"ShutterPosition1":6}"
As test i set the variable val to a fixed value (var val = 5 for example).
Then another issues popped up. And that is that domoticz and tasmota are getting in a loop.
Tasmota send an update to domoticz. The received value is updated in domoticz. But also send back to the tasmota. Tasmota updates is value (which is the same) and sends it back to domoticz. And so on and on and on. Untill i pull the power from tasmota.
Any tips of idea how to solve this loop?
I was thinking that i need to put the send payload in a memory and when receiving the same payload, than nothing to do.
Is that the way, or are there easier solutions?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by hoeby »

hoeby wrote: Friday 29 May 2020 7:07
FireWizard wrote: Thursday 28 May 2020 22:45 { Shutter1: object } ====> What is the contents of the object? Probably wat has been shown in the previous picture I see it 2 times.
Sorry i don't know (yet). Need to search for it.
Will have a look later this day , if i can find it
Done the test.
This is what is al putt in the debug of Node red when i do 1 movement in the tasmota browser

Code: Select all

29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[15]
"{"POWER1":"ON"}"
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[23]
"{"ShutterPosition1":56}"
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":29,"Direction":1,"Target":56}}"
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":33,"Direction":1,"Target":56}}"
29-5-2020 08:33:06node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":53,"Direction":1,"Target":56}}"
29-5-2020 08:33:06node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[16]
"{"POWER1":"OFF"}"
29-5-2020 08:33:06node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":56,"Direction":0,"Target":56}}"

Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Read Domoticz IDX shutter state and control Shelly 2.5 with tasmota, please help

Post by hoeby »

POST: 8


Got the flow working both ways. Maybe not how an experiance person will do.
For people wo are using it. It only tested for shelly 2.5 with tasmota firmware and setup as shutter.

Shelly --> Domoticz works
Domoticz --> Shelly works
Both options --> Works. It doesn't get in a loop.

How to setup:
- Check "Domoticz/in" if MQTT address and port are correct.
- Check "Domoticz/out" if MQTT address and port are correct.
- Check "Shelly/in" if MQTT address and port are correct
- Check "Shelly/out" if MQTT address and port are correct
- Open "idx <-> shelly" and add your IDX/shelly-tasmota topic name. (example: [540, "DZ_SH_A"], where 540=idx and DZ_SH_A=topic name), You could add Multi idx/topic devices in this list. Remember to separed them with the ,


The only thing with both options. When i change level in domoticz, the shelly moves to it but also sends it state. This state is then send 1 time to domoticz. After that the loop stops. It looks no problem, because when you move from 25% to 50%, then shelly will send that its state is 50%. But domoticz is already in that state.

The flow:

Code: Select all

[{"id":"638a85e3.ce91cc","type":"tab","label":"shelly generic","disabled":false,"info":""},{"id":"8bb85714.bb4258","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":326.2500305175781,"y":180,"wires":[["90342cf9.e9727"]]},{"id":"bc5348ac.393518","type":"mqtt in","z":"638a85e3.ce91cc","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"6211af79.02186","x":130,"y":180,"wires":[["8bb85714.bb4258"]]},{"id":"9e8b8d53.2286d","type":"mqtt in","z":"638a85e3.ce91cc","name":"shelly/out","topic":"stat/+/RESULT","qos":"2","datatype":"auto","broker":"6211af79.02186","x":120,"y":260,"wires":[["bff402bf.82d3b"]]},{"id":"720304a2.459d1c","type":"function","z":"638a85e3.ce91cc","name":"idx <-> shelly","func":"var idx_shelly_table = [\n    //[ domoticz idx, shelly name topic, relay ],   // syntax\n    [540, \"DZ_SH_A\"],    // shelly 2.5\n];\n\nif ( msg.src == 'shelly' ) {\n    var matches = msg.topic.match( /stat\\/(.*)\\/RESULT/ );\n    \n    if ( matches.length == 2 ) {\n        var shelly_id = matches[1];\n    \n        for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n            if ( idx_shelly_table[i][1] == shelly_id ) {\n                var val = (msg.payload)\n                msg = {\n                    payload:\n                    {\n                        \"command\": \"switchlight\", \n                        \"idx\": idx_shelly_table[i][0], \n                        \"switchcmd\": \"Set Level\", \n                        \"level\": val,\n                      \n                    }\n                }\n                \n                return [msg, null, null];\n            }\n        }\n        \n        // shelly not found in table\n        msg.shelly_id = shelly_id;\n        msg.relay = shelly_relay;\n        return [null, null, msg];\n    }\n}\n\nif ( msg.src == 'domoticz' ) {\n    for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n        if ( idx_shelly_table[i][0] == parseInt(msg.payload.idx) ) {\n                var aval = (msg.payload.svalue1);\n                if (aval == 0) {\n                    msg.payload = 100;\n                } \n                else if (aval == 100) { \n                    msg.payload = 0;\n                }\n                else msg.payload = aval;\n            //msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition/\" + idx_shelly_table[i][2] + \"/command\";\n            msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition\";\n            return [null, msg, null ];\n        }\n    }\n}\n\n// dismiss\nreturn [null, null, null];","outputs":3,"noerr":0,"x":1042.964111328125,"y":221.67853546142578,"wires":[["55333a53.9885d4"],["b20758ef.196b48"],[]]},{"id":"90342cf9.e9727","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'domoticz';\n\nreturn msg;","outputs":1,"noerr":0,"x":523.2142333984375,"y":180,"wires":[["46063ddb.177474"]]},{"id":"55333a53.9885d4","type":"mqtt out","z":"638a85e3.ce91cc","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"6211af79.02186","x":1284.1070556640625,"y":179.82140350341797,"wires":[]},{"id":"b20758ef.196b48","type":"mqtt out","z":"638a85e3.ce91cc","name":"Shelly/in","topic":"","qos":"","retain":"","broker":"6211af79.02186","x":1272.678466796875,"y":254.10712432861328,"wires":[]},{"id":"bff402bf.82d3b","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":246.19044494628906,"y":260,"wires":[["d02ec7a4.557f58"]]},{"id":"d02ec7a4.557f58","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'shelly';\nreturn msg;","outputs":1,"noerr":0,"x":372.857177734375,"y":259.20635986328125,"wires":[["e285f5f0.10d138"]]},{"id":"fd46034c.76e08","type":"debug","z":"638a85e3.ce91cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1045.297607421875,"y":289.6031494140625,"wires":[]},{"id":"e285f5f0.10d138","type":"split","z":"638a85e3.ce91cc","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":500.0001525878906,"y":259.8411865234375,"wires":[["6c1a59a9.b7dc18"]]},{"id":"6c1a59a9.b7dc18","type":"switch","z":"638a85e3.ce91cc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"101","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":615.873046875,"y":259.206298828125,"wires":[["6c63207d.043b1"]]},{"id":"6c63207d.043b1","type":"rbe","z":"638a85e3.ce91cc","name":"Anti-Loop-Shelly","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":765,"y":258.75,"wires":[["fd46034c.76e08","720304a2.459d1c"]]},{"id":"59c6f98c.f89b78","type":"debug","z":"638a85e3.ce91cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1041.25,"y":146.25001525878906,"wires":[]},{"id":"46063ddb.177474","type":"rbe","z":"638a85e3.ce91cc","name":"Anti-loop-Domoticz","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":756.2500610351562,"y":180,"wires":[["59c6f98c.f89b78","720304a2.459d1c"]]},{"id":"6211af79.02186","type":"mqtt-broker","z":"","name":"mqtt home","broker":"localhost","port":"1883","clientid":"node-red","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Working flow: Shelly 2.5 tasmota shutter <-> Domoticz

Post by FireWizard »

@hoeby

Hi,

I had just prepared something that published also from Domoticz, if you operate the slider, and I had also something that published to Domoticz.
It looks simpler than the function node you use, but as I'm still not sure how to communicate with the Shelly, I suggest, that, if you are satisfied, we leave it this way.

Regards
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Working flow: Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

Please post it. I still need to learn node-red. All information is welcome.

I just thoughed:
Mine works with browser control.
But need to connect the inputs of the shelly. And than look of iy still works.

Please share it.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Working flow: Shelly 2.5 tasmota shutter <-> Domoticz

Post by FireWizard »

@hoeby

I'm very sorry. I have just deleted those flows.
I had many tabs with flows for Shelly and Tasmota.

And I don't own any device, yet.
So cleaned it up.

But if you tell me what you want to see.
I can make something.

- Is it the action of the Domoticz switch/glider to Node Red?
- Is it the information of e.g. Shelly to Domoticz?

Regards
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Working flow: Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

The biggest problem for now, is how to get information out of the payload. For example the shutterposition1 from shelly.

That is why i used multi components in the flow, to get the value out of it
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

Back to the drawing board.
The flow works, but only when you use the webbrowser control of domoticz<->shelly (tasmota).
When you want to use the input switches on the devices, than it goes wrong.

What happens:
- when the input is actived, the mqtt is send to domoticz with its value.
- domoticz accepts and puts its state back to mqtt
- but then the shelly input is already changed because the input is still high. And it now get a mqtt with an other value than its own value. Relays are going crazy and the device doesn't know what to do.

Maybe it is a device setting, maybe it is the flow.
I don't know yet. Have to look in both, where to find the solution
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by FireWizard »

Hi,

@hoeby

What is the version of Domoticz you are using?

Regards
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

I am using 4.10717.
Updating is not possible, i am not running buster on my pi.

Could you have a look a this flow?
I made a switch in it. That when i receive an "ON" message from shelly tasmota device. The ON message i receive when a input or webbrowser is triggered. That it disables the input for device idx<->shelly.
All incomming domoticz mqtt messages can't reacht the idx<->shelly and therefor don't shoot mqtt messages to shelly tasmota

Code: Select all

[{"id":"638a85e3.ce91cc","type":"tab","label":"shelly generic","disabled":false,"info":""},{"id":"8bb85714.bb4258","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":440.25,"y":180,"wires":[["90342cf9.e9727"]]},{"id":"bc5348ac.393518","type":"mqtt in","z":"638a85e3.ce91cc","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"6211af79.02186","x":130,"y":180,"wires":[["234122dd.2cd7fe"]]},{"id":"9e8b8d53.2286d","type":"mqtt in","z":"638a85e3.ce91cc","name":"shelly/out","topic":"stat/+/RESULT","qos":"2","datatype":"auto","broker":"6211af79.02186","x":120,"y":260,"wires":[["bff402bf.82d3b"]]},{"id":"720304a2.459d1c","type":"function","z":"638a85e3.ce91cc","name":"idx <-> shelly","func":"var idx_shelly_table = [\n    //[ domoticz idx, shelly name topic, relay ],   // syntax\n    [540, \"DZ_SH_A\"],    // shelly 2.5\n];\n\nif ( msg.src == 'shelly' ) {\n    var matches = msg.topic.match( /stat\\/(.*)\\/RESULT/ );\n    \n    if ( matches.length == 2 ) {\n        var shelly_id = matches[1];\n    \n        for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n            if ( idx_shelly_table[i][1] == shelly_id ) {\n                var val = (msg.payload.Position)\n                msg = {\n                    payload:\n                    {\n                        \"command\": \"switchlight\", \n                        \"idx\": idx_shelly_table[i][0], \n                        \"switchcmd\": \"Set Level\", \n                        \"level\": val,\n                      \n                    }\n                }\n                \n                return [msg, null, null];\n            }\n        }\n        \n        // shelly not found in table\n        msg.shelly_id = shelly_id;\n        msg.relay = shelly_relay;\n        return [null, null, msg];\n    }\n}\n\nif ( msg.src == 'domoticz' ) {\n    for ( var i = 0; i < idx_shelly_table.length; i++ ) {\n        if ( idx_shelly_table[i][0] == parseInt(msg.payload.idx) ) {\n                var aval = (msg.payload.svalue1);\n                if (aval == 0) {\n                    msg.payload = 100;\n                } \n                else if (aval == 100) { \n                    msg.payload = 0;\n                }\n                else msg.payload = aval;\n            //msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition/\" + idx_shelly_table[i][2] + \"/command\";\n            msg.topic = \"cmnd/\" + idx_shelly_table[i][1] + \"/shutterposition\";\n            return [null, msg, null ];\n        }\n    }\n}\n\n// dismiss\nreturn [null, null, null];","outputs":3,"noerr":0,"x":1169.964111328125,"y":226.67852783203125,"wires":[["55333a53.9885d4"],["b71d3154.ee4","b20758ef.196b48"],[]]},{"id":"90342cf9.e9727","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'domoticz';\n\nreturn msg;","outputs":1,"noerr":0,"x":577.2142333984375,"y":180,"wires":[["46063ddb.177474"]]},{"id":"55333a53.9885d4","type":"mqtt out","z":"638a85e3.ce91cc","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"6211af79.02186","x":1378.1070556640625,"y":198.8214111328125,"wires":[]},{"id":"b20758ef.196b48","type":"mqtt out","z":"638a85e3.ce91cc","name":"Shelly/in","topic":"","qos":"","retain":"","broker":"6211af79.02186","x":1368.678466796875,"y":247.10711669921875,"wires":[]},{"id":"bff402bf.82d3b","type":"json","z":"638a85e3.ce91cc","name":"","property":"payload","action":"","pretty":false,"x":246.19044494628906,"y":260,"wires":[["d02ec7a4.557f58"]]},{"id":"d02ec7a4.557f58","type":"function","z":"638a85e3.ce91cc","name":"add src","func":"msg.src = 'shelly';\nreturn msg;","outputs":1,"noerr":0,"x":372.857177734375,"y":259.20635986328125,"wires":[["e285f5f0.10d138"]]},{"id":"e285f5f0.10d138","type":"split","z":"638a85e3.ce91cc","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":500.0001525878906,"y":259.8411865234375,"wires":[["6c1a59a9.b7dc18","d0bcf23f.236a6"]]},{"id":"6c1a59a9.b7dc18","type":"switch","z":"638a85e3.ce91cc","name":"","property":"payload.Position","propertyType":"msg","rules":[{"t":"lte","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":671.873046875,"y":260.206298828125,"wires":[["6c63207d.043b1"]]},{"id":"6c63207d.043b1","type":"rbe","z":"638a85e3.ce91cc","name":"Anti-Loop-Shelly","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":884,"y":259.75,"wires":[["720304a2.459d1c"]]},{"id":"46063ddb.177474","type":"rbe","z":"638a85e3.ce91cc","name":"Anti-loop-Domoticz","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":751.2500610351562,"y":180,"wires":[["6345c362.fb967c"]]},{"id":"b3c05808.3f08e8","type":"switch","z":"638a85e3.ce91cc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":913,"y":306,"wires":[["f614c20f.860ae"],["23f29e47.70d872"]]},{"id":"d80da56e.637dc8","type":"debug","z":"638a85e3.ce91cc","name":"DZ_out_Payload_disabled","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1225,"y":118,"wires":[]},{"id":"23f29e47.70d872","type":"change","z":"638a85e3.ce91cc","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"relayOn","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1400,"y":385,"wires":[[]]},{"id":"6345c362.fb967c","type":"switch","z":"638a85e3.ce91cc","name":"","property":"relayOn","propertyType":"flow","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":915,"y":180,"wires":[["d80da56e.637dc8"],["720304a2.459d1c","32952f63.42b8a"]]},{"id":"f614c20f.860ae","type":"delay","z":"638a85e3.ce91cc","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1128,"y":304,"wires":[["23f29e47.70d872","36147959.ad32d6"]]},{"id":"d0bcf23f.236a6","type":"change","z":"638a85e3.ce91cc","name":"Convert state to boolean","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":733,"y":306,"wires":[["b3c05808.3f08e8"]]},{"id":"b71d3154.ee4","type":"debug","z":"638a85e3.ce91cc","name":"SH_Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1380,"y":298,"wires":[]},{"id":"32952f63.42b8a","type":"debug","z":"638a85e3.ce91cc","name":"DZ_out_Payload-Enabled","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1214,"y":161,"wires":[]},{"id":"5c51156b.ca8c5c","type":"inject","z":"638a85e3.ce91cc","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":912,"y":394,"wires":[["23f29e47.70d872"]]},{"id":"b3da728e.b1e7b","type":"inject","z":"638a85e3.ce91cc","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":913,"y":355,"wires":[["23f29e47.70d872"]]},{"id":"234122dd.2cd7fe","type":"delay","z":"638a85e3.ce91cc","name":"","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":296,"y":180,"wires":[["8bb85714.bb4258"]]},{"id":"36147959.ad32d6","type":"debug","z":"638a85e3.ce91cc","name":"State","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1360,"y":342,"wires":[]},{"id":"6211af79.02186","type":"mqtt-broker","z":"","name":"mqtt home","broker":"localhost","port":"1883","clientid":"node-red","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Only thing i don't get. If i click on "close" for the device. It send value 100
If i then again click on "close" for the same device. Then is send value 0
Looks more as a toggle function. But because i am at an old version, it could be that the new stable works different.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by FireWizard »

@hoeby

Hi,

1.
The fact that a published message domoticz/in will be returned to domoticz/out is caused by your Domoticz version.

From version V4.11763, the MQTT behavior has been changed to avoid endless loops. As you are on 4.10717, you still has that problem.
However many users use this loop back functionality and therefore the possibility has returned , as an option, in v4.11921.
You can follow the discussion at: https://www.domoticz.com/forum/viewtopi ... hilit=mqtt and at:
https://github.com/domoticz/domoticz/issues/3863

So consider to upgrade to Raspian Buster, now called Raspberry Pi OS and to use the latest Domoticz 2020.2.

2.
I looked to your flow, but I think it is very complex, related to what you try to achieve.

If I'm correct.

1. You want to send the Shutter1 position, which is a number between 0 and 100 and represents how many percent the shutter is closed to Domoticz.
2. From Domoticz you want to send the slider position, which represents how many percent the shutter is closed back to the Shelly?

Have you flashed the Shelly with Tasmota?

I suggest that you create (probably you have already done so) a virtual switch and configure as Switch Type: Blind Percentage.

Test the following simple flow:

Code: Select all

[{"id":"43365171.f71f78","type":"mqtt in","z":"56f1881a.2a6b9","name":"Shelly MQTT in","topic":"stat/DZ_SH_A/RESULT","qos":"2","datatype":"json","broker":"c2d9657a.d81bf8","x":180,"y":160,"wires":[["1b0f86a2.453061"]]},{"id":"eb91d261.f985a8","type":"inject","z":"56f1881a.2a6b9","name":"","topic":"stat/DZ_SH_A/RESULT","payload":"{\"ShutterPosition1\": 34}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":100,"wires":[["1b0f86a2.453061","b5bbfdaa.73ddc8"]]},{"id":"1b0f86a2.453061","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":160,"wires":[]},{"id":"b5bbfdaa.73ddc8","type":"function","z":"56f1881a.2a6b9","name":"","func":"msg.payload = {\"command\":\"switchlight\",\"idx\":18,\"switchcmd\":\"Set Level\",\"level\":msg.payload.ShutterPosition1}\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":100,"wires":[["b1b8faa8.f974b8","930034c0.0bb858"]]},{"id":"b1b8faa8.f974b8","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":60,"wires":[]},{"id":"930034c0.0bb858","type":"mqtt out","z":"56f1881a.2a6b9","name":"Domoticz In","topic":"domoticz/in","qos":"","retain":"","broker":"c2d9657a.d81bf8","x":590,"y":100,"wires":[]},{"id":"c2d9657a.d81bf8","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
In the Inject node you can change the shutter position.
In the function node you have to change the IDX (currently 18) to the IDX of your virtual switch.
If you activate the Inject node, you should see that in Domoticz.

Can you check the output of the Shelly MQTT in node and compare it with what you get from the Inject node.

Regards
Last edited by FireWizard on Sunday 31 May 2020 10:38, edited 2 times in total.
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

Thanks for your answer.

For point 1.
You are right. I need to update.
I prefer to always have the latest stable running. But that was not not possible because the older OS is not supported.
I want to do a fresh install and not a update from stretch to buster. This takes more time, because i am not only running domoticz on the pi.
I had 2 projects which needs to be done. This shutter device is the last project. When finished i will start on the fresh install die domoticz.

For point 2
Your correct about the info which i want between the 2 devices.

The shelly is flashed with tasmota and setup as shutter device.
The virtual switch i made, this was my starting point for domoticz.

Later this day i will import your flow and test it.
Thanks for your effort
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

I looked at the flow.

Changed the ShutterPosition1 to Shutter1.Position.
Because ShutterPosition is a command and not the actual value. But that is a small change and has nothing to do with the working.

The flow is only from Shelly to domoticz.
Not the other way around.
I would love to know how you solve that and not getting the loop with mqtt messages.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
FireWizard
Posts: 1771
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by FireWizard »

Hi,

@hoeby

You wrote:
The flow is only from Shelly to domoticz.
Not the other way around.
I would love to know how you solve that and not getting the loop with mqtt messages.
I suggest we do it in 3 steps.

Step 1: Make a working flow (without errors) from the Shelly MQTT In to Domoticz, so that it functions, according what you want/need.
Step 2: Make a working flow (without errors) from Domoticz In To the Shelly, so that it functions, according what you want/need.
Step 3: Block the loop

For step 1 it is important that we know exactly what is published by the Shelly, if you activate in on the hardware itself or in the web interface.

You published the following data:
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[15]
"{"POWER1":"ON"}"
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[23]
"{"ShutterPosition1":56}"
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":29,"Direction":1,"Target":56}}"
29-5-2020 08:33:05node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":33,"Direction":1,"Target":56}}"
29-5-2020 08:33:06node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":53,"Direction":1,"Target":56}}"
29-5-2020 08:33:06node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[16]
"{"POWER1":"OFF"}"
29-5-2020 08:33:06node: 8c42a907.02ed98
stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":56,"Direction":0,"Target":56}}"
I see 3 different publications:

1. {"POWER1":"ON"}/{"POWER1":"OFF"}
2. {"ShutterPosition1":56}
3. {"Shutter1":{"Position":53,"Direction":1,"Target":56}}

Questions:

1. Is this all what is published on topic stat/DZ_SH_A/RESULT?
2. What do you want to do with {"POWER1":"ON"}/{"POWER1":"OFF"} ==> Where is that information coming from?
3. What do you want to do with {"ShutterPosition1":56} ==> Where is that information coming from?
4. I now made the simulation exactly according to {"Shutter1":{"Position":53,"Direction":1,"Target":56}} ==> Is it correct?
Is this the information , we get from the Shelly? If not , what information do we get?
If it is correct, what do you want to do with "Direction" and "Target"?

I saw in another publication that you use as topic stat/+/RESULT instead of stat/DZ_SH_A/RESULT.
As this is a wildcard, how many devices do you have?

I created a new flow, based on {"Shutter1":{"Position":53,"Direction":1,"Target":56}}

Code: Select all

[{"id":"43365171.f71f78","type":"mqtt in","z":"56f1881a.2a6b9","name":"Shelly Out - MQTT In","topic":"stat/DZ_SH_A/RESULT","qos":"2","datatype":"json","broker":"c2d9657a.d81bf8","x":200,"y":160,"wires":[["1b0f86a2.453061"]]},{"id":"eb91d261.f985a8","type":"inject","z":"56f1881a.2a6b9","name":"Simulate Shelly Out","topic":"stat/DZ_SH_A/RESULT","payload":"{\"Shutter1\":{\"Position\":29,\"Direction\":1,\"Target\":56}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":100,"wires":[["1b0f86a2.453061","b5bbfdaa.73ddc8"]]},{"id":"1b0f86a2.453061","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":160,"wires":[]},{"id":"b5bbfdaa.73ddc8","type":"function","z":"56f1881a.2a6b9","name":"Prrepare To Domoticz","func":"msg.payload = {\"command\":\"switchlight\",\"idx\":18,\"switchcmd\":\"Set Level\",\"level\":msg.payload.Shutter1.Position}\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":100,"wires":[["b1b8faa8.f974b8","930034c0.0bb858"]]},{"id":"b1b8faa8.f974b8","type":"debug","z":"56f1881a.2a6b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":60,"wires":[]},{"id":"930034c0.0bb858","type":"mqtt out","z":"56f1881a.2a6b9","name":"Domoticz In","topic":"domoticz/in","qos":"","retain":"","broker":"c2d9657a.d81bf8","x":690,"y":100,"wires":[]},{"id":"c2d9657a.d81bf8","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Regards
hoeby
Posts: 530
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: [NodeRed], Shelly 2.5 tasmota shutter <-> Domoticz

Post by hoeby »

I did controll the shelly. And for every command i did copy the debug and put at every message what it is doing.

Question 1, 2 and 3 are answered in the information below

Question 4: i will check

I use the wild-card because i will finally have 4 devices.

When giving command from the tasmota webcontrole, it gives Multi messages in the debug.
This is measured at the output of Shelly/Out. No converstion is done to the messages

Relay 2 is put "ON"

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[15]
"{"POWER2":"ON"}"
The command given, that Shutter has to go to position 19

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[23]
"{"ShutterPosition1":19}"
The actual values of settings of Shutter1
Position = current position
Direction = this tasmota uses to discripe if shutter is going Up or Down
Target = Where needs the shutter need to move to

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[55]
"{"Shutter1":{"Position":100,"Direction":-1,"Target":19}}"
Then a lot of messages, where the current position is update every X time, because it is moving
For example, when you move 10 % it could be 2 messages. But when moving 80% than it could be 18 message.
It is not the every fixed value %, there is a message send.

The target is reached. Relay 2 is put "OFF"

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[16]
"{"POWER2":"OFF"}"

The last state. Current position, direction 0 = off, target is the same as position, because target is reached.

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":19,"Direction":0,"Target":19}}"
When controlling the tasmota with wall-switch. Activating an input
Activating Relay 1

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[15]
"{"POWER1":"ON"}"
Moving the shutter. Value Position is changing. But Target stays the same. Becaus it doesn't know where the target will be.

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[55]
"{"Shutter1":{"Position":19,"Direction":1,"Target":100}}"
As example. The Position is changed, but Target stays the same

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[55]
"{"Shutter1":{"Position":39,"Direction":1,"Target":100}}"
Stop controlling the wall-switch. Relay 1 is put "OFF"

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[16]
"{"POWER1":"OFF"}"
Target is updated
Unfortunally i can't use this last message to send only 1 message to domoticz.
You would think that when updating the "Target". That the value would be the same as "Position".
But it is not. Then it is 1 more than position, then 2 and then exactly the same.

Code: Select all

stat/DZ_SH_A/RESULT : msg.payload : string[54]
"{"Shutter1":{"Position":41,"Direction":0,"Target":40}}"
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests