From d4c606f619d60b49a6f27251ad809057b49cd5d2 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 00:54:18 +0200 Subject: [PATCH 1/5] Add Philips Hue rules --- FloorMotion/off.rule.json | 24 ++++++++++++++++ FloorMotion/on-bright.rule.json | 39 ++++++++++++++++++++++++++ FloorMotion/on-dim.rule.json | 45 ++++++++++++++++++++++++++++++ LivingDimmer/dn-hold.rule.json | 30 ++++++++++++++++++++ LivingDimmer/dn-short.rule.json | 30 ++++++++++++++++++++ LivingDimmer/off-short.1.rule.json | 35 +++++++++++++++++++++++ LivingDimmer/off-short.2.rule.json | 35 +++++++++++++++++++++++ LivingDimmer/on-long.rule.json | 32 +++++++++++++++++++++ LivingDimmer/on-short.1.rule.json | 35 +++++++++++++++++++++++ LivingDimmer/on-short.2.rule.json | 35 +++++++++++++++++++++++ LivingDimmer/up-hold.rule.json | 30 ++++++++++++++++++++ LivingDimmer/up-short.rule.json | 30 ++++++++++++++++++++ SimpleTap/1.rule.json | 23 +++++++++++++++ SimpleTap/2.rule.json | 25 +++++++++++++++++ SimpleTap/3.rule.json | 25 +++++++++++++++++ SimpleTap/4.rule.json | 25 +++++++++++++++++ 16 files changed, 498 insertions(+) create mode 100644 FloorMotion/off.rule.json create mode 100644 FloorMotion/on-bright.rule.json create mode 100644 FloorMotion/on-dim.rule.json create mode 100644 LivingDimmer/dn-hold.rule.json create mode 100644 LivingDimmer/dn-short.rule.json create mode 100644 LivingDimmer/off-short.1.rule.json create mode 100644 LivingDimmer/off-short.2.rule.json create mode 100644 LivingDimmer/on-long.rule.json create mode 100644 LivingDimmer/on-short.1.rule.json create mode 100644 LivingDimmer/on-short.2.rule.json create mode 100644 LivingDimmer/up-hold.rule.json create mode 100644 LivingDimmer/up-short.rule.json create mode 100644 SimpleTap/1.rule.json create mode 100644 SimpleTap/2.rule.json create mode 100644 SimpleTap/3.rule.json create mode 100644 SimpleTap/4.rule.json diff --git a/FloorMotion/off.rule.json b/FloorMotion/off.rule.json new file mode 100644 index 0000000..aabdbda --- /dev/null +++ b/FloorMotion/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/FloorMotion/on-bright.rule.json b/FloorMotion/on-bright.rule.json new file mode 100644 index 0000000..b523a19 --- /dev/null +++ b/FloorMotion/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/FloorMotion/on-dim.rule.json b/FloorMotion/on-dim.rule.json new file mode 100644 index 0000000..cb19ce9 --- /dev/null +++ b/FloorMotion/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/LivingDimmer/dn-hold.rule.json b/LivingDimmer/dn-hold.rule.json new file mode 100644 index 0000000..181017f --- /dev/null +++ b/LivingDimmer/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": 100 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "ct_inc": 100 + } + } + ] +} diff --git a/LivingDimmer/dn-short.rule.json b/LivingDimmer/dn-short.rule.json new file mode 100644 index 0000000..19e364c --- /dev/null +++ b/LivingDimmer/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": -16 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri_inc": -14 + } + } + ] +} diff --git a/LivingDimmer/off-short.1.rule.json b/LivingDimmer/off-short.1.rule.json new file mode 100644 index 0000000..046e96f --- /dev/null +++ b/LivingDimmer/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/LivingDimmer/off-short.2.rule.json b/LivingDimmer/off-short.2.rule.json new file mode 100644 index 0000000..1cf4a19 --- /dev/null +++ b/LivingDimmer/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/LivingDimmer/on-long.rule.json b/LivingDimmer/on-long.rule.json new file mode 100644 index 0000000..92826f9 --- /dev/null +++ b/LivingDimmer/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/LivingDimmer/on-short.1.rule.json b/LivingDimmer/on-short.1.rule.json new file mode 100644 index 0000000..a5ad252 --- /dev/null +++ b/LivingDimmer/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/LivingDimmer/on-short.2.rule.json b/LivingDimmer/on-short.2.rule.json new file mode 100644 index 0000000..94f709b --- /dev/null +++ b/LivingDimmer/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/LivingDimmer/up-hold.rule.json b/LivingDimmer/up-hold.rule.json new file mode 100644 index 0000000..b0dc947 --- /dev/null +++ b/LivingDimmer/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": -100 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "ct_inc": -100 + } + } + ] +} diff --git a/LivingDimmer/up-short.rule.json b/LivingDimmer/up-short.rule.json new file mode 100644 index 0000000..62a787d --- /dev/null +++ b/LivingDimmer/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": 16 + } + }, + { + "address": "/groups/GROUP2/action", + "method": "PUT", + "body": { + "bri_inc": 15 + } + } + ] +} diff --git a/SimpleTap/1.rule.json b/SimpleTap/1.rule.json new file mode 100644 index 0000000..14b38d1 --- /dev/null +++ b/SimpleTap/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/SimpleTap/2.rule.json b/SimpleTap/2.rule.json new file mode 100644 index 0000000..cefc50a --- /dev/null +++ b/SimpleTap/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/SimpleTap/3.rule.json b/SimpleTap/3.rule.json new file mode 100644 index 0000000..a7adf53 --- /dev/null +++ b/SimpleTap/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/SimpleTap/4.rule.json b/SimpleTap/4.rule.json new file mode 100644 index 0000000..15d7d89 --- /dev/null +++ b/SimpleTap/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 2e1ea0e6c6ba03e0c596b12f2a6ac43e8d0e6ba4 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 07:11:06 +0200 Subject: [PATCH 2/5] 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 396ddaa6f0ba51b5dae04bf470f79bf6c2235f46 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 11 Apr 2018 00:54:18 +0200 Subject: [PATCH 3/5] 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 4/5] 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 5/5] 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