Util

Utility class with several color and range conversion methods.

Static Methods

calculateDimDuration

(static) calculateDimDuration(duration, opts): number

Calculate a duration value for SWITCH_MULTILEVEL and SWITCH_BINARY from an input value in milliseconds. Below 127 the value is in seconds, above the value is in minutes. Hence, above 127 some rounding might occur. If a value larger than 7560 is entered it will be maxed at 254 (longest duration possible).

Parameters

Name Type Description
duration
number

Dim duration in milliseconds (0 - 7560000ms)

opts
object
maxValue
number

Use a custom max value

}

Returns

Range 0 - 254 (short to long) 1-127 = 1 second – 127 seconds 128 – 253 = 1 minute – 126 minutes 254 max

number

calculateZwaveDimDuration

(static) calculateZwaveDimDuration(duration, opts): number

deprecated since v1.0.0 - Use calculateDimDuration instead.

Parameters

Name Type Description
duration
number

Dim duration in milliseconds (0 - 7560000ms)

opts
object
maxValue
number

Use a custom max value

}

Returns

Range 0 - 254 (short to long) 1-127 = 1 second – 127 seconds 128 – 253 = 1 minute – 126 minutes 254 max

number

convertHSVToCIE

(static) convertHSVToCIE(): Util.CIE|Error

Method that converts colors from the HSV (or HSL) color space to the CIE (1931) color space.

Parameters

Type Description
Util.HSV

HSV color object

Returns

  • CIE color space object
Util.CIE | Error

convertHSVToRGB

(static) convertHSVToRGB(): Util.RGB

Method that converts colors from the HSV (or HSL) color space to the RGB color space.

Parameters

Type Description
Util.HSV

HSV color object

Returns

  • RGB color object

convertRGBToCIE

(static) convertRGBToCIE(): Util.CIE|Error

Method that converts colors from the RGB color space to the CIE (1931) color space.

Parameters

Type Description
Util.RGB

RGB color object

Returns

  • CIE color space object
Util.CIE | Error

convertRGBToHSV

(static) convertRGBToHSV(): Util.HSV

Method that converts colors from the RGB color space to the HSV color space.

Parameters

Type Description
Util.RGB

RGB color object

Returns

  • HSV color object

mapValueRange

(static) mapValueRange(inputStart, inputEnd, outputStart, outputEnd, input): number|null

Map a range of values to a different range of values.

Parameters

Name Type Description
inputStart
inputEnd
outputStart
outputEnd
input

Returns

number | null

Type Definitions

CIE

CIE

Type

  • object

Properties

Name Type Description
x
number

CIE x (small x) value, range 0 - 0.8.

y
number

CIE y (small y) value, range 0 - 0.9.

HSV

HSV

Type

  • object

Properties

Name Type Description
hue
number

Hue value, range 0 - 1.

saturation
number

Saturation value, range 0 - 1.

value
number

Value (brightness) value, range 0 - 1.

RGB

RGB

Type

  • object

Properties

Name Type Description
red
number

Red value, range 0 - 255.

green
number

Green value, range 0 - 255.

blue
number

Blue value, range 0 - 255.