Skip to content

Commit

Permalink
Merge branch 'dev' into deps/all
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk authored Mar 2, 2025
2 parents 6516c13 + 4fa794a commit a7c51a6
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.1.2"
".": "2.1.3"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [2.1.3](https://github.com/Koenkk/zigbee2mqtt/compare/2.1.2...2.1.3) (2025-03-02)


### Bug Fixes

* Home Assistant: fix brightness only lights ([#26560](https://github.com/Koenkk/zigbee2mqtt/issues/26560)) ([7e7057e](https://github.com/Koenkk/zigbee2mqtt/commit/7e7057eccd1fe638dd73b4a4f303c6612b73c89d))

## [2.1.2](https://github.com/Koenkk/zigbee2mqtt/compare/2.1.1...2.1.2) (2025-03-01)


Expand Down
2 changes: 1 addition & 1 deletion lib/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Controller {
}

// Call extensions
await this.callExtensions('start', [...this.extensions]);
await this.callExtensions('start', this.extensions);

// Send all cached states.
if (settings.get().advanced.cache_state_send_on_startup && settings.get().advanced.cache_state) {
Expand Down
24 changes: 17 additions & 7 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,23 @@ export default class HomeAssistant extends Extension {
},
};

discoveryEntry.discovery_payload.supported_color_modes = [
'brightness',
const colorModes = [
hasColorXY && !preferHS ? 'xy' : null,
(!hasColorXY || preferHS) && hasColorHS ? 'hs' : null,
hasColorTemp ? 'color_temp' : null,
].filter((c) => c);

if (colorModes.length) {
discoveryEntry.discovery_payload.supported_color_modes = colorModes;
} else {
/**
* All bulbs support brightness, note that `brightness` cannot be combined
* with other color modes.
* https://github.com/Koenkk/zigbee2mqtt/issues/26520#issuecomment-2692432058
*/
discoveryEntry.discovery_payload.supported_color_modes = ['brightness'];
}

if (hasColorTemp) {
const colorTemps = (exposes as zhc.Light[])
.map((expose) => expose.features.find((e) => e.name === 'color_temp'))
Expand Down Expand Up @@ -1370,10 +1380,9 @@ export default class HomeAssistant extends Extension {
const exposesByType: {[s: string]: zhc.Expose[]} = {};
const allExposes: zhc.Expose[] = [];

entity.zh.members
.map((e) => this.zigbee.resolveEntity(e.getDevice()) as Device)
.filter((d) => d.definition)
.forEach((device) => {
for (const member of entity.zh.members) {
const device = this.zigbee.resolveEntity(member.getDevice()) as Device;
if (device.definition) {
const exposes = device.exposes();
allExposes.push(...exposes);
for (const expose of exposes.filter((e) => GROUP_SUPPORTED_TYPES.includes(e.type))) {
Expand All @@ -1389,7 +1398,8 @@ export default class HomeAssistant extends Extension {
if (!exposesByType[key]) exposesByType[key] = [];
exposesByType[key].push(expose);
}
});
}
}

configs = ([] as DiscoveryEntry[]).concat(
...Object.values(exposesByType).map((exposes) => this.exposeToConfig(exposes, 'group', allExposes)),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zigbee2mqtt",
"version": "2.1.2-dev",
"version": "2.1.3-dev",
"description": "Zigbee to MQTT bridge using Zigbee-herdsman",
"main": "index.js",
"packageManager": "[email protected]",
Expand Down
39 changes: 33 additions & 6 deletions test/extensions/homeassistant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Extension: HomeAssistant', () => {
name: null,
schema: 'json',
state_topic: 'zigbee2mqtt/ha_discovery_group',
supported_color_modes: ['brightness', 'xy', 'color_temp'],
supported_color_modes: ['xy', 'color_temp'],
effect: true,
effect_list: [
'blink',
Expand All @@ -165,6 +165,33 @@ describe('Extension: HomeAssistant', () => {
qos: 1,
});

payload = {
availability: [{topic: 'zigbee2mqtt/bridge/state', value_template: '{{ value_json.state }}'}],
brightness: true,
brightness_scale: 254,
command_topic: 'zigbee2mqtt/bulb_enddevice/set',
device: {
identifiers: ['zigbee2mqtt_0x0017880104e45553'],
manufacturer: 'Sengled',
model: 'Element classic (A19)',
model_id: 'E11-G13',
name: 'bulb_enddevice',
via_device: 'zigbee2mqtt_bridge_0x00124b00120144ae',
},
name: null,
object_id: 'bulb_enddevice',
origin: origin,
schema: 'json',
state_topic: 'zigbee2mqtt/bulb_enddevice',
supported_color_modes: ['brightness'],
unique_id: '0x0017880104e45553_light_zigbee2mqtt',
};

expect(mockMQTTPublishAsync).toHaveBeenCalledWith('homeassistant/light/0x0017880104e45553/light/config', stringify(payload), {
retain: true,
qos: 1,
});

payload = {
availability: [{topic: 'zigbee2mqtt/bridge/state', value_template: '{{ value_json.state }}'}],
command_topic: 'zigbee2mqtt/ha_discovery_group/set',
Expand Down Expand Up @@ -381,7 +408,7 @@ describe('Extension: HomeAssistant', () => {
availability: [{topic: 'zigbee2mqtt/bridge/state', value_template: '{{ value_json.state }}'}],
brightness: true,
brightness_scale: 254,
supported_color_modes: ['brightness', 'color_temp'],
supported_color_modes: ['color_temp'],
min_mireds: 250,
max_mireds: 454,
command_topic: 'zigbee2mqtt/bulb/set',
Expand Down Expand Up @@ -1633,7 +1660,7 @@ describe('Extension: HomeAssistant', () => {
name: null,
schema: 'json',
state_topic: 'zigbee2mqtt/ha_discovery_group_new',
supported_color_modes: ['brightness', 'xy', 'color_temp'],
supported_color_modes: ['xy', 'color_temp'],
effect: true,
effect_list: [
'blink',
Expand Down Expand Up @@ -2101,7 +2128,7 @@ describe('Extension: HomeAssistant', () => {
name: null,
schema: 'json',
state_topic: 'zigbee2mqtt/ha_discovery_group',
supported_color_modes: ['brightness', 'xy', 'color_temp'],
supported_color_modes: ['xy', 'color_temp'],
effect: true,
effect_list: [
'blink',
Expand Down Expand Up @@ -2145,7 +2172,7 @@ describe('Extension: HomeAssistant', () => {
name: null,
schema: 'json',
state_topic: 'zigbee2mqtt/ha_discovery_group',
supported_color_modes: ['brightness', 'xy', 'color_temp'],
supported_color_modes: ['xy', 'color_temp'],
effect: true,
effect_list: [
'blink',
Expand Down Expand Up @@ -2200,7 +2227,7 @@ describe('Extension: HomeAssistant', () => {
name: null,
schema: 'json',
state_topic: 'zigbee2mqtt/bulb',
supported_color_modes: ['brightness', 'color_temp'],
supported_color_modes: ['color_temp'],
object_id: 'bulb',
unique_id: '0x000b57fffec6a5b2_light_zigbee2mqtt',
origin: origin,
Expand Down

0 comments on commit a7c51a6

Please sign in to comment.