Skip to content

Commit

Permalink
added support for gen2+ devices
Browse files Browse the repository at this point in the history
1PM mini, H&T gen3
  • Loading branch information
windkh committed Mar 16, 2024
1 parent 2c787dc commit 0385212
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [10.19.0] - 2024-03-16
### support for gen 3 shelly 1PM Mini and H&T gen3

## [10.18.0] - 2024-03-12
### improved msg.payload checking - [#143](https://github.com/windkh/node-red-contrib-shelly/issues/143)

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Generation 2 devices:
- Shelly Plus Wall Dimmer
- Shelly Blu Gateway

Generation 3 devices:
- Shelly 1PM Mini
- Shelly Plus H&T


Others may work but are not really tested so far.

Expand Down Expand Up @@ -605,7 +609,7 @@ Note that the button is not always reachable as it falls to sleep. This is not t



# Shelly Node (Generation 2)
# Shelly Node (Generation 2+)
See also https://shelly-api-docs.shelly.cloud/gen2/
See also https://shelly-api-docs.shelly.cloud/gen2/Devices/ShellyPlus1PM
The node can communicate with several shelly types. You must select the correct device type from the combobox when configuring the node.
Expand All @@ -617,7 +621,7 @@ You must configure this network port, make sure that it is not already in use. I
under that the shelly device can reach the node-red server (Leave this field empty if you run inside the same network segment).


## Relay (Plus 1, Plus 1 PM, Plus 2 PM, Pro 1, Pro 1 PM, Pro 2, Pro 2 PM, Pro 4 PM, Plug US)
## Relay (Plus 1, Plus 1 PM, Plus 2 PM, Pro 1, Pro 1 PM, Pro 2, Pro 2 PM, Pro 4 PM, Plug US, 1PM Mini)
The node is able to turn on and turn off a shelly switch. It outputs the status after every interaction with the shelly device.
Turning on is done by sending the following payload into the input. The relay number is optional and defaults to 0.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-shelly",
"version": "10.18.0",
"version": "10.19.0",
"description": "Shelly nodes.",
"node-red": {
"version": ">=0.1.0",
Expand Down
4 changes: 2 additions & 2 deletions shelly/99-shelly.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ <h3>Details</h3>
inputs: 1,
outputs: 1,
icon: "shelly2.png",
paletteLabel: "shelly gen 2",
paletteLabel: "shelly gen 2+",
label: function () {
return this.description || this.hostname || this.devicetype || "Shelly";
},
Expand Down Expand Up @@ -453,7 +453,7 @@ <h3>Details</h3>
<div style="display: inline-block; position: relative; width: 70%; height: 19.1333px;">
<div style="position: absolute; left: 0; right: 0;">
<select id="node-input-devicetype" style="width:100%">
<option value="Relay">Relay - Shelly Plus 1, Plus 1 PM, Plus 2 PM, Pro 2, Pro 2 PM, Pro 4 PM, Plug US, Plus Plug S</option>
<option value="Relay">Relay - Shelly Plus 1, Plus 1 PM, Plus 2 PM, Pro 2, Pro 2 PM, Pro 4 PM, Plug US, Plus Plug S, 1PM Mini</option>
<option value="Button">Button - Shelly Plus I4</option>
<option value="Sensor">Sensor - Shelly Plus H&T, Plus Smoke</option>
<option value="Measure">Measure - Shelly Pro 3EM</option>
Expand Down
13 changes: 9 additions & 4 deletions shelly/99-shelly.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,15 @@ module.exports = function (RED) {
else if(node.shellyInfo.model && node.shellyInfo.gen === 2){
deviceType = node.shellyInfo.model;
requiredNodeType = 'shelly-gen2';

} // Generation 3 devices
else if(node.shellyInfo.model && node.shellyInfo.gen === 3){
deviceType = node.shellyInfo.model;
requiredNodeType = 'shelly-gen2'; // right now the protocol is compatible to gen 2
}
else {
// this can not happen right now.
requiredNodeType = 'not shupported';
requiredNodeType = 'shelly gen-type is not supported';
}


Expand Down Expand Up @@ -2151,7 +2156,7 @@ module.exports = function (RED) {
success = true;
}
else if(mode === 'callback'){
let scriptPath = path.resolve(__dirname, './scripts/button.script');
let scriptPath = path.resolve(__dirname, './scripts/callback.script');
const buffer = fs.readFileSync(scriptPath);
// const buffer = await readFile(scriptPath); #96 nodejs V19
let script = buffer.toString();
Expand Down Expand Up @@ -2250,9 +2255,9 @@ module.exports = function (RED) {
}

let gen2DeviceTypes = new Map([
["Relay", ["SHSW-", "SNSW-", "SPSW-", "SNPL-", "SNPM-"]],
["Relay", ["SHSW-", "SNSW-", "SPSW-", "SNPL-", "SNPM-", , "S3SW-"]],
["Button", ["SNSN-"]],
["Sensor", ["SNSN-"]], // Shelly Plus H&T / PLus Smoke only support Webhook, no scripting
["Sensor", ["SNSN-", "S3SN-"]], // Shelly Plus H&T / PLus Smoke only support Webhook, no scripting
["Measure", ["SPEM-"]],
["Dimmer", ["SNDM-"]],
["BluGateway", ["SNGW-"]],
Expand Down
File renamed without changes.

0 comments on commit 0385212

Please sign in to comment.