From 4110c352866d6e9a45e96c098c313f3eb1d0dda0 Mon Sep 17 00:00:00 2001 From: Smanar Date: Fri, 15 Nov 2024 17:19:42 +0100 Subject: [PATCH 1/6] Update de_web_plugin.cpp --- de_web_plugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/de_web_plugin.cpp b/de_web_plugin.cpp index 1ae078f593..0023ec6d6a 100644 --- a/de_web_plugin.cpp +++ b/de_web_plugin.cpp @@ -4880,6 +4880,13 @@ void DeRestPluginPrivate::checkSensorButtonEvent(Sensor *sensor, const deCONZ::A { ok = false; } + // SonOff + if (sensor->manufacturer() == QLatin1String("SONOFF")) + { + // payload: u16 attrId, u8 datatype, u8 data + // Comparing only data + ok = buttonMap.zclParam0 == zclFrame.payload().at(3); + } else if (ind.clusterId() == ONOFF_CLUSTER_ID && sensor->manufacturer() == QLatin1String("LUMI")) { quint8 value; From 11a0543ae4f0a8cc030d7cdf3c1cb7da43bfd4d7 Mon Sep 17 00:00:00 2001 From: "Schwarz, Christian" Date: Sun, 17 Nov 2024 20:45:42 +0100 Subject: [PATCH 2/6] Expand Sonoff Cluster in general.xml --- general.xml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/general.xml b/general.xml index 13d1a07a57..8d41df5dd1 100644 --- a/general.xml +++ b/general.xml @@ -5728,12 +5728,15 @@ Contactor > On/off=0003 - HP/HC=0004 - - Cluster for light sensor - - - - + + Cluster for Sonoff Specific Attributes + + + + + + + From 6814b86580920f29fd9409ceba42d9464fe583a8 Mon Sep 17 00:00:00 2001 From: "Schwarz, Christian" Date: Sun, 17 Nov 2024 20:52:34 +0100 Subject: [PATCH 3/6] add DDF for Sonoff Zbmini R2 extreme Smart Switch --- .../items/config_on_delayedpoweron_item.json | 8 + devices/sonoff/zbminir2.json | 283 ++++++++++++++++++ 2 files changed, 291 insertions(+) create mode 100644 devices/generic/items/config_on_delayedpoweron_item.json create mode 100644 devices/sonoff/zbminir2.json diff --git a/devices/generic/items/config_on_delayedpoweron_item.json b/devices/generic/items/config_on_delayedpoweron_item.json new file mode 100644 index 0000000000..14987a769e --- /dev/null +++ b/devices/generic/items/config_on_delayedpoweron_item.json @@ -0,0 +1,8 @@ +{ + "schema": "resourceitem1.schema.json", + "id": "config/on/delayedpoweron", + "datatype": "Bool", + "access": "RW", + "public": true, + "description": "Delays On/Off state on device startup (power on)." +} diff --git a/devices/sonoff/zbminir2.json b/devices/sonoff/zbminir2.json new file mode 100644 index 0000000000..608d24c81b --- /dev/null +++ b/devices/sonoff/zbminir2.json @@ -0,0 +1,283 @@ +{ + "schema": "devcap1.schema.json", + "manufacturername": "SONOFF", + "modelid": "ZBMINIR2", + "product": "Sonoff ZBMINI R2 Extreme", + "sleeper": false, + "status": "Gold", + "path": "/devices/zbminir2.json", + "subdevices": [ + { + "type": "$TYPE_ON_OFF_OUTPUT", + "restapi": "/lights", + "uuid": [ + "$address.ext", + "0x01" + ], + "items": [ + { + "name": "attr/id" + }, + { + "name": "attr/lastannounced" + }, + { + "name": "attr/lastseen" + }, + { + "name": "attr/manufacturername" + }, + { + "name": "attr/modelid" + }, + { + "name": "attr/name" + }, + { + "name": "attr/swversion" + }, + { + "name": "attr/type" + }, + { + "name": "attr/uniqueid" + }, + { + "name": "state/on" + }, + { + "name": "state/reachable" + } + ] + }, + { + "type": "$TYPE_SWITCH", + "restapi": "/sensors", + "uuid": [ + "$address.ext", + "0x01", + "0x0006" + ], + "meta": { + "values": { + "config/mode": { + "off": 9, + "on": 20 + } + } + }, + "items": [ + { + "name": "attr/id" + }, + { + "name": "attr/lastannounced" + }, + { + "name": "attr/lastseen" + }, + { + "name": "attr/manufacturername" + }, + { + "name": "attr/modelid" + }, + { + "name": "attr/name" + }, + { + "name": "attr/swversion" + }, + { + "name": "attr/type" + }, + { + "name": "attr/uniqueid" + }, + { + "name": "config/clickmode", + "description": "Allows configuration of the Relay (Detached Relay Mode). Usable Values are 'coupled' and 'decoupled'", + "default": "coupled", + "refresh.interval": 300, + "read": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0017" + }, + "parse": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0017", + "eval": "if (Attr.val == 0) { Item.val = 'coupled' } else if (Attr.val == 1) { Item.val = 'decoupled'}" + }, + "write": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0017", + "dt": "0x10", + "eval": "if (Item.val == 'coupled') { 0 } else if (Item.val == 'decoupled') { 1 } else { '0' }" + }, + "values": [ + ["\"coupled\"", "Relay Mode"], + ["\"decoupled\"", "Detach Relay Mode"] + ] + }, + { + "name": "config/devicemode", + "description": "Mode of the Switch with possible values 'rocker', 'momentary', 'followingon', 'followingoff'.", + "default": "rocker", + "refresh.interval": 300, + "read": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0016" + }, + "parse": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0016", + "eval": "if (Attr.val == 0) { Item.val = 'rocker' } else if (Attr.val == 1) { Item.val = 'momentary' } else if (Attr.val == 2) { Item.val = 'followingoff' } else if (Attr.val == 130) { Item.val = 'followingon' } else { Item.val = 'unknown' }" + }, + "write": { + "fn": "zcl:attr", + "ep": 1, + "at": "0x0016", + "cl": "0xfc11", + "dt": "0x20", + "eval": "if (Item.val == 'rocker') { 0 } else if (Item.val == 'momentary') { 1 } else if (Item.val == 'followingoff') { 2 } else if (Item.val == 'followingon') { 130 } else { 'unknown' }" + }, + "values": [ + ["\"momentary\"", "Momentary"], + ["\"rocker\"", "Rocker"], + ["\"followingoff\"", "Following (On)"], + ["\"follogwingon\"", "Following (Off)"] + ] + }, + { + "name": "config/delay", + "description": "Timedelay for On/Off state on device startup (power on).", + "refresh.interval": 3600, + "default": 0, + "read": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0015" + }, + "write": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0015", + "dt": "0x21", + "eval": "Item.val", + "range": [ + 1, + 3600 + ] + }, + "parse": { + "fn": "zcl:attr", + "ep": 1, + "at": "0x0015", + "cl": "0xfc11", + "eval": "Item.val = Attr.val" + } + }, + { + "name": "config/mode", + "description": "Enables or disable the Turbo Mode to Boost the signal.", + "default": "off", + "read": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0012" + }, + "parse": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0012", + "eval": "if (Attr.val == 9) { Item.val = 'off' } else if (Attr.val == 20) { Item.val = 'on' } else { Item.val = 'unknown' }" + }, + "write": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0012", + "dt": "0x29", + "eval": "if (Item.val == 'off') { 9 } else if (Item.val == 'on') { 20 }" + }, + "values": [ + ["\"off\"", "Turbo Mode Off"], + ["\"on\"", "Turbo Mode On"], + ["\"unknown\"", "Unknown"] + ] + }, + { + "name": "config/on" + }, + { + "name": "config/on/delayedpoweron", + "description": "Enables or disable the timedelay for On/Off state on device startup (power on).", + "refresh.interval": 3600, + "read": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0014" + }, + "write": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0014", + "dt": "0x10", + "eval": "Item.val" + }, + "parse": { + "fn": "zcl:attr", + "ep": 1, + "cl": "0xfc11", + "at": "0x0014", + "eval": "Item.val = Attr.val" + } + }, + { + "name": "config/on/startup" + }, + { + "name": "config/reachable" + }, + { + "name": "state/buttonevent", + "description": "The last received button event." + }, + { + "name": "state/lastupdated" + } + ] + } + ], + "bindings": [ + { + "bind": "unicast", + "src.ep": 1, + "cl": "0x0006", + "report": [ + { + "at": "0x0000", + "dt": "0x10", + "min": 5, + "max": 1800 + } + ] + } + ] +} \ No newline at end of file From 0d31af62f4094e4bd88aa5fdbdfe51e5d476f3e9 Mon Sep 17 00:00:00 2001 From: "Schwarz, Christian" Date: Sun, 17 Nov 2024 20:55:07 +0100 Subject: [PATCH 4/6] add zbminir2 to button_maps, needs changes from smanars pull request for rocker switch --- button_maps.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/button_maps.json b/button_maps.json index 4cf48f5672..f2f3f258de 100644 --- a/button_maps.json +++ b/button_maps.json @@ -1601,7 +1601,7 @@ ] }, "sonoffOnOffMap": { - "vendor": "Sonoff", + "vendor": "SONOFF", "doc": "Switch SNZB-01", "modelids": ["WB01", "WB-01", "SNZB-01P"], "map": [ @@ -1610,6 +1610,16 @@ [1, "0x01", "ONOFF", "TOGGLE", "0", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "short"] ] }, + "ZBMINIR2": { + "vendor": "SONOFF", + "doc": "ZBMINIR2", + "modelids": ["ZBMINIR2"], + "map": [ + [1, "0x01", "ONOFF", "ATTRIBUTE_REPORT", "0x01", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "On"], + [1, "0x01", "ONOFF", "ATTRIBUTE_REPORT", "0x00", "S_BUTTON_2", "S_BUTTON_ACTION_SHORT_RELEASED", "Off"], + [1, "0x01", "ONOFF", "TOGGLE", "0", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "Toggle"] + ] + }, "ZGRC-KEY-009": { "vendor": "YPHIX", "doc": "RGB wall switch", From 626140d061d01f645571f8edcd8a07917624e7b7 Mon Sep 17 00:00:00 2001 From: "Schwarz, Christian" Date: Mon, 18 Nov 2024 09:00:39 +0100 Subject: [PATCH 5/6] renamed ddf and removed path in json --- devices/sonoff/{zbminir2.json => zbminir2_relay.json} | 1 - 1 file changed, 1 deletion(-) rename devices/sonoff/{zbminir2.json => zbminir2_relay.json} (95%) diff --git a/devices/sonoff/zbminir2.json b/devices/sonoff/zbminir2_relay.json similarity index 95% rename from devices/sonoff/zbminir2.json rename to devices/sonoff/zbminir2_relay.json index 608d24c81b..ec0fd2e97a 100644 --- a/devices/sonoff/zbminir2.json +++ b/devices/sonoff/zbminir2_relay.json @@ -5,7 +5,6 @@ "product": "Sonoff ZBMINI R2 Extreme", "sleeper": false, "status": "Gold", - "path": "/devices/zbminir2.json", "subdevices": [ { "type": "$TYPE_ON_OFF_OUTPUT", From c6444855153e90a351dfb5ff8302f640bf4169d7 Mon Sep 17 00:00:00 2001 From: "Schwarz, Christian" Date: Mon, 18 Nov 2024 17:18:55 +0100 Subject: [PATCH 6/6] corrected config/delay range --- devices/sonoff/zbminir2_relay.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/devices/sonoff/zbminir2_relay.json b/devices/sonoff/zbminir2_relay.json index ec0fd2e97a..2effaadb61 100644 --- a/devices/sonoff/zbminir2_relay.json +++ b/devices/sonoff/zbminir2_relay.json @@ -162,6 +162,10 @@ "description": "Timedelay for On/Off state on device startup (power on).", "refresh.interval": 3600, "default": 0, + "range": [ + 1, + 3600 + ], "read": { "fn": "zcl:attr", "ep": 1, @@ -174,11 +178,7 @@ "cl": "0xfc11", "at": "0x0015", "dt": "0x21", - "eval": "Item.val", - "range": [ - 1, - 3600 - ] + "eval": "Item.val" }, "parse": { "fn": "zcl:attr",