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 # Dimmer Switch Ruleset for Color Control
This ruleset is a configuration that can change 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. This may be the case in the bedroom.
The on and off buttons work as expected. The on and off buttons work as expected.
Pressing the on button longer cycles temperature, color, and saturisation mode. Pressing the on button longer (check indicator light)
changes the mode of the brightness buttons:
Pressing the brightness buttons change the brightness,
holding the brightness buttons change the temperature, color, and saturisation respectively.
* Mode 1:
* Short Up/Down: brightness
* Long Up/Down: color temperature
* Mode 2:
* Short Up/Down: saturisation
* Long Up/Down: hue
## Devices ## Devices
```sh Install the memory sensor before proceding.
# IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEMORY/xxx/g"
```
Install the memory sensor and note its ID before proceding. ```sh
Use the `mem.sensor.json` file, replace the `BASENAME`, and POST it to the /api/KEY/sensors URL. IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/DIMMER/xxx/g; s/MEMORY/xxx/g"
```
* `BASENAME` Basename of the ruleset * `BASENAME` Basename of the ruleset
* `GROUP` ID of the group to handle * `GROUP` ID of the group to handle

View File

@ -16,7 +16,7 @@ holding the brightness buttons change the color temperature.
## Devices ## Devices
```sh ```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 * `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 ## Devices
Install the memory sensor before proceding.
```sh ```sh
IDS="s/BASENAME/xxx/g; s/GROUP/xxx/g; s/MOTION/xxx/g; s/AMBIENT/xxx/g; s/MEMORY/xxx/g" 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. Each folder contains a set of rules that can be used with Philips Hue.
**This is for geeks!** 😉
## Usage ## Usage
See the readme inside the folder. See the readmes inside the ruleset folders.
## Installation ## Installation
The IDs of the components should be replaced first. The JSON files are raw Hue API requests for maximum flexibility and portability.
Then the JSON files are submitted by POST to the bridge. 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 ```sh
BRIDGE="192.168.0.150" PREFIX="http://192.168.0.150/api/1234"
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 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
```