Skip to content

Commit

Permalink
Updated config.json, updated flowSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilchaddha committed Dec 10, 2018
1 parent 8054724 commit b17c370
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 31 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ Ignored when mode is 7.
Brightness: Brightness value, -1 or 1 ~ 100. Ignored when mode is 7.
When this value is -1, brightness in this tuple is ignored (only color or CT change takes effect).

Params for Night Mode scene, Set `params` as a number. 1 => CT Mode, 2 => RGB Mode, 3 => HSV Mode, 4 => CF Mode.
Switching off Night Mode will reset to provided params mode. If params not provided, it will only turn off lights, will not revert color to old state.

### Demo

#### Yeelight Color Bulb
Expand Down Expand Up @@ -180,7 +183,7 @@ https://www.mi.com/us/mi-bedside-lamp/

| Config | Type | Description | Default |
|------------------------------------|---------------------|-------------------------------------------------------|--------|
| addResetSwitch | bool | Should add Reset Switch to reset all scenes. | true|
| addResetSwitch | bool | Should add Reset Switch to reset all scenes. Reset switch will not reset night_mode. | true|
| shouldTurnOff | bool | Should turn off lights after scene is over. set false if you want lights to go back to their original state | true|
| pollingInterval | number | Time in ms, for plugin to poll the light to update HomeKit characteristics | 15000|
| scenes | Array (Object) | Scenes | Required|
Expand Down
32 changes: 32 additions & 0 deletions config-advanced.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"platforms": [
{
"platform": "Yeelight-Platform",
"debug": true,
"addResetSwitch": true,
"shouldTurnOff": true,
"pollingInterval": 20000,
"scenes": [
{
"name": "Sleep Time",
"scene": "custom",
"params": "2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10",
"lights": ["0x000000000543dd83", "0x00000000052ebb4a"]
},
{
"name": "Disco Time",
"scene": "disco"
},
{
"name": "Night Mode",
"scene": "night_mode",
"params": 3,
"lights": ["0x000000000543dd83"]
}
],
"rgb": {
"0x0000000005429bb96": true
}
}
]
}
79 changes: 52 additions & 27 deletions config-sample.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,56 @@
{
"platforms": [
{
"platform": "Yeelight-Platform",
"debug": true,
"addResetSwitch": true,
"shouldTurnOff": true,
"pollingInterval": 20000,
"scenes": [
{
"name": "Sleep Time",
"scene": "custom",
"params": "2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10",
"lights": ["0x000000000543dd83", "0x00000000052ebb4a"]
},
{
"name": "Disco Time",
"scene": "disco"
},
{
"name": "Night Mode",
"scene": "night_mode",
"lights": ["0x000000000543dd83"]
}
],
"rgb": {
"0x0000000005429bb96": true
}
"platform": "Yeelight-Platform",
"addResetSwitch": true,
"shouldTurnOff": true,
"scenes": [
{
"name": "Dark Cave",
"scene": "custom",
"params": "2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10"
},
{
"name": "Break in",
"scene": "custom",
"params": "500,1,255,100,500,1,255,10"
},
{
"name": "Disco",
"scene": "disco"
},
{
"name": "Party",
"scene": "birthday_party"
},
{
"name": "Flash",
"scene": "flash_notify"
},
{
"name": "Candle Light",
"scene": "candle_flicker"
},
{
"name": "Police_1",
"scene": "police_1"
},
{
"name": "Police_2",
"scene": "police_2"
},
{
"name": "Alarm",
"scene": "alarm"
},
{
"name": "Gaming",
"scene": "gaming"
},
{
"name": "Night Mode",
"scene": "night_mode",
"lights": [
"0x000000000543dd83"
]
}
]
}
8 changes: 5 additions & 3 deletions src/accessories/flowSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ const FlowSwitch = class extends Accessory {

if (this.flowScene === 'night_mode') {
offCmd.method = 'set_power'
// TODO:
offCmd.params = ['on', 'smooth', 500, 3]
offCmd.params = ['on', 'smooth', 500]
if (this.flowParams && typeof this.flowParams === 'number' && this.flowParams > 0) {
offCmd.params.push(this.flowParams)
}
}

yeeService.sendCommand(lights, offCmd)
Expand All @@ -139,7 +141,7 @@ const FlowSwitch = class extends Accessory {

bindEvents() {
emitter.on('YeeLightTurnOff', (name) => {
if (name === this.name) return
if (name === this.name || this.flowScene === 'night_mode') return
this.switchOff()
})
}
Expand Down

0 comments on commit b17c370

Please sign in to comment.