HA discovery: prefer XY over HS.

This commit is contained in:
Koen Kanters 2021-01-05 18:40:26 +01:00
parent 90abc2e846
commit acfd938e48

View File

@ -82,14 +82,16 @@ class HomeAssistant extends Extension {
let discoveryEntry = null;
/* istanbul ignore else */
if (expose.type === 'light') {
const supportsXY = !!expose.features.find((e) => e.name === 'color_xy');
const supportsHS = !!expose.features.find((e) => e.name === 'color_hs');
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'),
xy: !!expose.features.find((e) => e.name === 'color_xy'),
hs: !!expose.features.find((e) => e.name === 'color_hs'),
xy: supportsXY,
hs: !supportsXY && supportsHS,
schema: 'json',
command_topic: true,
brightness_scale: 254,