node-miio 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +25 -0
- package/README.md +5 -6
- package/dist/lib/connect_to_device.d.ts +2 -2
- package/dist/lib/device.d.ts +36 -60
- package/dist/lib/device.js +81 -24
- package/dist/lib/device.js.map +1 -1
- package/dist/lib/device_info.d.ts +1 -1
- package/dist/lib/device_info.js.map +1 -1
- package/dist/lib/devices/air-monitor.d.ts +8 -2
- package/dist/lib/devices/air-monitor.js +6 -3
- package/dist/lib/devices/air-monitor.js.map +1 -1
- package/dist/lib/devices/air-purifier.d.ts +14 -6
- package/dist/lib/devices/air-purifier.js +7 -2
- package/dist/lib/devices/air-purifier.js.map +1 -1
- package/dist/lib/devices/capabilities/battery-level.d.ts +5 -22
- package/dist/lib/devices/capabilities/battery-level.js +6 -5
- package/dist/lib/devices/capabilities/battery-level.js.map +1 -1
- package/dist/lib/devices/capabilities/buzzer.d.ts +24 -30
- package/dist/lib/devices/capabilities/buzzer.js +32 -49
- package/dist/lib/devices/capabilities/buzzer.js.map +1 -1
- package/dist/lib/devices/capabilities/changeable-led-brightness.d.ts +13 -29
- package/dist/lib/devices/capabilities/changeable-led-brightness.js +16 -24
- package/dist/lib/devices/capabilities/changeable-led-brightness.js.map +1 -1
- package/dist/lib/devices/capabilities/colorable.d.ts +5 -21
- package/dist/lib/devices/capabilities/colorable.js +6 -6
- package/dist/lib/devices/capabilities/colorable.js.map +1 -1
- package/dist/lib/devices/capabilities/device_capability.d.ts +7 -0
- package/dist/lib/devices/capabilities/device_capability.js +10 -0
- package/dist/lib/devices/capabilities/device_capability.js.map +1 -0
- package/dist/lib/devices/capabilities/dimmable.d.ts +5 -21
- package/dist/lib/devices/capabilities/dimmable.js +6 -6
- package/dist/lib/devices/capabilities/dimmable.js.map +1 -1
- package/dist/lib/devices/capabilities/mode.d.ts +5 -21
- package/dist/lib/devices/capabilities/mode.js +6 -5
- package/dist/lib/devices/capabilities/mode.js.map +1 -1
- package/dist/lib/devices/capabilities/power.d.ts +5 -21
- package/dist/lib/devices/capabilities/power.js +6 -5
- package/dist/lib/devices/capabilities/power.js.map +1 -1
- package/dist/lib/devices/capabilities/sensor.d.ts +29 -15
- package/dist/lib/devices/capabilities/sensor.js +56 -41
- package/dist/lib/devices/capabilities/sensor.js.map +1 -1
- package/dist/lib/devices/capabilities/switchable-led.d.ts +13 -29
- package/dist/lib/devices/capabilities/switchable-led.js +18 -30
- package/dist/lib/devices/capabilities/switchable-led.js.map +1 -1
- package/dist/lib/devices/chuangmi.plug.v1.d.ts +10 -29
- package/dist/lib/devices/chuangmi.plug.v1.js +39 -31
- package/dist/lib/devices/chuangmi.plug.v1.js.map +1 -1
- package/dist/lib/devices/eyecare-lamp2.d.ts +29 -59
- package/dist/lib/devices/eyecare-lamp2.js +49 -38
- package/dist/lib/devices/eyecare-lamp2.js.map +1 -1
- package/dist/lib/devices/gateway/controllers.d.ts +60 -0
- package/dist/lib/devices/gateway/controllers.js +137 -0
- package/dist/lib/devices/gateway/controllers.js.map +1 -0
- package/dist/lib/devices/gateway/ctrl_ln1.d.ts +5 -7
- package/dist/lib/devices/gateway/ctrl_ln1.js +8 -33
- package/dist/lib/devices/gateway/ctrl_ln1.js.map +1 -1
- package/dist/lib/devices/gateway/ctrl_ln2.d.ts +5 -7
- package/dist/lib/devices/gateway/ctrl_ln2.js +8 -41
- package/dist/lib/devices/gateway/ctrl_ln2.js.map +1 -1
- package/dist/lib/devices/gateway/ctrl_neutral1.d.ts +5 -7
- package/dist/lib/devices/gateway/ctrl_neutral1.js +8 -33
- package/dist/lib/devices/gateway/ctrl_neutral1.js.map +1 -1
- package/dist/lib/devices/gateway/ctrl_neutral2.d.ts +5 -7
- package/dist/lib/devices/gateway/ctrl_neutral2.js +8 -41
- package/dist/lib/devices/gateway/ctrl_neutral2.js.map +1 -1
- package/dist/lib/devices/gateway/gateway-light.d.ts +27 -0
- package/dist/lib/devices/gateway/gateway-light.js +64 -0
- package/dist/lib/devices/gateway/gateway-light.js.map +1 -0
- package/dist/lib/devices/gateway/light-channel.d.ts +29 -7
- package/dist/lib/devices/gateway/light-channel.js +58 -8
- package/dist/lib/devices/gateway/light-channel.js.map +1 -1
- package/dist/lib/devices/gateway/plug.d.ts +10 -5
- package/dist/lib/devices/gateway/plug.js +16 -12
- package/dist/lib/devices/gateway/plug.js.map +1 -1
- package/dist/lib/devices/gateway/sensors.d.ts +37 -0
- package/dist/lib/devices/gateway/sensors.js +86 -0
- package/dist/lib/devices/gateway/sensors.js.map +1 -0
- package/dist/lib/devices/gateway/subdevice.d.ts +80 -60
- package/dist/lib/devices/gateway/subdevice.js +112 -127
- package/dist/lib/devices/gateway/subdevice.js.map +1 -1
- package/dist/lib/devices/gateway/subdevices.d.ts +6 -49
- package/dist/lib/devices/gateway/subdevices.js +27 -15
- package/dist/lib/devices/gateway/subdevices.js.map +1 -1
- package/dist/lib/devices/gateway/voltage.d.ts +8 -23
- package/dist/lib/devices/gateway/voltage.js +11 -12
- package/dist/lib/devices/gateway/voltage.js.map +1 -1
- package/dist/lib/devices/gateway.d.ts +61 -67
- package/dist/lib/devices/gateway.js +127 -111
- package/dist/lib/devices/gateway.js.map +1 -1
- package/dist/lib/devices/humidifier.d.ts +23 -10
- package/dist/lib/devices/humidifier.js +33 -36
- package/dist/lib/devices/humidifier.js.map +1 -1
- package/dist/lib/devices/philips-light-bulb.d.ts +14 -6
- package/dist/lib/devices/philips-light-bulb.js +23 -21
- package/dist/lib/devices/philips-light-bulb.js.map +1 -1
- package/dist/lib/devices/power-plug.d.ts +9 -28
- package/dist/lib/devices/power-plug.js +15 -8
- package/dist/lib/devices/power-plug.js.map +1 -1
- package/dist/lib/devices/power-strip.d.ts +11 -5
- package/dist/lib/devices/power-strip.js +17 -9
- package/dist/lib/devices/power-strip.js.map +1 -1
- package/dist/lib/devices/vacuums/dreamevacuum.d.ts +3 -24
- package/dist/lib/devices/vacuums/dreamevacuum.js +4 -5
- package/dist/lib/devices/vacuums/dreamevacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/miot-vacuum.d.ts +3 -27
- package/dist/lib/devices/vacuums/miot-vacuum.js +3 -6
- package/dist/lib/devices/vacuums/miot-vacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum.d.ts +6 -26
- package/dist/lib/devices/vacuums/vacuum.js +13 -8
- package/dist/lib/devices/vacuums/vacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum_device.d.ts +1 -1
- package/dist/lib/devices/vacuums/vacuum_device.js +3 -3
- package/dist/lib/devices/vacuums/vacuum_device.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum_errors.d.ts +4 -3
- package/dist/lib/devices/vacuums/vacuum_errors.js +5 -7
- package/dist/lib/devices/vacuums/vacuum_errors.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum_thing.d.ts +13 -0
- package/dist/lib/devices/vacuums/vacuum_thing.js +19 -0
- package/dist/lib/devices/vacuums/vacuum_thing.js.map +1 -0
- package/dist/lib/devices/vacuums/viomivacuum.d.ts +3 -24
- package/dist/lib/devices/vacuums/viomivacuum.js +4 -5
- package/dist/lib/devices/vacuums/viomivacuum.js.map +1 -1
- package/dist/lib/devices/yeelight.color.d.ts +13 -2
- package/dist/lib/devices/yeelight.color.js +101 -3
- package/dist/lib/devices/yeelight.color.js.map +1 -1
- package/dist/lib/devices/yeelight.d.ts +36 -154
- package/dist/lib/devices/yeelight.js +36 -144
- package/dist/lib/devices/yeelight.js.map +1 -1
- package/dist/lib/devices/yeelight.mono.d.ts +13 -2
- package/dist/lib/devices/yeelight.mono.js +34 -3
- package/dist/lib/devices/yeelight.mono.js.map +1 -1
- package/dist/lib/discovery.js +2 -2
- package/dist/lib/discovery.js.map +1 -1
- package/dist/lib/events.d.ts +1 -1
- package/dist/lib/index.d.ts +0 -5
- package/dist/lib/models.d.ts +26 -239
- package/dist/lib/models.js +26 -29
- package/dist/lib/models.js.map +1 -1
- package/dist/lib/protocol.d.ts +10 -2
- package/dist/lib/things/capabilities/actions.d.ts +21 -0
- package/dist/lib/things/capabilities/actions.js +36 -0
- package/dist/lib/things/capabilities/actions.js.map +1 -0
- package/dist/lib/things/capabilities/battery-level.d.ts +13 -0
- package/dist/lib/things/capabilities/battery-level.js +26 -0
- package/dist/lib/things/capabilities/battery-level.js.map +1 -0
- package/dist/lib/things/capabilities/charging.d.ts +20 -0
- package/dist/lib/things/capabilities/charging.js +40 -0
- package/dist/lib/things/capabilities/charging.js.map +1 -0
- package/dist/lib/things/capabilities/children.d.ts +78 -0
- package/dist/lib/things/capabilities/children.js +173 -0
- package/dist/lib/things/capabilities/children.js.map +1 -0
- package/dist/lib/things/capabilities/cleaning.d.ts +40 -0
- package/dist/lib/things/capabilities/cleaning.js +85 -0
- package/dist/lib/things/capabilities/cleaning.js.map +1 -0
- package/dist/lib/things/capabilities/error-state.d.ts +15 -0
- package/dist/lib/things/capabilities/error-state.js +33 -0
- package/dist/lib/things/capabilities/error-state.js.map +1 -0
- package/dist/lib/things/capabilities/fan-speed.d.ts +36 -0
- package/dist/lib/things/capabilities/fan-speed.js +59 -0
- package/dist/lib/things/capabilities/fan-speed.js.map +1 -0
- package/dist/lib/things/capabilities/index.d.ts +14 -0
- package/dist/lib/things/capabilities/index.js +31 -0
- package/dist/lib/things/capabilities/index.js.map +1 -0
- package/dist/lib/things/capabilities/lights/brightness.d.ts +44 -0
- package/dist/lib/things/capabilities/lights/brightness.js +87 -0
- package/dist/lib/things/capabilities/lights/brightness.js.map +1 -0
- package/dist/lib/things/capabilities/lights/color-temperature.d.ts +21 -0
- package/dist/lib/things/capabilities/lights/color-temperature.js +43 -0
- package/dist/lib/things/capabilities/lights/color-temperature.js.map +1 -0
- package/dist/lib/things/capabilities/lights/colorable.d.ts +37 -0
- package/dist/lib/things/capabilities/lights/colorable.js +57 -0
- package/dist/lib/things/capabilities/lights/colorable.js.map +1 -0
- package/dist/lib/things/capabilities/lights/fading.d.ts +13 -0
- package/dist/lib/things/capabilities/lights/fading.js +23 -0
- package/dist/lib/things/capabilities/lights/fading.js.map +1 -0
- package/dist/lib/things/capabilities/lights/index.d.ts +5 -0
- package/dist/lib/things/capabilities/lights/index.js +22 -0
- package/dist/lib/things/capabilities/lights/index.js.map +1 -0
- package/dist/lib/things/capabilities/lights/light.d.ts +25 -0
- package/dist/lib/things/capabilities/lights/light.js +23 -0
- package/dist/lib/things/capabilities/lights/light.js.map +1 -0
- package/dist/lib/things/capabilities/mode.d.ts +45 -0
- package/dist/lib/things/capabilities/mode.js +75 -0
- package/dist/lib/things/capabilities/mode.js.map +1 -0
- package/dist/lib/things/capabilities/nameable.d.ts +18 -0
- package/dist/lib/things/capabilities/nameable.js +28 -0
- package/dist/lib/things/capabilities/nameable.js.map +1 -0
- package/dist/lib/things/capabilities/power.d.ts +40 -0
- package/dist/lib/things/capabilities/power.js +68 -0
- package/dist/lib/things/capabilities/power.js.map +1 -0
- package/dist/lib/things/capabilities/sensors.d.ts +91 -0
- package/dist/lib/things/capabilities/sensors.js +198 -0
- package/dist/lib/things/capabilities/sensors.js.map +1 -0
- package/dist/lib/things/capabilities/target-humidity.d.ts +36 -0
- package/dist/lib/things/capabilities/target-humidity.js +59 -0
- package/dist/lib/things/capabilities/target-humidity.js.map +1 -0
- package/dist/lib/things/capability.d.ts +24 -0
- package/dist/lib/things/capability.js +21 -0
- package/dist/lib/things/capability.js.map +1 -0
- package/dist/lib/things/color.d.ts +66 -0
- package/dist/lib/things/color.js +303 -0
- package/dist/lib/things/color.js.map +1 -0
- package/dist/lib/things/compose.d.ts +25 -0
- package/dist/lib/things/compose.js +105 -0
- package/dist/lib/things/compose.js.map +1 -0
- package/dist/lib/things/index.d.ts +14 -0
- package/dist/lib/things/index.js +39 -0
- package/dist/lib/things/index.js.map +1 -0
- package/dist/lib/things/registry.d.ts +19 -0
- package/dist/lib/things/registry.js +18 -0
- package/dist/lib/things/registry.js.map +1 -0
- package/dist/lib/things/thing.d.ts +110 -0
- package/dist/lib/things/thing.js +325 -0
- package/dist/lib/things/thing.js.map +1 -0
- package/dist/lib/things/values.d.ts +123 -0
- package/dist/lib/things/values.js +258 -0
- package/dist/lib/things/values.js.map +1 -0
- package/docs/devices/vacuum.md +1 -2
- package/package.json +4 -3
- package/snapshots/vacuum-specs.json.gz +0 -0
- package/dist/lib/devices/gateway/86sw1.d.ts +0 -7
- package/dist/lib/devices/gateway/86sw1.js +0 -20
- package/dist/lib/devices/gateway/86sw1.js.map +0 -1
- package/dist/lib/devices/gateway/86sw2.d.ts +0 -7
- package/dist/lib/devices/gateway/86sw2.js +0 -36
- package/dist/lib/devices/gateway/86sw2.js.map +0 -1
- package/dist/lib/devices/gateway/cube.d.ts +0 -6
- package/dist/lib/devices/gateway/cube.js +0 -49
- package/dist/lib/devices/gateway/cube.js.map +0 -1
- package/dist/lib/devices/gateway/light-mixin.d.ts +0 -2
- package/dist/lib/devices/gateway/light-mixin.js +0 -59
- package/dist/lib/devices/gateway/light-mixin.js.map +0 -1
- package/dist/lib/devices/gateway/magnet.d.ts +0 -6
- package/dist/lib/devices/gateway/magnet.js +0 -23
- package/dist/lib/devices/gateway/magnet.js.map +0 -1
- package/dist/lib/devices/gateway/magnet2.d.ts +0 -5
- package/dist/lib/devices/gateway/magnet2.js +0 -9
- package/dist/lib/devices/gateway/magnet2.js.map +0 -1
- package/dist/lib/devices/gateway/motion.d.ts +0 -6
- package/dist/lib/devices/gateway/motion.js +0 -21
- package/dist/lib/devices/gateway/motion.js.map +0 -1
- package/dist/lib/devices/gateway/motion2.d.ts +0 -6
- package/dist/lib/devices/gateway/motion2.js +0 -25
- package/dist/lib/devices/gateway/motion2.js.map +0 -1
- package/dist/lib/devices/gateway/sensor_ht.d.ts +0 -5
- package/dist/lib/devices/gateway/sensor_ht.js +0 -13
- package/dist/lib/devices/gateway/sensor_ht.js.map +0 -1
- package/dist/lib/devices/gateway/switch.d.ts +0 -6
- package/dist/lib/devices/gateway/switch.js +0 -24
- package/dist/lib/devices/gateway/switch.js.map +0 -1
- package/dist/lib/devices/gateway/switch2.d.ts +0 -6
- package/dist/lib/devices/gateway/switch2.js +0 -19
- package/dist/lib/devices/gateway/switch2.js.map +0 -1
- package/dist/lib/devices/gateway/weather.d.ts +0 -5
- package/dist/lib/devices/gateway/weather.js +0 -16
- package/dist/lib/devices/gateway/weather.js.map +0 -1
- package/dist/types/abstract-things/climate/index.d.ts +0 -431
- package/dist/types/abstract-things/electricals/index.d.ts +0 -5
- package/dist/types/abstract-things/index.d.ts +0 -206
- package/dist/types/abstract-things/lights/index.d.ts +0 -14
- package/dist/types/abstract-things/values/index.d.ts +0 -12
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Colorable } from "../things/capabilities/lights/colorable";
|
|
2
|
+
import { ColorTemperature, ColorFull } from "../things/capabilities/lights/color-temperature";
|
|
3
|
+
import { type LightChangeOptions } from "../things/capabilities/lights/light";
|
|
4
|
+
import { type Color } from "../things/color";
|
|
5
|
+
import { MiioApi } from "../device";
|
|
6
|
+
import { Yeelight } from "./yeelight";
|
|
7
|
+
declare const YeelightColor_base: typeof Yeelight & (abstract new (...args: any[]) => import("../things/compose").Composed<typeof Yeelight, [typeof Colorable, typeof ColorTemperature, typeof ColorFull]>);
|
|
8
|
+
/** Yeelights with full colour (RGB, HSV) and colour temperature */
|
|
9
|
+
export declare class YeelightColor extends YeelightColor_base {
|
|
10
|
+
constructor(handle: ConstructorParameters<typeof MiioApi>[0]);
|
|
11
|
+
propertyUpdated(key: string, value: unknown, oldValue?: unknown): void;
|
|
12
|
+
changeColor(value: Color, options: LightChangeOptions): Promise<null>;
|
|
3
13
|
}
|
|
14
|
+
export {};
|
|
@@ -1,5 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YeelightColor = void 0;
|
|
4
|
+
const compose_1 = require("../things/compose");
|
|
5
|
+
const colorable_1 = require("../things/capabilities/lights/colorable");
|
|
6
|
+
const color_temperature_1 = require("../things/capabilities/lights/color-temperature");
|
|
7
|
+
const color_1 = require("../things/color");
|
|
8
|
+
const device_1 = require("../device");
|
|
9
|
+
const yeelight_1 = require("./yeelight");
|
|
10
|
+
/** The properties that make up the current colour */
|
|
11
|
+
const COLOR_PROPERTIES = [
|
|
12
|
+
"colorTemperature",
|
|
13
|
+
"colorMode",
|
|
14
|
+
"colorRGB",
|
|
15
|
+
"colorHue",
|
|
16
|
+
"colorSaturation",
|
|
17
|
+
"brightness",
|
|
18
|
+
];
|
|
19
|
+
/** Yeelights with full colour (RGB, HSV) and colour temperature */
|
|
20
|
+
class YeelightColor extends (0, compose_1.compose)(yeelight_1.Yeelight, colorable_1.Colorable, color_temperature_1.ColorTemperature, color_temperature_1.ColorFull) {
|
|
21
|
+
constructor(handle) {
|
|
22
|
+
super(handle);
|
|
23
|
+
// Color temperature
|
|
24
|
+
this.defineProperty("ct", {
|
|
25
|
+
name: "colorTemperature",
|
|
26
|
+
mapper: (v) => parseInt(v, 10),
|
|
27
|
+
});
|
|
28
|
+
this.defineProperty("rgb", {
|
|
29
|
+
name: "colorRGB",
|
|
30
|
+
mapper: (v) => {
|
|
31
|
+
const rgb = parseInt(v, 10);
|
|
32
|
+
return {
|
|
33
|
+
red: (rgb >> 16) & 0xff,
|
|
34
|
+
green: (rgb >> 8) & 0xff,
|
|
35
|
+
blue: rgb & 0xff,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
this.defineProperty("hue", {
|
|
40
|
+
name: "colorHue",
|
|
41
|
+
mapper: (v) => parseInt(v, 10),
|
|
42
|
+
});
|
|
43
|
+
this.defineProperty("sat", {
|
|
44
|
+
name: "colorSaturation",
|
|
45
|
+
mapper: (v) => parseInt(v, 10),
|
|
46
|
+
});
|
|
47
|
+
// TODO: Do all Yeelights use the same color range?
|
|
48
|
+
this.updateColorTemperatureRange(yeelight_1.TEMPERATURE_RANGE.min, yeelight_1.TEMPERATURE_RANGE.max);
|
|
49
|
+
}
|
|
50
|
+
propertyUpdated(key, value, oldValue) {
|
|
51
|
+
if (COLOR_PROPERTIES.includes(key)) {
|
|
52
|
+
let currentColor = this.getState("color");
|
|
53
|
+
switch (this.property("colorMode")) {
|
|
54
|
+
case "colorTemperature":
|
|
55
|
+
// Currently using color temperature mode, parse as temperature
|
|
56
|
+
currentColor = color_1.color.temperature(this.property("colorTemperature"));
|
|
57
|
+
break;
|
|
58
|
+
case "rgb": {
|
|
59
|
+
// Using RGB, parse if we have gotten the RGB value
|
|
60
|
+
const rgb = this.property("colorRGB");
|
|
61
|
+
if (rgb) {
|
|
62
|
+
currentColor = color_1.color.rgb(rgb.red, rgb.green, rgb.blue);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case "hsv": {
|
|
67
|
+
// Using HSV, parse the hue, saturation and get the brightness to set color
|
|
68
|
+
const hue = this.property("colorHue");
|
|
69
|
+
const saturation = this.property("colorSaturation");
|
|
70
|
+
if (typeof hue !== "undefined" && typeof saturation !== "undefined") {
|
|
71
|
+
currentColor = color_1.color.hsv(hue, saturation, this.property("brightness"));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (currentColor) {
|
|
76
|
+
this.updateColor(currentColor);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
super.propertyUpdated(key, value, oldValue);
|
|
80
|
+
}
|
|
81
|
+
changeColor(value, options) {
|
|
82
|
+
if (value.is("temperature")) {
|
|
83
|
+
// The user has request a color via temperature
|
|
84
|
+
const temperature = (0, yeelight_1.clampTemperature)(value.temperature.kelvins);
|
|
85
|
+
return this.call("set_ct_abx", yeelight_1.Yeelight.withEffect(temperature, options.duration), {
|
|
86
|
+
refresh: ["colorTemperature", "colorMode"],
|
|
87
|
+
}).then(device_1.MiioApi.checkOk);
|
|
88
|
+
}
|
|
89
|
+
else if (value.is("hsl") || value.is("hsv")) {
|
|
90
|
+
// The user has requested hue and saturation
|
|
91
|
+
return this.call("set_hsv", yeelight_1.Yeelight.withEffect([value.hue, value.saturation], options.duration), {
|
|
92
|
+
refresh: ["colorHue", "colorSaturation", "colorMode"],
|
|
93
|
+
}).then(device_1.MiioApi.checkOk);
|
|
94
|
+
}
|
|
95
|
+
// Fallback to applying via RGB
|
|
96
|
+
const rgb = value.rgb;
|
|
97
|
+
return this.call("set_rgb", yeelight_1.Yeelight.withEffect(rgb.red * 65536 + rgb.green * 256 + rgb.blue, options.duration), {
|
|
98
|
+
refresh: ["colorRGB", "colorMode"],
|
|
99
|
+
}).then(device_1.MiioApi.checkOk);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.YeelightColor = YeelightColor;
|
|
5
103
|
//# sourceMappingURL=yeelight.color.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yeelight.color.js","sourceRoot":"","sources":["../../../src/lib/devices/yeelight.color.
|
|
1
|
+
{"version":3,"file":"yeelight.color.js","sourceRoot":"","sources":["../../../src/lib/devices/yeelight.color.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,uEAAoE;AACpE,uFAGyD;AAEzD,2CAAoD;AACpD,sCAAoC;AAEpC,yCAA2E;AAQ3E,qDAAqD;AACrD,MAAM,gBAAgB,GAAG;IACvB,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,UAAU;IACV,iBAAiB;IACjB,YAAY;CACb,CAAC;AAEF,mEAAmE;AACnE,MAAa,aAAc,SAAQ,IAAA,iBAAO,EACxC,mBAAQ,EACR,qBAAS,EACT,oCAAgB,EAChB,6BAAS,CACV;IACC,YAAY,MAAgD;QAC1D,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,oBAAoB;QACpB,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;YACxB,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,CAAC,CAAS,EAAE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|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
extendWith<T>(...mixins: T[]): T & Thing;
|
|
20
|
-
readonly miioModel?: string;
|
|
21
|
-
readonly _properties: Record<string, unknown>;
|
|
22
|
-
readonly _propertiesToMonitor: string[];
|
|
23
|
-
readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
|
|
24
|
-
readonly _reversePropertyDefinitions: Record<string, string>;
|
|
25
|
-
readonly management: import("../management").DeviceManagement;
|
|
26
|
-
debugFn?: import("../logger").DebugFn;
|
|
27
|
-
readonly handle: import("../management").DeviceHandle;
|
|
28
|
-
miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
|
|
29
|
-
call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
|
|
30
|
-
refresh?: string[];
|
|
31
|
-
refreshDelay?: number;
|
|
32
|
-
sid?: number;
|
|
33
|
-
retries?: number;
|
|
34
|
-
}): Promise<Response>;
|
|
35
|
-
defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
|
|
36
|
-
_pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
|
|
37
|
-
poll(_isInitial?: boolean): Promise<void>;
|
|
38
|
-
_loadProperties(properties?: string[]): Promise<void>;
|
|
39
|
-
setProperty(key: string, value: unknown): void;
|
|
40
|
-
setRawProperty(name: string, value: unknown): void;
|
|
41
|
-
property<T>(key: string): T;
|
|
42
|
-
get connected(): boolean;
|
|
43
|
-
get properties(): Record<string, unknown>;
|
|
44
|
-
miioProperties(): Record<string, unknown>;
|
|
45
|
-
getProperties(props: string[]): {};
|
|
46
|
-
loadProperties(props: string[]): Promise<{}>;
|
|
47
|
-
updatePollDuration(duration: number): void;
|
|
48
|
-
updateMaxPollFailures(failures: number): void;
|
|
49
|
-
updateColor(value: import("abstract-things/values").Color): void;
|
|
50
|
-
} & Thing;
|
|
51
|
-
export const ColorFull: new (...args: any[]) => {
|
|
52
|
-
propertyUpdated(key: any, value: any): void;
|
|
53
|
-
changeColor(color: any, options: any): Promise<null>;
|
|
54
|
-
id: string | null;
|
|
55
|
-
metadata: Record<string, unknown> & {
|
|
56
|
-
types: string[];
|
|
57
|
-
capabilities: string[];
|
|
58
|
-
addCapabilities(...capabilities: string[]): void;
|
|
59
|
-
};
|
|
60
|
-
init(): Promise</*elided*/ any | undefined>;
|
|
61
|
-
initCallback(): Promise<void>;
|
|
62
|
-
destroy(): Promise<void>;
|
|
63
|
-
destroyCallback: (() => Promise<void>) & (() => Promise<void>);
|
|
64
|
-
debug: ((...parts: unknown[]) => void) & ((...msgs: unknown[]) => void);
|
|
65
|
-
matches(...tags: string[]): boolean;
|
|
66
|
-
emitEvent(event: string, data?: unknown, options?: unknown): void;
|
|
67
|
-
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
68
|
-
off(event: string, listener: (...args: never[]) => void): unknown;
|
|
69
|
-
extendWith<T>(...mixins: T[]): T & Thing;
|
|
70
|
-
readonly miioModel?: string;
|
|
71
|
-
readonly _properties: Record<string, unknown>;
|
|
72
|
-
readonly _propertiesToMonitor: string[];
|
|
73
|
-
readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
|
|
74
|
-
readonly _reversePropertyDefinitions: Record<string, string>;
|
|
75
|
-
readonly management: import("../management").DeviceManagement;
|
|
76
|
-
debugFn?: import("../logger").DebugFn;
|
|
77
|
-
readonly handle: import("../management").DeviceHandle;
|
|
78
|
-
miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
|
|
79
|
-
call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
|
|
80
|
-
refresh?: string[];
|
|
81
|
-
refreshDelay?: number;
|
|
82
|
-
sid?: number;
|
|
83
|
-
retries?: number;
|
|
84
|
-
}): Promise<Response>;
|
|
85
|
-
defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
|
|
86
|
-
_pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
|
|
87
|
-
poll(_isInitial?: boolean): Promise<void>;
|
|
88
|
-
_loadProperties(properties?: string[]): Promise<void>;
|
|
89
|
-
setProperty(key: string, value: unknown): void;
|
|
90
|
-
setRawProperty(name: string, value: unknown): void;
|
|
91
|
-
property<T>(key: string): T;
|
|
92
|
-
get connected(): boolean;
|
|
93
|
-
get properties(): Record<string, unknown>;
|
|
94
|
-
miioProperties(): Record<string, unknown>;
|
|
95
|
-
getProperties(props: string[]): {};
|
|
96
|
-
loadProperties(props: string[]): Promise<{}>;
|
|
97
|
-
updatePollDuration(duration: number): void;
|
|
98
|
-
updateMaxPollFailures(failures: number): void;
|
|
99
|
-
updateColor(value: import("abstract-things/values").Color): void;
|
|
100
|
-
} & Thing;
|
|
101
|
-
export const Yeelight: new (options?: any) => {
|
|
102
|
-
propertyUpdated(key: any, value: any): void;
|
|
103
|
-
changePower(power: any): Promise<null>;
|
|
1
|
+
import { MiioApi } from "../device";
|
|
2
|
+
import { Nameable } from "../things/capabilities/nameable";
|
|
3
|
+
import { Light, type BrightnessChangeOptions } from "../things/capabilities/lights/light";
|
|
4
|
+
import { Fading } from "../things/capabilities/lights/fading";
|
|
5
|
+
import type { Duration } from "../things/values";
|
|
6
|
+
import { Power } from "./capabilities/power";
|
|
7
|
+
import { Dimmable } from "./capabilities/dimmable";
|
|
8
|
+
/** The colour temperatures supported by the Yeelights, in kelvins */
|
|
9
|
+
export declare const TEMPERATURE_RANGE: {
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
};
|
|
13
|
+
declare const Yeelight_base: typeof MiioApi & (abstract new (...args: any[]) => import("../things/compose").Composed<typeof MiioApi, [typeof Light, typeof Fading, typeof Power, typeof Dimmable, typeof Nameable]>);
|
|
14
|
+
export declare class Yeelight extends Yeelight_base {
|
|
15
|
+
static get type(): string;
|
|
16
|
+
constructor(handle: ConstructorParameters<typeof MiioApi>[0]);
|
|
17
|
+
propertyUpdated(key: string, value: unknown, oldValue?: unknown): void;
|
|
18
|
+
changePower(power: boolean): Promise<null>;
|
|
104
19
|
/**
|
|
105
20
|
* Make the current state the default state, meaning the light will restore
|
|
106
21
|
* to this state after power has been cut.
|
|
107
22
|
*/
|
|
108
23
|
setDefault(): Promise<null>;
|
|
109
|
-
changeBrightness(brightness:
|
|
110
|
-
changeName(name:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
readonly miioModel?: string;
|
|
128
|
-
readonly _properties: Record<string, unknown>;
|
|
129
|
-
readonly _propertiesToMonitor: string[];
|
|
130
|
-
readonly _propertyDefinitions: Record<string, import("../device").PersistedPropertyDefinition<never, never>>;
|
|
131
|
-
readonly _reversePropertyDefinitions: Record<string, string>;
|
|
132
|
-
readonly management: import("../management").DeviceManagement;
|
|
133
|
-
debugFn?: import("../logger").DebugFn;
|
|
134
|
-
readonly handle: import("../management").DeviceHandle;
|
|
135
|
-
miioCall<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params): Promise<Response>;
|
|
136
|
-
call<Method extends keyof import("../protocol").Protocol, Params extends import("../protocol").Protocol[Method]["params"], Response extends import("../protocol").Protocol[Method]["response"]>(method: Method, args: Params, options?: {
|
|
137
|
-
refresh?: string[];
|
|
138
|
-
refreshDelay?: number;
|
|
139
|
-
sid?: number;
|
|
140
|
-
retries?: number;
|
|
141
|
-
}): Promise<Response>;
|
|
142
|
-
defineProperty<T, V>(name: string, def?: import("../device").Mapper<T, V> | import("../device").PropertyDefinition<T, V> | undefined): void;
|
|
143
|
-
_pushProperty(result: Record<string, unknown>, name: string, value: unknown): void;
|
|
144
|
-
poll(_isInitial?: boolean): Promise<void>;
|
|
145
|
-
_loadProperties(properties?: string[]): Promise<void>;
|
|
146
|
-
setProperty(key: string, value: unknown): void;
|
|
147
|
-
setRawProperty(name: string, value: unknown): void;
|
|
148
|
-
property<T>(key: string): T;
|
|
149
|
-
get connected(): boolean;
|
|
150
|
-
get properties(): Record<string, unknown>;
|
|
151
|
-
miioProperties(): Record<string, unknown>;
|
|
152
|
-
getProperties(props: string[]): {};
|
|
153
|
-
loadProperties(props: string[]): Promise<{}>;
|
|
154
|
-
updatePollDuration(duration: number): void;
|
|
155
|
-
updateMaxPollFailures(failures: number): void;
|
|
156
|
-
updatePower<T>(value: T): void;
|
|
157
|
-
updateBrightness(value: number): void;
|
|
158
|
-
} & Thing;
|
|
159
|
-
import { Thing } from "abstract-things";
|
|
24
|
+
changeBrightness(brightness: number, options: BrightnessChangeOptions): any;
|
|
25
|
+
changeName(name: string): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Helper method to combine an argument with effect information.
|
|
28
|
+
*
|
|
29
|
+
* @param arg The argument(s) of the command
|
|
30
|
+
* @param duration The duration of the effect in ms
|
|
31
|
+
*/
|
|
32
|
+
static withEffect(arg: unknown, duration?: Duration): unknown[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Clamps a colour temperature to the range of the Yeelights.
|
|
36
|
+
*
|
|
37
|
+
* @param kelvins The temperature
|
|
38
|
+
* @returns The clamped temperature
|
|
39
|
+
*/
|
|
40
|
+
export declare const clampTemperature: (kelvins: number) => number;
|
|
41
|
+
export {};
|
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clampTemperature = exports.Yeelight = exports.TEMPERATURE_RANGE = void 0;
|
|
4
|
+
const device_1 = require("../device");
|
|
5
|
+
const compose_1 = require("../things/compose");
|
|
6
|
+
const nameable_1 = require("../things/capabilities/nameable");
|
|
7
|
+
const light_1 = require("../things/capabilities/lights/light");
|
|
8
|
+
const fading_1 = require("../things/capabilities/lights/fading");
|
|
9
|
+
const power_1 = require("./capabilities/power");
|
|
10
|
+
const dimmable_1 = require("./capabilities/dimmable");
|
|
8
11
|
const DEFAULT_EFFECT = "smooth";
|
|
9
12
|
const DEFAULT_DURATION = 500;
|
|
10
|
-
|
|
13
|
+
/** The colour temperatures supported by the Yeelights, in kelvins */
|
|
14
|
+
exports.TEMPERATURE_RANGE = { min: 2700, max: 6500 };
|
|
15
|
+
class Yeelight extends (0, compose_1.compose)(device_1.MiioApi, light_1.Light, fading_1.Fading, power_1.Power, dimmable_1.Dimmable, nameable_1.Nameable) {
|
|
11
16
|
static get type() {
|
|
12
17
|
return "miio:yeelight";
|
|
13
18
|
}
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
19
|
+
constructor(handle) {
|
|
20
|
+
super(handle);
|
|
16
21
|
this.defineProperty("power", {
|
|
17
22
|
name: "power",
|
|
18
23
|
mapper: (v) => v === "on",
|
|
19
24
|
});
|
|
20
25
|
this.defineProperty("bright", {
|
|
21
26
|
name: "brightness",
|
|
22
|
-
mapper: parseInt,
|
|
27
|
+
mapper: (v) => parseInt(v, 10),
|
|
23
28
|
});
|
|
24
29
|
// Used for scheduling turning off after a while
|
|
25
30
|
this.defineProperty("delayoff", {
|
|
26
31
|
name: "offDelay",
|
|
27
|
-
mapper: parseInt,
|
|
32
|
+
mapper: (v) => parseInt(v, 10),
|
|
28
33
|
});
|
|
29
34
|
// Query for the color mode
|
|
30
35
|
this.defineProperty("color_mode", {
|
|
31
36
|
name: "colorMode",
|
|
32
37
|
mapper: (v) => {
|
|
33
|
-
|
|
34
|
-
switch (v) {
|
|
38
|
+
switch (parseInt(v, 10)) {
|
|
35
39
|
case 1:
|
|
36
40
|
return "rgb";
|
|
37
41
|
case 2:
|
|
@@ -49,24 +53,24 @@ const Yeelight = Thing.type((Parent) => class Yeelight extends Parent.with(MiioA
|
|
|
49
53
|
*/
|
|
50
54
|
this.updateMaxChangeTime("30s");
|
|
51
55
|
}
|
|
52
|
-
propertyUpdated(key, value) {
|
|
56
|
+
propertyUpdated(key, value, oldValue) {
|
|
53
57
|
if (key === "name") {
|
|
54
58
|
this.metadata.name = value;
|
|
55
59
|
}
|
|
56
|
-
super.propertyUpdated(key, value);
|
|
60
|
+
super.propertyUpdated(key, value, oldValue);
|
|
57
61
|
}
|
|
58
62
|
changePower(power) {
|
|
59
63
|
// TODO: Support for duration
|
|
60
64
|
return this.call("set_power", Yeelight.withEffect(power ? "on" : "off"), {
|
|
61
65
|
refresh: ["power"],
|
|
62
|
-
}).then(MiioApi.checkOk);
|
|
66
|
+
}).then(device_1.MiioApi.checkOk);
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* Make the current state the default state, meaning the light will restore
|
|
66
70
|
* to this state after power has been cut.
|
|
67
71
|
*/
|
|
68
72
|
setDefault() {
|
|
69
|
-
return this.call("set_default").then(MiioApi.checkOk);
|
|
73
|
+
return this.call("set_default", []).then(device_1.MiioApi.checkOk);
|
|
70
74
|
}
|
|
71
75
|
changeBrightness(brightness, options) {
|
|
72
76
|
if (brightness <= 0) {
|
|
@@ -74,7 +78,7 @@ const Yeelight = Thing.type((Parent) => class Yeelight extends Parent.with(MiioA
|
|
|
74
78
|
}
|
|
75
79
|
else {
|
|
76
80
|
let promise;
|
|
77
|
-
if (options.powerOn && this.power
|
|
81
|
+
if (options.powerOn && this.getState("power") === false) {
|
|
78
82
|
// Currently not turned on
|
|
79
83
|
promise = this.changePower(true);
|
|
80
84
|
}
|
|
@@ -85,19 +89,19 @@ const Yeelight = Thing.type((Parent) => class Yeelight extends Parent.with(MiioA
|
|
|
85
89
|
.then(() => this.call("set_bright", Yeelight.withEffect(brightness, options.duration), {
|
|
86
90
|
refresh: ["brightness"],
|
|
87
91
|
}))
|
|
88
|
-
.then(MiioApi.checkOk);
|
|
92
|
+
.then(device_1.MiioApi.checkOk);
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
changeName(name) {
|
|
92
96
|
return this.call("set_name", [name])
|
|
93
|
-
.then(MiioApi.checkOk)
|
|
97
|
+
.then(device_1.MiioApi.checkOk)
|
|
94
98
|
.then(() => (this.metadata.name = name));
|
|
95
99
|
}
|
|
96
100
|
/**
|
|
97
101
|
* Helper method to combine an argument with effect information.
|
|
98
102
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @param
|
|
103
|
+
* @param arg The argument(s) of the command
|
|
104
|
+
* @param duration The duration of the effect in ms
|
|
101
105
|
*/
|
|
102
106
|
static withEffect(arg, duration) {
|
|
103
107
|
const result = Array.isArray(arg) ? arg : [arg];
|
|
@@ -117,126 +121,14 @@ const Yeelight = Thing.type((Parent) => class Yeelight extends Parent.with(MiioA
|
|
|
117
121
|
}
|
|
118
122
|
return result;
|
|
119
123
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// TODO: Do all Yeelights use the same color range?
|
|
131
|
-
this.updateColorTemperatureRange(2700, 6500);
|
|
132
|
-
}
|
|
133
|
-
propertyUpdated(key, value) {
|
|
134
|
-
if (key === "colorTemperature") {
|
|
135
|
-
this.updateColor(color.temperature(value));
|
|
136
|
-
}
|
|
137
|
-
super.propertyUpdated(key, value);
|
|
138
|
-
}
|
|
139
|
-
changeColor(color, options) {
|
|
140
|
-
const range = this.colorTemperatureRange;
|
|
141
|
-
const temperature = Math.min(Math.max(color.temperature.kelvins, range.min), range.max);
|
|
142
|
-
return this.call("set_ct_abx", Yeelight.withEffect(temperature, options.duration), {
|
|
143
|
-
refresh: ["colorTemperature"],
|
|
144
|
-
}).then(MiioApi.checkOk);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
module.exports.ColorFull = Thing.mixin((Parent) => class extends Parent.with(MiioApi, Colorable, ColorTemperature, ColorFull) {
|
|
148
|
-
constructor(...args) {
|
|
149
|
-
super(...args);
|
|
150
|
-
// Color temperature
|
|
151
|
-
this.defineProperty("ct", {
|
|
152
|
-
name: "colorTemperature",
|
|
153
|
-
mapper: parseInt,
|
|
154
|
-
});
|
|
155
|
-
this.defineProperty("rgb", {
|
|
156
|
-
name: "colorRGB",
|
|
157
|
-
mapper: (rgb) => {
|
|
158
|
-
rgb = parseInt(rgb);
|
|
159
|
-
return {
|
|
160
|
-
red: (rgb >> 16) & 0xff,
|
|
161
|
-
green: (rgb >> 8) & 0xff,
|
|
162
|
-
blue: rgb & 0xff,
|
|
163
|
-
};
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
this.defineProperty("hue", {
|
|
167
|
-
name: "colorHue",
|
|
168
|
-
mapper: parseInt,
|
|
169
|
-
});
|
|
170
|
-
this.defineProperty("sat", {
|
|
171
|
-
name: "colorSaturation",
|
|
172
|
-
mapper: parseInt,
|
|
173
|
-
});
|
|
174
|
-
this.metadata.addCapabilities("color:temperature", "color:full");
|
|
175
|
-
// TODO: Do all Yeelights use the same color range?
|
|
176
|
-
this.updateColorTemperatureRange(2700, 6500);
|
|
177
|
-
}
|
|
178
|
-
propertyUpdated(key, value) {
|
|
179
|
-
if (key === "colorTemperature" ||
|
|
180
|
-
key === "colorMode" ||
|
|
181
|
-
key === "colorRGB" ||
|
|
182
|
-
key === "colorHue" ||
|
|
183
|
-
key === "colorSaturation" ||
|
|
184
|
-
key === "brightness") {
|
|
185
|
-
let currentColor = this.color();
|
|
186
|
-
switch (this.property("colorMode")) {
|
|
187
|
-
case "colorTemperature":
|
|
188
|
-
// Currently using color temperature mode, parse as temperature
|
|
189
|
-
currentColor = color.temperature(this.property("colorTemperature"));
|
|
190
|
-
break;
|
|
191
|
-
case "rgb": {
|
|
192
|
-
// Using RGB, parse if we have gotten the RGB value
|
|
193
|
-
let rgb = this.property("colorRGB");
|
|
194
|
-
if (rgb) {
|
|
195
|
-
currentColor = color.rgb(rgb.red, rgb.green, rgb.blue);
|
|
196
|
-
}
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
case "hsv": {
|
|
200
|
-
// Using HSV, parse the hue, saturation and get the brightness to set color
|
|
201
|
-
let hue = this.property("colorHue");
|
|
202
|
-
let saturation = this.property("colorSaturation");
|
|
203
|
-
if (typeof hue !== "undefined" &&
|
|
204
|
-
typeof saturation !== "undefined") {
|
|
205
|
-
currentColor = color.hsv(hue, saturation, this.property("brightness"));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
this.updateColor(currentColor);
|
|
210
|
-
}
|
|
211
|
-
super.propertyUpdated(key, value);
|
|
212
|
-
}
|
|
213
|
-
changeColor(color, options) {
|
|
214
|
-
if (color.is("temperature")) {
|
|
215
|
-
// The user has request a color via temperature
|
|
216
|
-
const range = this.colorTemperatureRange;
|
|
217
|
-
const temperature = Math.min(Math.max(color.temperature.kelvins, range.min), range.max);
|
|
218
|
-
return this.call("set_ct_abx", Yeelight.withEffect(temperature, options.duration), {
|
|
219
|
-
refresh: ["colorTemperature", "colorMode"],
|
|
220
|
-
}).then(MiioApi.checkOk);
|
|
221
|
-
}
|
|
222
|
-
else if (color.is("hsl")) {
|
|
223
|
-
/*
|
|
224
|
-
* User has requested hue and saturation
|
|
225
|
-
*/
|
|
226
|
-
return this.call("set_hsv", Yeelight.withEffect([color.hue, color.saturation], options.duration), {
|
|
227
|
-
refresh: ["colorHue", "colorSaturation", "colorMode"],
|
|
228
|
-
}).then(MiioApi.checkOk);
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
/*
|
|
232
|
-
* Fallback to applying via RGB.
|
|
233
|
-
*/
|
|
234
|
-
color = color.rgb;
|
|
235
|
-
const rgb = color.red * 65536 + color.green * 256 + color.blue;
|
|
236
|
-
return this.call("set_rgb", Yeelight.withEffect(rgb, options.duration), {
|
|
237
|
-
refresh: ["colorRGB", "colorMode"],
|
|
238
|
-
}).then(MiioApi.checkOk);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
});
|
|
124
|
+
}
|
|
125
|
+
exports.Yeelight = Yeelight;
|
|
126
|
+
/**
|
|
127
|
+
* Clamps a colour temperature to the range of the Yeelights.
|
|
128
|
+
*
|
|
129
|
+
* @param kelvins The temperature
|
|
130
|
+
* @returns The clamped temperature
|
|
131
|
+
*/
|
|
132
|
+
const clampTemperature = (kelvins) => Math.min(Math.max(kelvins, exports.TEMPERATURE_RANGE.min), exports.TEMPERATURE_RANGE.max);
|
|
133
|
+
exports.clampTemperature = clampTemperature;
|
|
242
134
|
//# sourceMappingURL=yeelight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yeelight.js","sourceRoot":"","sources":["../../../src/lib/devices/yeelight.
|
|
1
|
+
{"version":3,"file":"yeelight.js","sourceRoot":"","sources":["../../../src/lib/devices/yeelight.ts"],"names":[],"mappings":";;;AAAA,sCAAoC;AACpC,+CAA4C;AAC5C,8DAA2D;AAC3D,+DAG6C;AAC7C,iEAA8D;AAG9D,gDAA6C;AAC7C,sDAAmD;AAEnD,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,qEAAqE;AACxD,QAAA,iBAAiB,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AAE1D,MAAa,QAAS,SAAQ,IAAA,iBAAO,EACnC,gBAAO,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BAAiB,CAAC,GAAG,CAAC,EAAE,yBAAiB,CAAC,GAAG,CAAC,CAAC;AAD/D,QAAA,gBAAgB,oBAC+C"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Colorable } from "../things/capabilities/lights/colorable";
|
|
2
|
+
import { ColorTemperature } from "../things/capabilities/lights/color-temperature";
|
|
3
|
+
import { type LightChangeOptions } from "../things/capabilities/lights/light";
|
|
4
|
+
import { type Color } from "../things/color";
|
|
5
|
+
import { MiioApi } from "../device";
|
|
6
|
+
import { Yeelight } from "./yeelight";
|
|
7
|
+
declare const YeelightMono_base: typeof Yeelight & (abstract new (...args: any[]) => import("../things/compose").Composed<typeof Yeelight, [typeof Colorable, typeof ColorTemperature]>);
|
|
8
|
+
/** Yeelights with a white light of variable colour temperature */
|
|
9
|
+
export declare class YeelightMono extends YeelightMono_base {
|
|
10
|
+
constructor(handle: ConstructorParameters<typeof MiioApi>[0]);
|
|
11
|
+
propertyUpdated(key: string, value: unknown, oldValue?: unknown): void;
|
|
12
|
+
changeColor(value: Color, options: LightChangeOptions): Promise<null>;
|
|
3
13
|
}
|
|
14
|
+
export {};
|