Methods
calculateColorControlTransitionTime
(static) calculateColorControlTransitionTime(optsopt): numberCalculate a transitionTime value for the color control cluster, it takes one parameter: the
opts
object provided by a Homey.Device.registerCapabilityListener which can hold a
duration
property (in milliseconds).
Parameters
Name | Type | Description |
---|---|---|
opts
|
object
<optional> |
|
duration
|
number
<optional> |
Duration property in milliseconds (preferred over 'transition_time') |
|
Returns
transitionTime - Transition time (0 - 65535) in tenths of seconds as per Zigbee Cluster Specification section 5.2.2.3.3.4.
calculateLevelControlTransitionTime
(static) calculateLevelControlTransitionTime(optsopt): numberCalculate a transitionTime value for the level control cluster, it takes one parameter: the
opts
object provided by a Homey.Device.registerCapabilityListener which can hold a
duration
property (in milliseconds).
Parameters
Name | Type | Description |
---|---|---|
opts
|
object
<optional> |
|
duration
|
number
<optional> |
Duration property in milliseconds (preferred over 'transition_time') |
|
Returns
transitionTime - Transition time (0 - 65534) in tenths of seconds as per Zigbee Cluster Specification section 3.10.2.4.1.2.
convertCIEToHSV
(static) convertCIEToHSV(): HSVMethod that converts colors from the CIE (xyY) color space to the HSV color space. Note: do not use this for converting xy values from Zigbee devices to HSV, that seems to be inaccurate (see: https://github.com/colorjs/color-space/issues/48).
Parameters
Type | Description |
---|---|
CIExyY | xyY color object |
Returns
- HSV color object
convertHSVToCIE
(static) convertHSVToCIE(): CIExyYdebounce
(static) debounce(fn, interval, immediateopt): functionPlain JS implementation of debounce, returns a function which will be debounced when called.
Parameters
Name | Type | Description |
---|---|---|
fn
|
function | Function to debounce |
interval
|
number | Time in ms the function will be debounced. |
immediate
|
boolean
<optional> default: false
|
If true then leading debounce, false then trailing debounce. |
Returns
- Debounced function
debugZigbeeClusters
(static) debugZigbeeClusters(flag, namespaces)Note: this method has been deprecated since 1.5.0, please use debug
from
zigbee-clusters
.
Enables or disables debug logging in the zigbee-clusters
module.
Parameters
Name | Type | Description |
---|---|---|
flag
|
boolean | Set to true to enable logging |
namespaces
|
string | As specified by |
Example
const { Util } = require('homey-zigbeedriver');
Util.debugZigbeeClusters(true);
limitValue
(static) limitValue(value, min, max): numberLimit a value between min and max.
Parameters
Name | Type | Description |
---|---|---|
value
|
number | |
min
|
number | |
max
|
number |
Returns
mapTemperatureToHueSaturation
(static) mapTemperatureToHueSaturation(temperature): HSVTakes a temperature value (0-1) and returns a HSV object. It tries to mimic the light temperature capabilities some devices have for RGB devices.
Parameters
Name | Type | Description |
---|---|---|
temperature
|
number |
Returns
- Range 0 - 1
mapValueRange
(static) mapValueRange(originalRangeStart, originalRangeEnd, newRangeStart, newRangeEnd, value): numberMap a range of values to a new range.
Parameters
Name | Type | Description |
---|---|---|
originalRangeStart
|
number | |
originalRangeEnd
|
number | |
newRangeStart
|
number | |
newRangeEnd
|
number | |
value
|
number |
Returns
- Value mapped from original range to new range.
throttle
(static) throttle(fn, interval): functionPlain JS implementation of throttle, returns a function that will be throttled when called.
Parameters
Name | Type | Description |
---|---|---|
fn
|
function | Function to throttle. |
interval
|
number | Time to wait in ms. |
Returns
- Throttled function