This commit is contained in:
Koen Kanters 2021-02-12 20:38:06 +01:00
parent 545caef6d5
commit 5986152349
2 changed files with 9 additions and 1 deletions

View File

@ -83,12 +83,13 @@ class HomeAssistant extends Extension {
if (expose.type === 'light') {
const supportsXY = !!expose.features.find((e) => e.name === 'color_xy');
const supportsHS = !!expose.features.find((e) => e.name === 'color_hs');
const colorTemp = expose.features.find((e) => e.name === 'color_temp');
discoveryEntry = {
type: 'light',
object_id: expose.endpoint ? `light_${expose.endpoint}` : 'light',
discovery_payload: {
brightness: !!expose.features.find((e) => e.name === 'brightness'),
color_temp: !!expose.features.find((e) => e.name === 'color_temp'),
color_temp: !!colorTemp,
xy: supportsXY,
hs: !supportsXY && supportsHS,
schema: 'json',
@ -99,6 +100,11 @@ class HomeAssistant extends Extension {
},
};
if (colorTemp) {
discoveryEntry.discovery_payload.max_mireds = colorTemp.value_max;
discoveryEntry.discovery_payload.min_mireds = colorTemp.value_min;
}
const effect = def.exposes.find((e) => e.type === 'enum' && e.name === 'effect');
if (effect) {
discoveryEntry.discovery_payload.effect = true;

View File

@ -249,6 +249,8 @@ describe('HomeAssistant extension', () => {
"brightness":true,
"brightness_scale":254,
"color_temp":true,
"min_mireds": 250,
"max_mireds": 454,
"command_topic":"zigbee2mqtt/bulb/set",
"device":{
"identifiers":[