Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Daro1003
Posts: 193
Joined: Monday 14 November 2022 12:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: Poland
Contact:

Re: Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Post by Daro1003 »

1. I just need to turn on the flows and dashticz stops working properly.

2. I start a scene in domoticz and then the lighting from the sensors stops working, i.e. communication between Domoticz and sonoff 4ch.
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Post by FireWizard »

Hello @Daro1003,

I do not understand, why all this trouble with Dashticz and the Switches occurs.

But I went back to a very basic flow.
Can you test this one.

Disable all flows, which receive and control Shellies and try this complete new flow.
Instead of a configuration, all idx's are hard coded in the flow (1060 and 1061)
As always, configure your own MQTT settings,

Test and let me know.

Code: Select all

[
    {
        "id": "ffc4efc1cd6ece12",
        "type": "function",
        "z": "10c090a82727bafe",
        "name": "Control Domoticz Switch",
        "func": "let msg1 = {};\nlet msg2 = {};\nmsg1.topic = \"shellies/switches\";\nmsg2.topic = \"shellies/temperature\";\n\n//Open (for Reversed Position)\nif (msg.payload.current_pos === 100) {\n    msg1.payload = { \"command\": \"udevice\", \"idx\": 1060, \"nvalue\": 1, \"svalue\": \"100\" }\n}\n\n//Closed (for Reversed Position)\nif (msg.payload.current_pos === 0) {\n    msg1.payload = { \"command\": \"udevice\", \"idx\": 1060, \"nvalue\": 0, \"svalue\": \"0\" }\n}\n\n//Percentage (for Reversed Position)\nif ((msg.payload.current_pos > 0) && (msg.payload.current_pos < 100)) {\n    msg1.payload = { \"command\": \"udevice\", \"idx\": 1060, \"nvalue\": 2, \"svalue\": msg.payload.current_pos.toString() }\n}\n\n//Temperature\nmsg2.payload = { \"command\": \"udevice\", \"idx\": 1061, \"nvalue\": 0, \"svalue\": msg.payload.temperature.tC.toString() }\n\nreturn [[msg1,msg2]];",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 530,
        "y": 380,
        "wires": [
            [
                "17f76470f66893c6"
            ]
        ]
    },
    {
        "id": "63466c41eeccdb21",
        "type": "mqtt out",
        "z": "10c090a82727bafe",
        "name": "Domoticz In",
        "topic": "domoticz/in",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "38b35487299a036d",
        "x": 1050,
        "y": 380,
        "wires": []
    },
    {
        "id": "f5114a0ea7413f87",
        "type": "mqtt in",
        "z": "10c090a82727bafe",
        "name": "Shelly Cover Status Out",
        "topic": "shelly2pmg3-34cdb0774d4c/status/cover:0",
        "qos": "0",
        "datatype": "auto-detect",
        "broker": "38b35487299a036d",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 260,
        "y": 380,
        "wires": [
            [
                "ffc4efc1cd6ece12"
            ]
        ]
    },
    {
        "id": "c3669ae0eab4b29d",
        "type": "comment",
        "z": "10c090a82727bafe",
        "name": "Shelly  ====> Domoticz Switch",
        "info": "",
        "x": 540,
        "y": 320,
        "wires": []
    },
    {
        "id": "51882f2b44c43e5c",
        "type": "mqtt in",
        "z": "10c090a82727bafe",
        "name": "Domoticz Out",
        "topic": "domoticz/out",
        "qos": "0",
        "datatype": "auto-detect",
        "broker": "38b35487299a036d",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 290,
        "y": 200,
        "wires": [
            [
                "ab0176dcde2164b2"
            ]
        ]
    },
    {
        "id": "dbc4d9f998e839fd",
        "type": "function",
        "z": "10c090a82727bafe",
        "name": "Blinds + Percentage ",
        "func": "// Function Blinds and Percentage\n\nmsg.topic = \"shelly2pmg3-34cdb0774d4c/command/cover:0\";\n\n//Closed\nif (msg.payload.nvalue === 0) { msg.payload = \"close\" };\n\n//Open\nif (msg.payload.nvalue === 1) { msg.payload = \"open\" };\n\n//Percentage\nif (msg.payload.nvalue === 2) { msg.payload = \"pos,\" + msg.payload.Level.toString() };\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 820,
        "y": 200,
        "wires": [
            [
                "91622adcb065ef12",
                "adb3dcf604b852df"
            ]
        ]
    },
    {
        "id": "91622adcb065ef12",
        "type": "debug",
        "z": "10c090a82727bafe",
        "name": "debug 76",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1040,
        "y": 260,
        "wires": []
    },
    {
        "id": "adb3dcf604b852df",
        "type": "mqtt out",
        "z": "10c090a82727bafe",
        "name": "Shelly Cover Command Out",
        "topic": "",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "38b35487299a036d",
        "x": 1100,
        "y": 200,
        "wires": []
    },
    {
        "id": "67acc7281fe20577",
        "type": "comment",
        "z": "10c090a82727bafe",
        "name": " Domoticz Switch ====> Shelly",
        "info": "",
        "x": 540,
        "y": 140,
        "wires": []
    },
    {
        "id": "ab0176dcde2164b2",
        "type": "switch",
        "z": "10c090a82727bafe",
        "name": "Filter Domoticz Switch Index",
        "property": "payload.idx",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1060",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 540,
        "y": 200,
        "wires": [
            [
                "dbc4d9f998e839fd"
            ]
        ]
    },
    {
        "id": "17f76470f66893c6",
        "type": "rbe",
        "z": "10c090a82727bafe",
        "name": "Prevent Loop",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "septopics": true,
        "property": "payload",
        "topi": "topic",
        "x": 790,
        "y": 380,
        "wires": [
            [
                "63466c41eeccdb21",
                "1917bf35635d0f9e"
            ]
        ]
    },
    {
        "id": "1917bf35635d0f9e",
        "type": "debug",
        "z": "10c090a82727bafe",
        "name": "debug 77",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1040,
        "y": 440,
        "wires": []
    },
    {
        "id": "38b35487299a036d",
        "type": "mqtt-broker",
        "name": "Raspberry Pi 1",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
Regards
Daro1003
Posts: 193
Joined: Monday 14 November 2022 12:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: Poland
Contact:

Re: Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Post by Daro1003 »

I'm testing this new flow for the second day and everything works fine.

Where do I provide the switch IDX and temperature IDX?
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Post by FireWizard »

Hello @Daro1003,
I'm testing this new flow for the second day and everything works fine.
I suggest, that we leave it, as it is now.
In case of another Shelly you can simply copying this flow and adjust some parameters.
Where do I provide the switch IDX and temperature IDX?
You have 2 streams, one from Domoticz to the Shelly.
This one needs only the Domoticz IDX number of the Domoticz Switch.

See the picture below and the "red arrow" in the "Switch" node, called "Filter Domoticz Switch Index"

Screenshot_Switch_node_Shelly2PM.png
Screenshot_Switch_node_Shelly2PM.png (22.95 KiB) Viewed 89 times

The other stream is from the Shelly to Domoticz This one needs the Domoticz IDX's in the "Function" node.

See the picture below and the "red arrows" in the "Function" node, called "Control Domoticz Switch" for the Domoticz switch
and the "blue arrow" for the Domoticz Temperature Sensor.

Screenshot_Function_node_Shelly2PM.png
Screenshot_Function_node_Shelly2PM.png (125.28 KiB) Viewed 89 times

Best regards
Daro1003
Posts: 193
Joined: Monday 14 November 2022 12:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: Poland
Contact:

Re: Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Post by Daro1003 »

ok so I select the whole flow and give copy.
COPY.png
COPY.png (50.31 KiB) Viewed 42 times
Then new FLOW and ctrl+V

Question:

Where do I put the shelly ID?

You showed me where to put the IDX switch and temp - thank you
Where do I put the shelly ID?
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Is it possible to add Shelly 2PM GEN 3 to Domoticz?

Post by FireWizard »

Hi Daro1003,

You asked.
ok so I select the whole flow and give copy.
Then new FLOW and ctrl+V
Yes, or Select the nodes, you want to copy and then CTRL-C and CTRL-V
Question:

Where do I put the shelly ID?
We have a limited number of nodes in the flow and if you would have double-clicked om each of them, you would have seen them yourself.

But okay,

In the upper stream from Domoticz to the Shelly, click on the Function node, called "Blinds + Percentage" and see below:

Screenshot_Function2_node_Shelly2PM.png
Screenshot_Function2_node_Shelly2PM.png (59.79 KiB) Viewed 30 times

In the lower stream from Shelly to Domoticz, click on the MQTT Input node, called "Shelly Cover Status Out" and see below:

Screenshot_MQTT-In_node_Shelly2PM.png
Screenshot_MQTT-In_node_Shelly2PM.png (44.87 KiB) Viewed 30 times

For the future development of flows, I recommend watching this playlist: Node-RED Essentials. (https://www.youtube.com/playlist?list=P ... qFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Best regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest