From c342f4ec46d5f76d1ca8d68c90335e476e51c0b5 Mon Sep 17 00:00:00 2001 From: Adrian Date: Tue, 26 Mar 2019 10:48:05 +0100 Subject: [PATCH 1/2] Update readmes --- DimmerBed/README.md | 23 ++++++----- DimmerLiving/README.md | 2 +- MotionIntelligent/README.md | 2 + README.md | 78 +++++++++++++++++++++++++++++++++---- 4 files changed, 87 insertions(+), 18 deletions(-) diff --git a/DimmerBed/README.md b/DimmerBed/README.md index 6df28f3..8da4048 100644 --- a/DimmerBed/README.md +++ b/DimmerBed/README.md @@ -1,25 +1,28 @@ # Dimmer Switch Ruleset for Color Control This ruleset is a configuration that can change -color and temperature for a group of lights. +color and brightness 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 cycles temperature, color, and saturisation mode. - -Pressing the brightness buttons change the brightness, -holding the brightness buttons change the temperature, color, and saturisation respectively. +Pressing the on button longer (check indicator light) +changes the mode of the brightness buttons: +* Mode 1: + * Short Up/Down: brightness + * Long Up/Down: color temperature +* Mode 2: + * Short Up/Down: saturisation + * Long Up/Down: hue ## Devices -```sh -# IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEMORY/xxx/g" -``` +Install the memory sensor before proceding. -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. +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEMORY/xxx/g" +``` * `BASENAME` Basename of the ruleset * `GROUP` ID of the group to handle diff --git a/DimmerLiving/README.md b/DimmerLiving/README.md index 8a01681..507daa9 100644 --- a/DimmerLiving/README.md +++ b/DimmerLiving/README.md @@ -16,7 +16,7 @@ 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" +IDS="s/BASENAME/xxx/g; s/GROUP1/xxx/g; s/GROUP2/xxx/g; s/DIMMER/xxx/g" ``` * `BASENAME` Basename of the ruleset diff --git a/MotionIntelligent/README.md b/MotionIntelligent/README.md index 9bb066f..de847a2 100644 --- a/MotionIntelligent/README.md +++ b/MotionIntelligent/README.md @@ -12,6 +12,8 @@ It does not switch off the lights, if they were not switched on by the sensor. ## Devices +Install the memory sensor before proceding. + ```sh IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; s/AMBIENT/xxx/g; s/MEMORY/xxx/g" ``` diff --git a/README.md b/README.md index 3033c8e..4a32602 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,80 @@ 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. +The JSON files are raw Hue API requests for maximum flexibility and portability. +Identifiers for lights and sensors are parameterized using uppercase letters. +Hence, before submitting the configuration files to the bridge, +they should be replaced as described below. -This can be done using the following snippet: +Some rulesets also require memory sensors. +The `BASENAME` and `MAC` parameters should be different for +every configuration. + +### Example + +The following snippets demonstrate the installation of the +[DimmerBed](DimmerBed) ruleset for two different rooms. + +First, install the memory sensors and note the returned IDs: ```sh -BRIDGE="192.168.0.150" -APIKEY="1234" -IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; ..." +PREFIX="http://192.168.0.150/api/1234" -for f in *.rule.json; do cat "$f" | sed "$IDS" | curl "http://$BRIDGE/api/$APIKEY/rules" -H 'Content-Type: application/json' -d @-; done +IDS="s/BASENAME/BedroomAlice/g; s/XX/00/g" + +cat DimmerBed/mem.sensor.json | sed "$IDS" | curl "$PREFIX/sensors" -H 'Content-Type: application/json' -d @- + +# Returns: [{"success":{"id":"30"}}] + +IDS="s/BASENAME/BedroomBob/g; s/XX/01/g" + +cat DimmerBed/mem.sensor.json | sed "$IDS" | curl "$PREFIX/sensors" -H 'Content-Type: application/json' -d @- + +# Returns: [{"success":{"id":"31"}}] ``` +Then, the ruleset can be installed: + +```sh +PREFIX="http://192.168.0.150/api/1234" + +IDS="s/BASENAME/BedroomAlice/g; s/GROUP/1/g; s/DIMMER/10/g; s/MEMORY/30/g" + +for f in DimmerBed/*.rule.json; do cat "$f" | sed "$IDS" | curl "$PREFIX/rules" -H 'Content-Type: application/json' -d @-; done + +IDS="s/BASENAME/BedroomBob/g; s/GROUP/2/g; s/DIMMER/11/g; s/MEMORY/31/g" + +for f in DimmerBed/*.rule.json; do cat "$f" | sed "$IDS" | curl "$PREFIX/rules" -H 'Content-Type: application/json' -d @-; done +``` + +### Advanced Example + +Note that the installation always is the same command. +This example requires `jq` for fully automated installation. + + +```sh +install_sensor() { + cat $1.sensor.json | sed "$IDS" | \ + curl "$PREFIX/sensors" -H 'Content-Type: application/json' -d @- | \ + jq -r .[0].success.id +} + +install_ruleset() { + for f in $1/*.rule.json; do cat "$f" | sed "$IDS" | curl "$PREFIX/rules" -H 'Content-Type: application/json' -d @-; done +} + +PREFIX="http://192.168.0.150/api/1234" + +IDS="s/BASENAME/BedroomAlice/g; s/XX/00/g" +mem=$(install_sensor DimmerBed/mem) + +IDS="s/BASENAME/BedroomAlice/g; s/GROUP/1/g; s/DIMMER/10/g; s/MEMORY/$mem/g" +install_ruleset DimmerBed + +IDS="s/BASENAME/BedroomBob/g; s/XX/01/g" +mem=$(install_sensor DimmerBed/mem) + +IDS="s/BASENAME/BedroomBob/g; s/GROUP/2/g; s/DIMMER/11/g; s/MEMORY/$mem/g" +install_ruleset DimmerBed +``` From 6c48eeaf7f3b319be5f0e0c0af4588e900264ee8 Mon Sep 17 00:00:00 2001 From: Adrian Date: Tue, 26 Mar 2019 10:48:05 +0100 Subject: [PATCH 2/2] Update readmes --- DimmerBed/README.md | 23 ++++++----- DimmerLiving/README.md | 2 +- MotionIntelligent/README.md | 2 + README.md | 80 +++++++++++++++++++++++++++++++++---- 4 files changed, 88 insertions(+), 19 deletions(-) diff --git a/DimmerBed/README.md b/DimmerBed/README.md index 6df28f3..8da4048 100644 --- a/DimmerBed/README.md +++ b/DimmerBed/README.md @@ -1,25 +1,28 @@ # Dimmer Switch Ruleset for Color Control This ruleset is a configuration that can change -color and temperature for a group of lights. +color and brightness 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 cycles temperature, color, and saturisation mode. - -Pressing the brightness buttons change the brightness, -holding the brightness buttons change the temperature, color, and saturisation respectively. +Pressing the on button longer (check indicator light) +changes the mode of the brightness buttons: +* Mode 1: + * Short Up/Down: brightness + * Long Up/Down: color temperature +* Mode 2: + * Short Up/Down: saturisation + * Long Up/Down: hue ## Devices -```sh -# IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEMORY/xxx/g" -``` +Install the memory sensor before proceding. -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. +```sh +IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEMORY/xxx/g" +``` * `BASENAME` Basename of the ruleset * `GROUP` ID of the group to handle diff --git a/DimmerLiving/README.md b/DimmerLiving/README.md index 8a01681..507daa9 100644 --- a/DimmerLiving/README.md +++ b/DimmerLiving/README.md @@ -16,7 +16,7 @@ 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" +IDS="s/BASENAME/xxx/g; s/GROUP1/xxx/g; s/GROUP2/xxx/g; s/DIMMER/xxx/g" ``` * `BASENAME` Basename of the ruleset diff --git a/MotionIntelligent/README.md b/MotionIntelligent/README.md index 9bb066f..de847a2 100644 --- a/MotionIntelligent/README.md +++ b/MotionIntelligent/README.md @@ -12,6 +12,8 @@ It does not switch off the lights, if they were not switched on by the sensor. ## Devices +Install the memory sensor before proceding. + ```sh IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; s/AMBIENT/xxx/g; s/MEMORY/xxx/g" ``` diff --git a/README.md b/README.md index 3033c8e..667a19b 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,86 @@ Each folder contains a set of rules that can be used with Philips Hue. +**This is for geeks!** 😉 + ## Usage -See the readme inside the folder. +See the readmes inside the ruleset folders. ## Installation -The IDs of the components should be replaced first. -Then the JSON files are submitted by POST to the bridge. +The JSON files are raw Hue API requests for maximum flexibility and portability. +Identifiers for lights and sensors are parameterized using uppercase letters. +Hence, before submitting the configuration files to the bridge, +the parameters should be replaced as described below. -This can be done using the following snippet: +Some rulesets also require memory sensors. +The `BASENAME` and `XX` parameters should be different for +every instance of the ruleset. + +### Example + +The following snippets demonstrate the installation of the +[DimmerBed](DimmerBed) ruleset for two different rooms. + +First, install the memory sensors and note the returned IDs: ```sh -BRIDGE="192.168.0.150" -APIKEY="1234" -IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; ..." +PREFIX="http://192.168.0.150/api/1234" -for f in *.rule.json; do cat "$f" | sed "$IDS" | curl "http://$BRIDGE/api/$APIKEY/rules" -H 'Content-Type: application/json' -d @-; done +IDS="s/BASENAME/BedroomAlice/g; s/XX/00/g" + +cat DimmerBed/mem.sensor.json | sed "$IDS" | curl "$PREFIX/sensors" -H 'Content-Type: application/json' -d @- + +# Returns: [{"success":{"id":"30"}}] + +IDS="s/BASENAME/BedroomBob/g; s/XX/01/g" + +cat DimmerBed/mem.sensor.json | sed "$IDS" | curl "$PREFIX/sensors" -H 'Content-Type: application/json' -d @- + +# Returns: [{"success":{"id":"31"}}] ``` +Then, the ruleset can be installed: + +```sh +PREFIX="http://192.168.0.150/api/1234" + +IDS="s/BASENAME/BedroomAlice/g; s/GROUP/1/g; s/DIMMER/10/g; s/MEMORY/30/g" + +for f in DimmerBed/*.rule.json; do cat "$f" | sed "$IDS" | curl "$PREFIX/rules" -H 'Content-Type: application/json' -d @-; done + +IDS="s/BASENAME/BedroomBob/g; s/GROUP/2/g; s/DIMMER/11/g; s/MEMORY/31/g" + +for f in DimmerBed/*.rule.json; do cat "$f" | sed "$IDS" | curl "$PREFIX/rules" -H 'Content-Type: application/json' -d @-; done +``` + +### Advanced Example + +This example requires `jq` for fully automated installation. + +```sh +install_sensor() { + cat $1.sensor.json | sed "$IDS" | \ + curl "$PREFIX/sensors" -H 'Content-Type: application/json' -d @- | \ + jq -r .[0].success.id +} + +install_ruleset() { + for f in $1/*.rule.json; do cat "$f" | sed "$IDS" | curl "$PREFIX/rules" -H 'Content-Type: application/json' -d @-; done +} + +PREFIX="http://192.168.0.150/api/1234" + +IDS="s/BASENAME/BedroomAlice/g; s/XX/00/g" +mem=$(install_sensor DimmerBed/mem) + +IDS="s/BASENAME/BedroomAlice/g; s/GROUP/1/g; s/DIMMER/10/g; s/MEMORY/$mem/g" +install_ruleset DimmerBed + +IDS="s/BASENAME/BedroomBob/g; s/XX/01/g" +mem=$(install_sensor DimmerBed/mem) + +IDS="s/BASENAME/BedroomBob/g; s/GROUP/2/g; s/DIMMER/11/g; s/MEMORY/$mem/g" +install_ruleset DimmerBed +```