Skip to content

Commit

Permalink
Add support for sliders with steps
Browse files Browse the repository at this point in the history
  • Loading branch information
grover committed Feb 21, 2018
1 parent 6ab26af commit cb38200
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
33 changes: 32 additions & 1 deletion docs/Slider.md
Expand Up @@ -45,9 +45,40 @@ A slider can accept a value between a minimum and a maximum bound. The default v
| stored | No | Set this to true if you want the slider to retain its value across restarts. The default setting for the ```slider``` type is ```false```. |
| minValue | Yes | Sets the minimum boundary of the slider. |
| maxValue | Yes | Sets the maximum boundary of the slider. |
| minStep | No | The minimum step between values of the slider. The default is 1. |

See [configuration](Configuration.md) for more advanced configuration examples.

# Restrictions
## Restrictions

The slider is not useable in the official Apple Home app as it makes use of a custom service and characteristic.

## Examples

### Slider with steps

```json
{
"bridge": {
...
},
"platforms": [
{
"platform": "AutomationSwitches",
"switches": [
{
"type": "slider",
"name": "My basic slider",
"stored": true,
"default": 5,
"minValue": 0,
"maxValue": 10,
"minStep": 2
}
]
}
]
}
```

![Preview](SliderWithSteps.png "Preview of Slider with steps")
Binary file added docs/SliderWithSteps.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions examples/slider/config.json
Expand Up @@ -16,6 +16,15 @@
"default": 5,
"minValue": 1,
"maxValue": 10
},
{
"type": "slider",
"name": "Example Slider with step 2",
"stored": true,
"default": 4,
"minValue": 0,
"maxValue": 10,
"minStep": 2
}
]
}
Expand Down
6 changes: 5 additions & 1 deletion src/SliderAccessory.js
Expand Up @@ -64,9 +64,13 @@ class SliderAccessory {

const props = {
minValue: this.config.minValue,
maxValue: this.config.maxValue,
maxValue: this.config.maxValue
};

if (this.config.minStep !== undefined) {
props.minStep = this.config.minStep;
}

this._sliderService.getCharacteristic(Characteristic.SliderValue)
.on('set', this._setValue.bind(this))
.setProps(props)
Expand Down

0 comments on commit cb38200

Please sign in to comment.