From 396ddaa6f0ba51b5dae04bf470f79bf6c2235f46 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 00:54:18 +0200 Subject: [PATCH 1/8] Add Philips Hue rules --- DimmerLiving/dn-hold.rule.json | 30 ++++++++++++++++++++ DimmerLiving/dn-short.rule.json | 30 ++++++++++++++++++++ DimmerLiving/mem.sensor.json | 8 ++++++ DimmerLiving/off-short.1.rule.json | 35 +++++++++++++++++++++++ DimmerLiving/off-short.2.rule.json | 35 +++++++++++++++++++++++ DimmerLiving/on-long.rule.json | 32 +++++++++++++++++++++ DimmerLiving/on-short.1.rule.json | 35 +++++++++++++++++++++++ DimmerLiving/on-short.2.rule.json | 35 +++++++++++++++++++++++ DimmerLiving/up-hold.rule.json | 30 ++++++++++++++++++++ DimmerLiving/up-short.rule.json | 30 ++++++++++++++++++++ MotionSimple/off.rule.json | 24 ++++++++++++++++ MotionSimple/on-bright.rule.json | 39 ++++++++++++++++++++++++++ MotionSimple/on-dim.rule.json | 45 ++++++++++++++++++++++++++++++ TapSimple/1.rule.json | 23 +++++++++++++++ TapSimple/2.rule.json | 25 +++++++++++++++++ TapSimple/3.rule.json | 25 +++++++++++++++++ TapSimple/4.rule.json | 25 +++++++++++++++++ 17 files changed, 506 insertions(+) create mode 100644 DimmerLiving/dn-hold.rule.json create mode 100644 DimmerLiving/dn-short.rule.json create mode 100644 DimmerLiving/mem.sensor.json create mode 100644 DimmerLiving/off-short.1.rule.json create mode 100644 DimmerLiving/off-short.2.rule.json create mode 100644 DimmerLiving/on-long.rule.json create mode 100644 DimmerLiving/on-short.1.rule.json create mode 100644 DimmerLiving/on-short.2.rule.json create mode 100644 DimmerLiving/up-hold.rule.json create mode 100644 DimmerLiving/up-short.rule.json create mode 100644 MotionSimple/off.rule.json create mode 100644 MotionSimple/on-bright.rule.json create mode 100644 MotionSimple/on-dim.rule.json create mode 100644 TapSimple/1.rule.json create mode 100644 TapSimple/2.rule.json create mode 100644 TapSimple/3.rule.json create mode 100644 TapSimple/4.rule.json diff --git a/DimmerLiving/dn-hold.rule.json b/DimmerLiving/dn-hold.rule.json new file mode 100644 index 0000000..3f4a400 --- /dev/null +++ b/DimmerLiving/dn-hold.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.dn-hold", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "ct_inc": 24 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "ct_inc": 24 + } + } + ] +} diff --git a/DimmerLiving/dn-short.rule.json b/DimmerLiving/dn-short.rule.json new file mode 100644 index 0000000..1ae9f8e --- /dev/null +++ b/DimmerLiving/dn-short.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.dn-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "bri_inc": -25 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri_inc": -25 + } + } + ] +} diff --git a/DimmerLiving/mem.sensor.json b/DimmerLiving/mem.sensor.json new file mode 100644 index 0000000..71f3596 --- /dev/null +++ b/DimmerLiving/mem.sensor.json @@ -0,0 +1,8 @@ +{ + "name": "BASENAME.mem", + "type": "CLIPGenericStatus", + "modelid": "Adrium Memory", + "manufacturername": "Adrium", + "swversion": "1.0", + "uniqueid": "d0:ac:4e:d3:93:3b:7a:00-01" +} diff --git a/DimmerLiving/off-short.1.rule.json b/DimmerLiving/off-short.1.rule.json new file mode 100644 index 0000000..046e96f --- /dev/null +++ b/DimmerLiving/off-short.1.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.off-short.1", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "4002" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "eq", + "value": "1" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 0 + } + }, + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/DimmerLiving/off-short.2.rule.json b/DimmerLiving/off-short.2.rule.json new file mode 100644 index 0000000..1cf4a19 --- /dev/null +++ b/DimmerLiving/off-short.2.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.off-short.2", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "4002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "gt", + "value": "1" + } + ], + "actions": [ + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "on": false + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/DimmerLiving/on-long.rule.json b/DimmerLiving/on-long.rule.json new file mode 100644 index 0000000..302695f --- /dev/null +++ b/DimmerLiving/on-long.rule.json @@ -0,0 +1,32 @@ +{ + "name": "BASENAME.on-long", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "bri": 203, + "ct": 357 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri": 203, + "ct": 357 + } + } + ] +} diff --git a/DimmerLiving/on-short.1.rule.json b/DimmerLiving/on-short.1.rule.json new file mode 100644 index 0000000..a5ad252 --- /dev/null +++ b/DimmerLiving/on-short.1.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.on-short.1", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "lt", + "value": "1" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "on": true + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/DimmerLiving/on-short.2.rule.json b/DimmerLiving/on-short.2.rule.json new file mode 100644 index 0000000..94f709b --- /dev/null +++ b/DimmerLiving/on-short.2.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.on-short.2", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "eq", + "value": "1" + } + ], + "actions": [ + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "on": true + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 2 + } + } + ] +} diff --git a/DimmerLiving/up-hold.rule.json b/DimmerLiving/up-hold.rule.json new file mode 100644 index 0000000..c4822ca --- /dev/null +++ b/DimmerLiving/up-hold.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.up-hold", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "ct_inc": -24 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "ct_inc": -24 + } + } + ] +} diff --git a/DimmerLiving/up-short.rule.json b/DimmerLiving/up-short.rule.json new file mode 100644 index 0000000..b50cf30 --- /dev/null +++ b/DimmerLiving/up-short.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.up-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "bri_inc": 25 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri_inc": 25 + } + } + ] +} diff --git a/MotionSimple/off.rule.json b/MotionSimple/off.rule.json new file mode 100644 index 0000000..aabdbda --- /dev/null +++ b/MotionSimple/off.rule.json @@ -0,0 +1,24 @@ +{ + "name": "BASENAME.off", + "conditions": [ + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "false" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "ddx", + "value": "PT00:03:00" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/MotionSimple/on-bright.rule.json b/MotionSimple/on-bright.rule.json new file mode 100644 index 0000000..b523a19 --- /dev/null +++ b/MotionSimple/on-bright.rule.json @@ -0,0 +1,39 @@ +{ + "name": "BASENAME.on-bright", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/daylight", + "operator": "eq", + "value": "false" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "in", + "value": "T07:00:00/T00:00:00" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 230 + } + } + ] +} diff --git a/MotionSimple/on-dim.rule.json b/MotionSimple/on-dim.rule.json new file mode 100644 index 0000000..cb19ce9 --- /dev/null +++ b/MotionSimple/on-dim.rule.json @@ -0,0 +1,45 @@ +{ + "name": "BASENAME.on-dim", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/daylight", + "operator": "eq", + "value": "false" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "in", + "value": "T00:00:00/T07:00:00" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 5 + } + }, + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + } + } + ] +} diff --git a/TapSimple/1.rule.json b/TapSimple/1.rule.json new file mode 100644 index 0000000..14b38d1 --- /dev/null +++ b/TapSimple/1.rule.json @@ -0,0 +1,23 @@ +{ + "name": "BASENAME.1", + "conditions": [ + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "34" + }, + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/TapSimple/2.rule.json b/TapSimple/2.rule.json new file mode 100644 index 0000000..cefc50a --- /dev/null +++ b/TapSimple/2.rule.json @@ -0,0 +1,25 @@ +{ + "name": "BASENAME.2", + "conditions": [ + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "16" + }, + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 5, + "ct": 400 + } + } + ] +} diff --git a/TapSimple/3.rule.json b/TapSimple/3.rule.json new file mode 100644 index 0000000..a7adf53 --- /dev/null +++ b/TapSimple/3.rule.json @@ -0,0 +1,25 @@ +{ + "name": "BASENAME.3", + "conditions": [ + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "17" + }, + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 52, + "ct": 286 + } + } + ] +} diff --git a/TapSimple/4.rule.json b/TapSimple/4.rule.json new file mode 100644 index 0000000..15d7d89 --- /dev/null +++ b/TapSimple/4.rule.json @@ -0,0 +1,25 @@ +{ + "name": "BASENAME.4", + "conditions": [ + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "18" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 205, + "ct": 182 + } + } + ] +} From ff7b74da7b2af7cf0e18e02ce34b072cfe7e4ba9 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 07:11:06 +0200 Subject: [PATCH 2/8] Add README --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3033c8e --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Philips Hue Rules + +Each folder contains a set of rules that can be used with Philips Hue. + +## Usage + +See the readme inside the folder. + +## Installation + +The IDs of the components should be replaced first. +Then the JSON files are submitted by POST to the bridge. + +This can be done using the following snippet: + +```sh +BRIDGE="192.168.0.150" +APIKEY="1234" +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; ..." + +for f in *.rule.json; do cat "$f" | sed "$IDS" | curl "http://$BRIDGE/api/$APIKEY/rules" -H 'Content-Type: application/json' -d @-; done +``` + From ce1851cf5a4f5fc58f19507d90fc6cd623737535 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 12 Apr 2018 23:13:12 +0200 Subject: [PATCH 3/8] Add readmes --- DimmerLiving/README.md | 31 +++++++++++++++++++++++++++++++ MotionSimple/README.md | 19 +++++++++++++++++++ TapSimple/README.md | 15 +++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 DimmerLiving/README.md create mode 100644 MotionSimple/README.md create mode 100644 TapSimple/README.md diff --git a/DimmerLiving/README.md b/DimmerLiving/README.md new file mode 100644 index 0000000..8e82173 --- /dev/null +++ b/DimmerLiving/README.md @@ -0,0 +1,31 @@ +# Dimmer Switch Ruleset for Two Light Groups + +This ruleset assumes two light groups inside the same room. + +The on button first turns on one group and then the other. +So does the off button in reverse order. + +The lights are only switched on without changing +the previously configured state. + +The lights can be reset to a bright but confortable mood for the evening +when pressing the on button longer. + +Pressing the brightness buttons change the brightness, +holding the brightness buttons change the color temperature. + + +## Devices + +```sh +# IDS="s/BASENAME/xxx/g; s/GROUP1/xxx/g; s/GROUP2/xxx/g; s/DIMMER/xxx/g; s/MEM/xxx/g" +``` + +Install the memory sensor and note its ID before proceding. +Use the `mem.sensor.json` file, replace the `BASENAME`, and POST it to the /api/KEY/sensors URL. + +* `BASENAME` Basename of the ruleset +* `GROUP1` ID of the first group to handle +* `GROUP2` ID of the second group to handle +* `DIMMER` ID of the dimmer switch +* `MEM` ID of the memory sensor diff --git a/MotionSimple/README.md b/MotionSimple/README.md new file mode 100644 index 0000000..aa9edd0 --- /dev/null +++ b/MotionSimple/README.md @@ -0,0 +1,19 @@ +# Simple Motion Sensor Ruleset + +This ruleset is a simple configuration that turns on a +group of lights when the motion sensor registers movement. + +It does not trigger an action, if a light in the group is already switched on. + +In the night, it only turns on the lights dim. + +## Devices + +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; s/AMBIENT/xxx/g" +``` + +* `BASENAME` Basename of the ruleset +* `GROUP` ID of the group to handle +* `MOTION` ID of the motion sensor +* `AMBIENT` ID of the ambient light sensor inside the motion sensor diff --git a/TapSimple/README.md b/TapSimple/README.md new file mode 100644 index 0000000..4608607 --- /dev/null +++ b/TapSimple/README.md @@ -0,0 +1,15 @@ +# Simple Tap Button Ruleset + +This ruleset is a simple configuration that turns on a +group of lights with an increasing brightness on the buttons. + + +## Devices + +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/TAP/xxx/g" +``` + +* `BASENAME` Basename of the ruleset +* `GROUP` ID of the group to handle +* `TAP` ID of the tap button From f32a9b1e7afc10f4eb433d31db63c2d7a4e4e218 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 00:54:18 +0200 Subject: [PATCH 4/8] Add Philips Hue rules --- DimmerLiving/dn-hold.rule.json | 30 +++++++++++++++++++++++ DimmerLiving/dn-short.rule.json | 30 +++++++++++++++++++++++ DimmerLiving/off-short.1.rule.json | 35 +++++++++++++++++++++++++++ DimmerLiving/off-short.2.rule.json | 35 +++++++++++++++++++++++++++ DimmerLiving/on-long.rule.json | 32 ++++++++++++++++++++++++ DimmerLiving/on-short.1.rule.json | 35 +++++++++++++++++++++++++++ DimmerLiving/on-short.2.rule.json | 35 +++++++++++++++++++++++++++ DimmerLiving/up-hold.rule.json | 30 +++++++++++++++++++++++ DimmerLiving/up-short.rule.json | 30 +++++++++++++++++++++++ MotionSimple/off.rule.json | 24 ++++++++++++++++++ MotionSimple/on-bright.rule.json | 39 ++++++++++++++++++++++++++++++ MotionSimple/on-dim.rule.json | 39 ++++++++++++++++++++++++++++++ TapSimple/1.rule.json | 23 ++++++++++++++++++ TapSimple/2.rule.json | 25 +++++++++++++++++++ TapSimple/3.rule.json | 25 +++++++++++++++++++ TapSimple/4.rule.json | 25 +++++++++++++++++++ 16 files changed, 492 insertions(+) create mode 100644 DimmerLiving/dn-hold.rule.json create mode 100644 DimmerLiving/dn-short.rule.json create mode 100644 DimmerLiving/off-short.1.rule.json create mode 100644 DimmerLiving/off-short.2.rule.json create mode 100644 DimmerLiving/on-long.rule.json create mode 100644 DimmerLiving/on-short.1.rule.json create mode 100644 DimmerLiving/on-short.2.rule.json create mode 100644 DimmerLiving/up-hold.rule.json create mode 100644 DimmerLiving/up-short.rule.json create mode 100644 MotionSimple/off.rule.json create mode 100644 MotionSimple/on-bright.rule.json create mode 100644 MotionSimple/on-dim.rule.json create mode 100644 TapSimple/1.rule.json create mode 100644 TapSimple/2.rule.json create mode 100644 TapSimple/3.rule.json create mode 100644 TapSimple/4.rule.json diff --git a/DimmerLiving/dn-hold.rule.json b/DimmerLiving/dn-hold.rule.json new file mode 100644 index 0000000..3f4a400 --- /dev/null +++ b/DimmerLiving/dn-hold.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.dn-hold", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "ct_inc": 24 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "ct_inc": 24 + } + } + ] +} diff --git a/DimmerLiving/dn-short.rule.json b/DimmerLiving/dn-short.rule.json new file mode 100644 index 0000000..1ae9f8e --- /dev/null +++ b/DimmerLiving/dn-short.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.dn-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "bri_inc": -25 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri_inc": -25 + } + } + ] +} diff --git a/DimmerLiving/off-short.1.rule.json b/DimmerLiving/off-short.1.rule.json new file mode 100644 index 0000000..046e96f --- /dev/null +++ b/DimmerLiving/off-short.1.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.off-short.1", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "4002" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "eq", + "value": "1" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 0 + } + }, + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/DimmerLiving/off-short.2.rule.json b/DimmerLiving/off-short.2.rule.json new file mode 100644 index 0000000..1cf4a19 --- /dev/null +++ b/DimmerLiving/off-short.2.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.off-short.2", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "4002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "gt", + "value": "1" + } + ], + "actions": [ + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "on": false + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/DimmerLiving/on-long.rule.json b/DimmerLiving/on-long.rule.json new file mode 100644 index 0000000..91ffdb0 --- /dev/null +++ b/DimmerLiving/on-long.rule.json @@ -0,0 +1,32 @@ +{ + "name": "BASENAME.on-long", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1003" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "bri": 203, + "ct": 357 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri": 203, + "ct": 357 + } + } + ] +} diff --git a/DimmerLiving/on-short.1.rule.json b/DimmerLiving/on-short.1.rule.json new file mode 100644 index 0000000..a5ad252 --- /dev/null +++ b/DimmerLiving/on-short.1.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.on-short.1", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "lt", + "value": "1" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "on": true + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/DimmerLiving/on-short.2.rule.json b/DimmerLiving/on-short.2.rule.json new file mode 100644 index 0000000..94f709b --- /dev/null +++ b/DimmerLiving/on-short.2.rule.json @@ -0,0 +1,35 @@ +{ + "name": "BASENAME.on-short.2", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/MEM/state/status", + "operator": "eq", + "value": "1" + } + ], + "actions": [ + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "on": true + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 2 + } + } + ] +} diff --git a/DimmerLiving/up-hold.rule.json b/DimmerLiving/up-hold.rule.json new file mode 100644 index 0000000..c4822ca --- /dev/null +++ b/DimmerLiving/up-hold.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.up-hold", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "ct_inc": -24 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "ct_inc": -24 + } + } + ] +} diff --git a/DimmerLiving/up-short.rule.json b/DimmerLiving/up-short.rule.json new file mode 100644 index 0000000..b50cf30 --- /dev/null +++ b/DimmerLiving/up-short.rule.json @@ -0,0 +1,30 @@ +{ + "name": "BASENAME.up-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP1/action", + "method": "PUT", + "body": { + "bri_inc": 25 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri_inc": 25 + } + } + ] +} diff --git a/MotionSimple/off.rule.json b/MotionSimple/off.rule.json new file mode 100644 index 0000000..aabdbda --- /dev/null +++ b/MotionSimple/off.rule.json @@ -0,0 +1,24 @@ +{ + "name": "BASENAME.off", + "conditions": [ + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "false" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "ddx", + "value": "PT00:03:00" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/MotionSimple/on-bright.rule.json b/MotionSimple/on-bright.rule.json new file mode 100644 index 0000000..051684d --- /dev/null +++ b/MotionSimple/on-bright.rule.json @@ -0,0 +1,39 @@ +{ + "name": "BASENAME.on-bright", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/daylight", + "operator": "eq", + "value": "false" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "in", + "value": "T07:00:00/T00:00:00" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 240 + } + } + ] +} diff --git a/MotionSimple/on-dim.rule.json b/MotionSimple/on-dim.rule.json new file mode 100644 index 0000000..b777cb5 --- /dev/null +++ b/MotionSimple/on-dim.rule.json @@ -0,0 +1,39 @@ +{ + "name": "BASENAME.on-dim", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/daylight", + "operator": "eq", + "value": "false" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "in", + "value": "T00:00:00/T07:00:00" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 5 + } + } + ] +} diff --git a/TapSimple/1.rule.json b/TapSimple/1.rule.json new file mode 100644 index 0000000..14b38d1 --- /dev/null +++ b/TapSimple/1.rule.json @@ -0,0 +1,23 @@ +{ + "name": "BASENAME.1", + "conditions": [ + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "34" + }, + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/TapSimple/2.rule.json b/TapSimple/2.rule.json new file mode 100644 index 0000000..cefc50a --- /dev/null +++ b/TapSimple/2.rule.json @@ -0,0 +1,25 @@ +{ + "name": "BASENAME.2", + "conditions": [ + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "16" + }, + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 5, + "ct": 400 + } + } + ] +} diff --git a/TapSimple/3.rule.json b/TapSimple/3.rule.json new file mode 100644 index 0000000..a7adf53 --- /dev/null +++ b/TapSimple/3.rule.json @@ -0,0 +1,25 @@ +{ + "name": "BASENAME.3", + "conditions": [ + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "17" + }, + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 52, + "ct": 286 + } + } + ] +} diff --git a/TapSimple/4.rule.json b/TapSimple/4.rule.json new file mode 100644 index 0000000..41eb092 --- /dev/null +++ b/TapSimple/4.rule.json @@ -0,0 +1,25 @@ +{ + "name": "BASENAME.4", + "conditions": [ + { + "address": "/sensors/TAP/state/lastupdated", + "operator": "dx" + }, + { + "address": "/sensors/TAP/state/buttonevent", + "operator": "eq", + "value": "18" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 203, + "ct": 182 + } + } + ] +} From 105cc17ad352237844df0601be7938f80308b601 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 07:11:06 +0200 Subject: [PATCH 5/8] Add README --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3033c8e --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Philips Hue Rules + +Each folder contains a set of rules that can be used with Philips Hue. + +## Usage + +See the readme inside the folder. + +## Installation + +The IDs of the components should be replaced first. +Then the JSON files are submitted by POST to the bridge. + +This can be done using the following snippet: + +```sh +BRIDGE="192.168.0.150" +APIKEY="1234" +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; ..." + +for f in *.rule.json; do cat "$f" | sed "$IDS" | curl "http://$BRIDGE/api/$APIKEY/rules" -H 'Content-Type: application/json' -d @-; done +``` + From 4103cfe4e90401fc452db78b212223700dc60eca Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 12 Apr 2018 23:13:12 +0200 Subject: [PATCH 6/8] Add descriptions --- DimmerLiving/README.md | 29 +++++++++++++++++++++++++++++ DimmerLiving/mem.sensor.json | 8 ++++++++ MotionSimple/README.md | 19 +++++++++++++++++++ TapSimple/README.md | 15 +++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 DimmerLiving/README.md create mode 100644 DimmerLiving/mem.sensor.json create mode 100644 MotionSimple/README.md create mode 100644 TapSimple/README.md diff --git a/DimmerLiving/README.md b/DimmerLiving/README.md new file mode 100644 index 0000000..81e439c --- /dev/null +++ b/DimmerLiving/README.md @@ -0,0 +1,29 @@ +# Dimmer Switch Ruleset for Two Light Groups + +This ruleset assumes two light groups inside the same room. +This may be the case in the living room. + +The on button first turns on one group and then the other. +So does the off button in reverse order. + +The lights can be reset to a bright but confortable mood for the evening +when pressing the on button longer. + +Pressing the brightness buttons change the brightness, +holding the brightness buttons change the color temperature. + + +## Devices + +```sh +# IDS="s/BASENAME/xxx/g; s/GROUP1/xxx/g; s/GROUP2/xxx/g; s/DIMMER/xxx/g; s/MEM/xxx/g" +``` + +Install the memory sensor and note its ID before proceding. +Use the `mem.sensor.json` file, replace the `BASENAME`, and POST it to the /api/KEY/sensors URL. + +* `BASENAME` Basename of the ruleset +* `GROUP1` ID of the first group to handle +* `GROUP2` ID of the second group to handle +* `DIMMER` ID of the dimmer switch +* `MEM` ID of the memory sensor diff --git a/DimmerLiving/mem.sensor.json b/DimmerLiving/mem.sensor.json new file mode 100644 index 0000000..fff90e6 --- /dev/null +++ b/DimmerLiving/mem.sensor.json @@ -0,0 +1,8 @@ +{ + "name": "BASENAME.mem", + "type": "CLIPGenericStatus", + "modelid": "MEM001", + "manufacturername": "Adrium", + "swversion": "1.0", + "uniqueid": "00:ad:10:f3:2a:9b-01" +} diff --git a/MotionSimple/README.md b/MotionSimple/README.md new file mode 100644 index 0000000..aa9edd0 --- /dev/null +++ b/MotionSimple/README.md @@ -0,0 +1,19 @@ +# Simple Motion Sensor Ruleset + +This ruleset is a simple configuration that turns on a +group of lights when the motion sensor registers movement. + +It does not trigger an action, if a light in the group is already switched on. + +In the night, it only turns on the lights dim. + +## Devices + +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; s/AMBIENT/xxx/g" +``` + +* `BASENAME` Basename of the ruleset +* `GROUP` ID of the group to handle +* `MOTION` ID of the motion sensor +* `AMBIENT` ID of the ambient light sensor inside the motion sensor diff --git a/TapSimple/README.md b/TapSimple/README.md new file mode 100644 index 0000000..4608607 --- /dev/null +++ b/TapSimple/README.md @@ -0,0 +1,15 @@ +# Simple Tap Button Ruleset + +This ruleset is a simple configuration that turns on a +group of lights with an increasing brightness on the buttons. + + +## Devices + +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/TAP/xxx/g" +``` + +* `BASENAME` Basename of the ruleset +* `GROUP` ID of the group to handle +* `TAP` ID of the tap button From 7ea6d42baf793b77cec89a84dcfbaa4715cd662f Mon Sep 17 00:00:00 2001 From: Adrian Date: Tue, 17 Apr 2018 09:36:09 +0200 Subject: [PATCH 7/8] Add more Motion sensor rulesets --- MotionAllOff/README.md | 13 ++++++ MotionAllOff/all-off.rule.json | 24 ++++++++++ MotionIntelligent/README.md | 24 ++++++++++ MotionIntelligent/mem.sensor.json | 8 ++++ MotionIntelligent/off.rule.json | 36 +++++++++++++++ MotionIntelligent/on-bright.rule.json | 52 ++++++++++++++++++++++ MotionIntelligent/on-dim-morning.rule.json | 52 ++++++++++++++++++++++ MotionIntelligent/on-dim-night.rule.json | 47 +++++++++++++++++++ 8 files changed, 256 insertions(+) create mode 100644 MotionAllOff/README.md create mode 100644 MotionAllOff/all-off.rule.json create mode 100644 MotionIntelligent/README.md create mode 100644 MotionIntelligent/mem.sensor.json create mode 100644 MotionIntelligent/off.rule.json create mode 100644 MotionIntelligent/on-bright.rule.json create mode 100644 MotionIntelligent/on-dim-morning.rule.json create mode 100644 MotionIntelligent/on-dim-night.rule.json diff --git a/MotionAllOff/README.md b/MotionAllOff/README.md new file mode 100644 index 0000000..d204398 --- /dev/null +++ b/MotionAllOff/README.md @@ -0,0 +1,13 @@ +# Turn Off All Lights + +This ruleset is a simple configuration that turns off all +lights when the motion sensor does not register movement within a 2 hour timeframe. + +## Devices + +```sh +IDS="s/BASENAME/xxx/g; s/MOTION/xxx/g" +``` + +* `BASENAME` Basename of the ruleset +* `MOTION` ID of the motion sensor diff --git a/MotionAllOff/all-off.rule.json b/MotionAllOff/all-off.rule.json new file mode 100644 index 0000000..3650665 --- /dev/null +++ b/MotionAllOff/all-off.rule.json @@ -0,0 +1,24 @@ +{ + "name": "BASENAME.all-off", + "conditions": [ + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "false" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "stable", + "value": "PT02:00:00" + } + ], + "actions": [ + { + "address": "/groups/0/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/MotionIntelligent/README.md b/MotionIntelligent/README.md new file mode 100644 index 0000000..9b39526 --- /dev/null +++ b/MotionIntelligent/README.md @@ -0,0 +1,24 @@ +# Intelligent Motion Sensor Ruleset + +This ruleset is an improved configuration that turns on a +group of lights when the motion sensor registers movement. + +It does not trigger an action, if a light in the group is already switched on. + +In the night, it only turns on the lights dim. +The daylight sensor is checked for sunrise times. + +It does not switch off the lights, if they were not switched on by the sensor. + +## Devices + +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; s/AMBIENT/xxx/g; s/DAYLIGHT/1/g; s/MEM/xxx/g" +``` + +* `BASENAME` Basename of the ruleset +* `GROUP` ID of the group to handle +* `MOTION` ID of the motion sensor +* `AMBIENT` ID of the ambient light sensor inside the motion sensor +* `DAYLIGHT` ID of the daylight sensor (usually 1) +* `MEM` ID of the memory sensor diff --git a/MotionIntelligent/mem.sensor.json b/MotionIntelligent/mem.sensor.json new file mode 100644 index 0000000..e75e228 --- /dev/null +++ b/MotionIntelligent/mem.sensor.json @@ -0,0 +1,8 @@ +{ + "name": "BASENAME.mem", + "type": "CLIPGenericStatus", + "modelid": "MEM001", + "manufacturername": "Adrium", + "swversion": "1.0", + "uniqueid": "00:ad:10:f3:2a:9b-02" +} diff --git a/MotionIntelligent/off.rule.json b/MotionIntelligent/off.rule.json new file mode 100644 index 0000000..aa1b810 --- /dev/null +++ b/MotionIntelligent/off.rule.json @@ -0,0 +1,36 @@ +{ + "name": "BASENAME.off", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "gt", + "value": "0" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "false" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "ddx", + "value": "PT00:02:00" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": false + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 0 + } + } + ] +} diff --git a/MotionIntelligent/on-bright.rule.json b/MotionIntelligent/on-bright.rule.json new file mode 100644 index 0000000..03489fb --- /dev/null +++ b/MotionIntelligent/on-bright.rule.json @@ -0,0 +1,52 @@ +{ + "name": "BASENAME.on-bright", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/dark", + "operator": "eq", + "value": "true" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "not in", + "value": "T00:00:00/T05:00:00" + }, + { + "address": "/sensors/DAYLIGHT/state/daylight", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 240, + "ct": 357 + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/MotionIntelligent/on-dim-morning.rule.json b/MotionIntelligent/on-dim-morning.rule.json new file mode 100644 index 0000000..b0ca2ef --- /dev/null +++ b/MotionIntelligent/on-dim-morning.rule.json @@ -0,0 +1,52 @@ +{ + "name": "BASENAME.on-dim-morning", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/dark", + "operator": "eq", + "value": "true" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "not in", + "value": "T00:00:00/T05:00:00" + }, + { + "address": "/sensors/DAYLIGHT/state/daylight", + "operator": "eq", + "value": "false" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 13, + "ct": 1000 + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/MotionIntelligent/on-dim-night.rule.json b/MotionIntelligent/on-dim-night.rule.json new file mode 100644 index 0000000..ea9d39c --- /dev/null +++ b/MotionIntelligent/on-dim-night.rule.json @@ -0,0 +1,47 @@ +{ + "name": "BASENAME.on-dim-night", + "conditions": [ + { + "address": "/sensors/AMBIENT/state/dark", + "operator": "eq", + "value": "true" + }, + { + "address": "/groups/GROUP/state/any_on", + "operator": "eq", + "value": "false" + }, + { + "address": "/config/localtime", + "operator": "in", + "value": "T00:00:00/T05:00:00" + }, + { + "address": "/sensors/MOTION/state/presence", + "operator": "eq", + "value": "true" + }, + { + "address": "/sensors/MOTION/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true, + "bri": 13, + "ct": 1000 + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} From 4c565e59c23dd01f72656924ef16bfbc50efa00f Mon Sep 17 00:00:00 2001 From: Adrian Date: Tue, 17 Apr 2018 11:01:43 +0200 Subject: [PATCH 8/8] Add Color Control Dimmer Switch --- DimmerBed/README.md | 27 ++++++++++++++++++++++++ DimmerBed/dn-hold-ct.rule.json | 29 ++++++++++++++++++++++++++ DimmerBed/dn-hold-hue.rule.json | 29 ++++++++++++++++++++++++++ DimmerBed/dn-short.rule.json | 24 +++++++++++++++++++++ DimmerBed/mem.sensor.json | 8 +++++++ DimmerBed/off-short.rule.json | 23 ++++++++++++++++++++ DimmerBed/on-long-ct.rule.json | 37 +++++++++++++++++++++++++++++++++ DimmerBed/on-long-hue.rule.json | 36 ++++++++++++++++++++++++++++++++ DimmerBed/on-short.rule.json | 23 ++++++++++++++++++++ DimmerBed/up-hold-ct.rule.json | 29 ++++++++++++++++++++++++++ DimmerBed/up-hold-hue.rule.json | 29 ++++++++++++++++++++++++++ DimmerBed/up-short.rule.json | 24 +++++++++++++++++++++ 12 files changed, 318 insertions(+) create mode 100644 DimmerBed/README.md create mode 100644 DimmerBed/dn-hold-ct.rule.json create mode 100644 DimmerBed/dn-hold-hue.rule.json create mode 100644 DimmerBed/dn-short.rule.json create mode 100644 DimmerBed/mem.sensor.json create mode 100644 DimmerBed/off-short.rule.json create mode 100644 DimmerBed/on-long-ct.rule.json create mode 100644 DimmerBed/on-long-hue.rule.json create mode 100644 DimmerBed/on-short.rule.json create mode 100644 DimmerBed/up-hold-ct.rule.json create mode 100644 DimmerBed/up-hold-hue.rule.json create mode 100644 DimmerBed/up-short.rule.json diff --git a/DimmerBed/README.md b/DimmerBed/README.md new file mode 100644 index 0000000..598c7d6 --- /dev/null +++ b/DimmerBed/README.md @@ -0,0 +1,27 @@ +# Dimmer Switch Ruleset for Color Control + +This ruleset is a configuration that can change +color and temperature for a group of lights. +This may be the case in the bedroom. + +The on and off buttons work as expected. + +Pressing the on button longer toggles color and temperature mode. + +Pressing the brightness buttons change the brightness, +holding the brightness buttons change the color or temperature accordingly. + + +## Devices + +```sh +# IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEM/xxx/g" +``` + +Install the memory sensor and note its ID before proceding. +Use the `mem.sensor.json` file, replace the `BASENAME`, and POST it to the /api/KEY/sensors URL. + +* `BASENAME` Basename of the ruleset +* `GROUP` ID of the group to handle +* `DIMMER` ID of the dimmer switch +* `MEM` ID of the memory sensor diff --git a/DimmerBed/dn-hold-ct.rule.json b/DimmerBed/dn-hold-ct.rule.json new file mode 100644 index 0000000..18813d1 --- /dev/null +++ b/DimmerBed/dn-hold-ct.rule.json @@ -0,0 +1,29 @@ +{ + "name": "BASENAME.dn-hold-ct", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "gt", + "value": "0" + }, + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "transitiontime": 1, + "ct_inc": 24 + } + } + ] +} diff --git a/DimmerBed/dn-hold-hue.rule.json b/DimmerBed/dn-hold-hue.rule.json new file mode 100644 index 0000000..599e531 --- /dev/null +++ b/DimmerBed/dn-hold-hue.rule.json @@ -0,0 +1,29 @@ +{ + "name": "BASENAME.dn-hold-hue", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "lt", + "value": "1" + }, + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "transitiontime": 1, + "hue_inc": -10000 + } + } + ] +} diff --git a/DimmerBed/dn-short.rule.json b/DimmerBed/dn-short.rule.json new file mode 100644 index 0000000..b75fd9c --- /dev/null +++ b/DimmerBed/dn-short.rule.json @@ -0,0 +1,24 @@ +{ + "name": "BASENAME.dn-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "3002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "transitiontime": 1, + "bri_inc": -25 + } + } + ] +} diff --git a/DimmerBed/mem.sensor.json b/DimmerBed/mem.sensor.json new file mode 100644 index 0000000..a73e66e --- /dev/null +++ b/DimmerBed/mem.sensor.json @@ -0,0 +1,8 @@ +{ + "name": "BASENAME.mem", + "type": "CLIPGenericStatus", + "modelid": "MEM001", + "manufacturername": "Adrium", + "swversion": "1.0", + "uniqueid": "00:ad:10:f3:2a:9b-03" +} diff --git a/DimmerBed/off-short.rule.json b/DimmerBed/off-short.rule.json new file mode 100644 index 0000000..5cd9e3d --- /dev/null +++ b/DimmerBed/off-short.rule.json @@ -0,0 +1,23 @@ +{ + "name": "BASENAME.off-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "4002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": false + } + } + ] +} diff --git a/DimmerBed/on-long-ct.rule.json b/DimmerBed/on-long-ct.rule.json new file mode 100644 index 0000000..e7a0a81 --- /dev/null +++ b/DimmerBed/on-long-ct.rule.json @@ -0,0 +1,37 @@ +{ + "name": "BASENAME.on-long-ct", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "gt", + "value": "0" + }, + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1003" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "bri": 203, + "hue": 60000, + "sat": 240 + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 0 + } + } + ] +} diff --git a/DimmerBed/on-long-hue.rule.json b/DimmerBed/on-long-hue.rule.json new file mode 100644 index 0000000..23bbf3a --- /dev/null +++ b/DimmerBed/on-long-hue.rule.json @@ -0,0 +1,36 @@ +{ + "name": "BASENAME.on-long-hue", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "lt", + "value": "1" + }, + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1003" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "bri": 203, + "ct": 357 + } + }, + { + "address": "/sensors/MEM/state", + "method": "PUT", + "body": { + "status": 1 + } + } + ] +} diff --git a/DimmerBed/on-short.rule.json b/DimmerBed/on-short.rule.json new file mode 100644 index 0000000..4b5fb77 --- /dev/null +++ b/DimmerBed/on-short.rule.json @@ -0,0 +1,23 @@ +{ + "name": "BASENAME.on-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "1002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "on": true + } + } + ] +} diff --git a/DimmerBed/up-hold-ct.rule.json b/DimmerBed/up-hold-ct.rule.json new file mode 100644 index 0000000..25f52da --- /dev/null +++ b/DimmerBed/up-hold-ct.rule.json @@ -0,0 +1,29 @@ +{ + "name": "BASENAME.up-hold-ct", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "gt", + "value": "0" + }, + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "transitiontime": 1, + "ct_inc": -24 + } + } + ] +} diff --git a/DimmerBed/up-hold-hue.rule.json b/DimmerBed/up-hold-hue.rule.json new file mode 100644 index 0000000..42e0191 --- /dev/null +++ b/DimmerBed/up-hold-hue.rule.json @@ -0,0 +1,29 @@ +{ + "name": "BASENAME.up-hold-hue", + "conditions": [ + { + "address": "/sensors/MEM/state/status", + "operator": "lt", + "value": "1" + }, + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2001" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "transitiontime": 1, + "hue_inc": 10000 + } + } + ] +} diff --git a/DimmerBed/up-short.rule.json b/DimmerBed/up-short.rule.json new file mode 100644 index 0000000..cf2908f --- /dev/null +++ b/DimmerBed/up-short.rule.json @@ -0,0 +1,24 @@ +{ + "name": "BASENAME.up-short", + "conditions": [ + { + "address": "/sensors/DIMMER/state/buttonevent", + "operator": "eq", + "value": "2002" + }, + { + "address": "/sensors/DIMMER/state/lastupdated", + "operator": "dx" + } + ], + "actions": [ + { + "address": "/groups/GROUP/action", + "method": "PUT", + "body": { + "transitiontime": 1, + "bri_inc": 25 + } + } + ] +}