2018-04-11 07:11:06 +02:00
|
|
|
# Philips Hue Rules
|
|
|
|
|
|
|
|
Each folder contains a set of rules that can be used with Philips Hue.
|
|
|
|
|
2019-03-26 10:48:05 +01:00
|
|
|
**This is for geeks!** 😉
|
|
|
|
|
2019-03-27 14:11:25 +01:00
|
|
|
Also see [LampShade moods](LampShade).
|
|
|
|
|
2018-04-11 07:11:06 +02:00
|
|
|
## Usage
|
|
|
|
|
2019-03-26 10:48:05 +01:00
|
|
|
See the readmes inside the ruleset folders.
|
2018-04-11 07:11:06 +02:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2019-03-26 10:48:05 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
2018-04-11 07:11:06 +02:00
|
|
|
|
2019-03-26 10:48:05 +01:00
|
|
|
First, install the memory sensors and note the returned IDs:
|
2018-04-11 07:11:06 +02:00
|
|
|
|
|
|
|
```sh
|
2019-03-26 10:48:05 +01:00
|
|
|
PREFIX="http://192.168.0.150/api/1234"
|
|
|
|
|
|
|
|
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"}}]
|
2018-04-11 07:11:06 +02:00
|
|
|
|
2019-03-26 10:48:05 +01:00
|
|
|
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"}}]
|
2018-04-11 07:11:06 +02:00
|
|
|
```
|
|
|
|
|
2019-03-26 10:48:05 +01:00
|
|
|
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
|
|
|
|
```
|