Compare commits

...

1 Commits

Author SHA1 Message Date
Adrian 6c48eeaf7f Update readmes 2019-03-26 11:01:29 +01:00
4 changed files with 88 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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"
```

View File

@ -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
```