Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Shelly 2PM Gen 3 #1057

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.0 |

### Bluetooth Low Energy (BLU)

Expand Down Expand Up @@ -157,6 +158,11 @@ execute
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->

### **WORK IN PROGRESS**
* (@rockflopp) Added Shelly 2 PM gen 3 Integration
rockflopp marked this conversation as resolved.
Show resolved Hide resolved


### 8.2.1 (2024-09-23)

* (@Matze2010) Added datapoint for cover target position
Expand Down
6 changes: 6 additions & 0 deletions lib/datapoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,6 +143,7 @@ const devices = {
shellyhtg3,
shelly1pmg3,
shelly1g3,
shelly2pmg3,
};

const deviceTypes = {
Expand Down Expand Up @@ -211,6 +214,7 @@ const deviceTypes = {
shellyhtg3: ['shellyhtg3'],
shelly1pmg3: ['shelly1pmg3'],
shelly1g3: ['shelly1g3'],
shelly2pmg3: ['shelly2pmg3'],
};
rockflopp marked this conversation as resolved.
Show resolved Hide resolved

const deviceGen = {
Expand Down Expand Up @@ -280,6 +284,7 @@ const deviceGen = {
shellyhtg3: 3,
shelly1pmg3: 3,
shelly1g3: 3,
shelly2pmg3: 3,
};

// https://shelly.cloud/knowledge-base/devices/
Expand Down Expand Up @@ -350,6 +355,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',
};

/**
Expand Down
53 changes: 53 additions & 0 deletions lib/devices/gen3/shelly2pmg3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

const shellyHelperGen2 = require('../gen2-helper');

/**
* Shelly 2 PM Gen 3 / shelly2pmg3
*
* 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: '<mqttprefix>/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',
},
},
},
};

// Add Switches (like Shelly Pro 2 PM)
shellyHelperGen2.addSwitch(shelly2pmg3, 0, true);
shellyHelperGen2.addSwitch(shelly2pmg3, 1, true);

// Add Inputs (like Shelly Pro 2 PM)
shellyHelperGen2.addInput(shelly2pmg3, 0);
shellyHelperGen2.addInput(shelly2pmg3, 1);

// Add cover functionality (optional)
shellyHelperGen2.addCover(shelly2pmg3, 0);

module.exports = {
shelly2pmg3: shelly2pmg3,
};