Adrian 836b3ff8b2 | ||
---|---|---|
DimmerBed | ||
DimmerLiving | ||
LampShade | ||
MotionAllOff | ||
MotionIntelligent | ||
TapSimple | ||
README.md |
README.md
Philips Hue Rules
Each folder contains a set of rules that can be used with Philips Hue.
This is for geeks! 😉
Also see LampShade moods.
Usage
See the readmes inside the ruleset folders.
Installation
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 ruleset for two different rooms.
First, install the memory sensors and note the returned IDs:
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"}}]
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:
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.
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