From 23d3b70a0c333254e095fceed9d38eb3f3a7d30c Mon Sep 17 00:00:00 2001 From: rockflopp Date: Sat, 5 Oct 2024 18:57:23 +0200 Subject: [PATCH 1/5] added shelly 2 pm g3 support --- README.md | 6 ++++ lib/datapoints.js | 10 ++++++- lib/devices/gen3/shelly2pmg3.js | 53 +++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 lib/devices/gen3/shelly2pmg3.js diff --git a/README.md b/README.md index 219ad80c..33301ac7 100755 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ It uses the default Shelly firmware (no flashing of firmware needed!). You will | Shelly H&T Gen3 (shellyhtg3) | ❌ | >= v8.0.0 | | Shelly 1 PM Gen3 (shelly1pmg3) | ❌ | >= v8.0.0 | | Shelly 1 Gen3 (shelly1g3) | ❌ | >= v8.0.0 | +| Shelly 2 PM Gen3 (shelly2pmg3) | ❌ | >= v8.0.0 | ### Bluetooth Low Energy (BLU) @@ -157,6 +158,11 @@ execute Placeholder for the next version (at the beginning of the line): ### **WORK IN PROGRESS** --> + +### 8.2.2 (2024-10-05) +* (@rockflopp) Added Shelly 2 PM gen 3 Integration + + ### 8.2.1 (2024-09-23) * (@Matze2010) Added datapoint for cover target position diff --git a/lib/datapoints.js b/lib/datapoints.js index 45c9ff1e..7047cf68 100644 --- a/lib/datapoints.js +++ b/lib/datapoints.js @@ -73,6 +73,8 @@ const shellypmminig3 = require('./devices/gen3/shellypmminig3').shellypmminig3; const shellyhtg3 = require('./devices/gen3/shellyhtg3').shellyhtg3; const shelly1pmg3 = require('./devices/gen3/shelly1pmg3').shelly1pmg3; const shelly1g3 = require('./devices/gen3/shelly1g3').shelly1g3; +const shelly2pmg3 = require('./devices/gen3/shelly2pmg3').shelly2pmg3; + const devices = { // Gen 1 @@ -141,6 +143,7 @@ const devices = { shellyhtg3, shelly1pmg3, shelly1g3, + shelly2pmg3, }; const deviceTypes = { @@ -204,13 +207,16 @@ const deviceTypes = { shellyplusuni: ['shellyplusuni'], ShellyWallDisplay: ['ShellyWallDisplay'], shellyplusrgbwpm: ['shellyplusrgbwpm'], - // Gen 3 + // Gen 3 shelly1minig3: ['shelly1minig3'], shelly1pmminig3: ['shelly1pmminig3'], shellypmminig3: ['shellypmminig3'], shellyhtg3: ['shellyhtg3'], shelly1pmg3: ['shelly1pmg3'], shelly1g3: ['shelly1g3'], + shelly2pmg3: ['shelly2pmgen3'], + + }; const deviceGen = { @@ -280,6 +286,7 @@ const deviceGen = { shellyhtg3: 3, shelly1pmg3: 3, shelly1g3: 3, + shelly2pmg3: 3, }; // https://shelly.cloud/knowledge-base/devices/ @@ -350,6 +357,7 @@ const deviceKnowledgeBase = { shellyhtg3: 'https://kb.shelly.cloud/knowledge-base/shelly-h-t-gen3', shelly1pmg3: 'https://kb.shelly.cloud/knowledge-base/shelly-1pm-gen3', shelly1g3: 'https://kb.shelly.cloud/knowledge-base/shelly-1-gen3', + shelly2pmg3: 'https://kb.shelly.cloud/knowledge-base/shelly-2pm-gen3', }; /** diff --git a/lib/devices/gen3/shelly2pmg3.js b/lib/devices/gen3/shelly2pmg3.js new file mode 100644 index 00000000..9bd7b367 --- /dev/null +++ b/lib/devices/gen3/shelly2pmg3.js @@ -0,0 +1,53 @@ +'use strict'; + +const shellyHelperGen2 = require('../gen2-helper'); + +/** + * Shelly 2 PM Gen 3 / shelly2pmgen3 + * + * https://shelly-api-docs.shelly.cloud/gen2/Devices/Gen3/Shelly2PMG3 + */ +const shelly2pmg3 = { + 'Sys.deviceMode': { + mqtt: { + init_funct: self => self.getDeviceMode(), + http_publish: '/rpc/Sys.GetConfig', + http_publish_funct: value => value ? JSON.parse(value).device.profile : undefined, + mqtt_cmd: '/rpc', + mqtt_cmd_funct: (value, self) => { + return JSON.stringify({ + id: self.getNextMsgId(), + src: 'iobroker', + method: 'Shelly.SetProfile', + params: { name: value } + }); + }, + }, + common: { + name: 'Mode / Profile', + type: 'string', + role: 'state', + read: true, + write: true, + states: { + 'switch': 'relay', + 'cover': 'shutter', + }, + }, + }, +}; + +// Füge die beiden Schalter hinzu (wie beim Shelly Pro 2 PM) +shellyHelperGen2.addSwitch(shelly2pmg3, 0, true); +shellyHelperGen2.addSwitch(shelly2pmg3, 1, true); + +// Füge die Eingänge hinzu (wie beim Shelly Pro 2 PM) +shellyHelperGen2.addInput(shelly2pmg3, 0); +shellyHelperGen2.addInput(shelly2pmg3, 1); + +// Füge die Cover-Funktionalität hinzu (optional, je nach Gerät) +shellyHelperGen2.addCover(shelly2pmg3, 0); + +module.exports = { + shelly2pmgen3: shelly2pmg3, +}; From 14cdee9771e4f0e09ead28559a5d32cb3dd03c88 Mon Sep 17 00:00:00 2001 From: rockflopp Date: Sat, 5 Oct 2024 21:47:06 +0200 Subject: [PATCH 2/5] spelling error --- lib/devices/gen3/shelly2pmg3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/devices/gen3/shelly2pmg3.js b/lib/devices/gen3/shelly2pmg3.js index 9bd7b367..76415c99 100644 --- a/lib/devices/gen3/shelly2pmg3.js +++ b/lib/devices/gen3/shelly2pmg3.js @@ -49,5 +49,5 @@ shellyHelperGen2.addInput(shelly2pmg3, 1); shellyHelperGen2.addCover(shelly2pmg3, 0); module.exports = { - shelly2pmgen3: shelly2pmg3, + shelly2pmg3: shelly2pmg3, }; From b425a7be29ceca88e24c3a01f30e63822e43203b Mon Sep 17 00:00:00 2001 From: rockflopp Date: Sat, 5 Oct 2024 23:44:02 +0200 Subject: [PATCH 3/5] added basic shelly 2 pm Gen3 Support --- lib/devices/gen3/shelly2pmg3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/devices/gen3/shelly2pmg3.js b/lib/devices/gen3/shelly2pmg3.js index 76415c99..219a321f 100644 --- a/lib/devices/gen3/shelly2pmg3.js +++ b/lib/devices/gen3/shelly2pmg3.js @@ -3,7 +3,7 @@ const shellyHelperGen2 = require('../gen2-helper'); /** - * Shelly 2 PM Gen 3 / shelly2pmgen3 + * Shelly 2 PM Gen 3 / shelly2pmg3 * * https://shelly-api-docs.shelly.cloud/gen2/Devices/Gen3/Shelly2PMG3 */ From 057d31babb64bc8a2819c0aa375badaad6250340 Mon Sep 17 00:00:00 2001 From: rockflopp Date: Mon, 7 Oct 2024 21:39:03 +0200 Subject: [PATCH 4/5] added basic shelly 2PM Gen3 Support --- README.md | 4 ++-- lib/datapoints.js | 4 +--- lib/devices/gen3/shelly2pmg3.js | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 33301ac7..90711547 100755 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ It uses the default Shelly firmware (no flashing of firmware needed!). You will | Shelly H&T Gen3 (shellyhtg3) | ❌ | >= v8.0.0 | | Shelly 1 PM Gen3 (shelly1pmg3) | ❌ | >= v8.0.0 | | Shelly 1 Gen3 (shelly1g3) | ❌ | >= v8.0.0 | -| Shelly 2 PM Gen3 (shelly2pmg3) | ❌ | >= v8.0.0 | +| Shelly 2 PM Gen3 (shelly2pmg3) | ❌ | >= v8.3.0 | ### Bluetooth Low Energy (BLU) @@ -159,7 +159,7 @@ execute ### **WORK IN PROGRESS** --> -### 8.2.2 (2024-10-05) +### **WORK IN PROGRESS** * (@rockflopp) Added Shelly 2 PM gen 3 Integration diff --git a/lib/datapoints.js b/lib/datapoints.js index 7047cf68..bfe0056f 100644 --- a/lib/datapoints.js +++ b/lib/datapoints.js @@ -214,9 +214,7 @@ const deviceTypes = { shellyhtg3: ['shellyhtg3'], shelly1pmg3: ['shelly1pmg3'], shelly1g3: ['shelly1g3'], - shelly2pmg3: ['shelly2pmgen3'], - - + shelly2pmg3: ['shelly2pmg3'], }; const deviceGen = { diff --git a/lib/devices/gen3/shelly2pmg3.js b/lib/devices/gen3/shelly2pmg3.js index 219a321f..4e88beeb 100644 --- a/lib/devices/gen3/shelly2pmg3.js +++ b/lib/devices/gen3/shelly2pmg3.js @@ -37,15 +37,15 @@ const shelly2pmg3 = { }, }; -// Füge die beiden Schalter hinzu (wie beim Shelly Pro 2 PM) +// Add Switches (like Shelly Pro 2 PM) shellyHelperGen2.addSwitch(shelly2pmg3, 0, true); shellyHelperGen2.addSwitch(shelly2pmg3, 1, true); -// Füge die Eingänge hinzu (wie beim Shelly Pro 2 PM) +// Add Inputs (like Shelly Pro 2 PM) shellyHelperGen2.addInput(shelly2pmg3, 0); shellyHelperGen2.addInput(shelly2pmg3, 1); -// Füge die Cover-Funktionalität hinzu (optional, je nach Gerät) +// Add cover functionality (optional) shellyHelperGen2.addCover(shelly2pmg3, 0); module.exports = { From da5d3978a591c14fe588a2a384639ad75133fbe7 Mon Sep 17 00:00:00 2001 From: rockflopp Date: Mon, 7 Oct 2024 22:00:38 +0200 Subject: [PATCH 5/5] added basic shelly 2PM Gen3 Support (fixed Linter Errors) --- lib/datapoints.js | 4 ++-- lib/devices/gen3/shelly2pmg3.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/datapoints.js b/lib/datapoints.js index bfe0056f..d1d5d7d7 100644 --- a/lib/datapoints.js +++ b/lib/datapoints.js @@ -207,14 +207,14 @@ const deviceTypes = { shellyplusuni: ['shellyplusuni'], ShellyWallDisplay: ['ShellyWallDisplay'], shellyplusrgbwpm: ['shellyplusrgbwpm'], - // Gen 3 + // Gen 3 shelly1minig3: ['shelly1minig3'], shelly1pmminig3: ['shelly1pmminig3'], shellypmminig3: ['shellypmminig3'], shellyhtg3: ['shellyhtg3'], shelly1pmg3: ['shelly1pmg3'], shelly1g3: ['shelly1g3'], - shelly2pmg3: ['shelly2pmg3'], + shelly2pmg3: ['shelly2pmg3'], }; const deviceGen = { diff --git a/lib/devices/gen3/shelly2pmg3.js b/lib/devices/gen3/shelly2pmg3.js index 4e88beeb..74fbe0a4 100644 --- a/lib/devices/gen3/shelly2pmg3.js +++ b/lib/devices/gen3/shelly2pmg3.js @@ -19,7 +19,7 @@ const shelly2pmg3 = { id: self.getNextMsgId(), src: 'iobroker', method: 'Shelly.SetProfile', - params: { name: value } + params: { name: value }, }); }, },