Skip to content

Commit 9ca85df

Browse files
burmistrzakKoenkk
andauthored
fix: Home Assistant: Translate boolean to state topic for current_humidity_topic (#30014)
Co-authored-by: Koen Kanters <[email protected]>
1 parent 334fa2a commit 9ca85df

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

lib/extension/homeassistant.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,10 @@ export class HomeAssistant extends Extension {
16811681
payload.action_topic = stateTopic;
16821682
}
16831683

1684+
if (payload.current_humidity_topic) {
1685+
payload.current_humidity_topic = stateTopic;
1686+
}
1687+
16841688
// Override configuration with user settings.
16851689
if (entity.options.homeassistant != null) {
16861690
const add = (obj: KeyValue, ignoreName: boolean): void => {

test/extensions/bridge.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ describe("Extension: Bridge", () => {
164164
"0x0017880104a44559": {friendly_name: "J1_cover"},
165165
"0x0017880104e43559": {friendly_name: "U202DST600ZB"},
166166
"0x0017880104e44559": {friendly_name: "3157100_thermostat"},
167+
"0x18fc2600000d7ae3": {friendly_name: "bosch_rm230z"},
167168
"0x0017880104e45517": {friendly_name: "remote", retain: true},
168169
"0x0017880104e45520": {friendly_name: "button", retain: false},
169170
"0x0017880104e45521": {

test/extensions/homeassistant.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,51 @@ describe("Extension: HomeAssistant", () => {
11971197
overrideSpy.mockRestore();
11981198
});
11991199

1200+
it("Should discover Bosch BTH-RM230Z with a current_humidity attribute", () => {
1201+
const payload = {
1202+
action_template:
1203+
"{% set values = {None:None,'idle':'idle','heat':'heating','cool':'cooling','fan_only':'fan'} %}{{ values[value_json.running_state] }}",
1204+
action_topic: "zigbee2mqtt/bosch_rm230z",
1205+
availability: [{topic: "zigbee2mqtt/bridge/state", value_template: "{{ value_json.state }}"}],
1206+
current_humidity_template: "{{ value_json.humidity }}",
1207+
current_humidity_topic: "zigbee2mqtt/bosch_rm230z",
1208+
current_temperature_template: "{{ value_json.local_temperature }}",
1209+
current_temperature_topic: "zigbee2mqtt/bosch_rm230z",
1210+
default_entity_id: "climate.bosch_rm230z",
1211+
device: {
1212+
identifiers: ["zigbee2mqtt_0x18fc2600000d7ae3"],
1213+
manufacturer: "Bosch",
1214+
model: "Room thermostat II 230V",
1215+
model_id: "BTH-RM230Z",
1216+
name: "bosch_rm230z",
1217+
via_device: "zigbee2mqtt_bridge_0x00124b00120144ae",
1218+
},
1219+
max_temp: "30",
1220+
min_temp: "5",
1221+
mode_command_topic: "zigbee2mqtt/bosch_rm230z/set/system_mode",
1222+
mode_state_template: "{{ value_json.system_mode }}",
1223+
mode_state_topic: "zigbee2mqtt/bosch_rm230z",
1224+
modes: ["off", "heat", "cool"],
1225+
name: null,
1226+
object_id: "bosch_rm230z",
1227+
origin,
1228+
temp_step: 0.5,
1229+
temperature_high_command_topic: "zigbee2mqtt/bosch_rm230z/set/occupied_cooling_setpoint",
1230+
temperature_high_state_template: "{{ value_json.occupied_cooling_setpoint }}",
1231+
temperature_high_state_topic: "zigbee2mqtt/bosch_rm230z",
1232+
temperature_low_command_topic: "zigbee2mqtt/bosch_rm230z/set/occupied_heating_setpoint",
1233+
temperature_low_state_template: "{{ value_json.occupied_heating_setpoint }}",
1234+
temperature_low_state_topic: "zigbee2mqtt/bosch_rm230z",
1235+
temperature_unit: "C",
1236+
unique_id: "0x18fc2600000d7ae3_climate_zigbee2mqtt",
1237+
};
1238+
1239+
expect(mockMQTTPublishAsync).toHaveBeenCalledWith("homeassistant/climate/0x18fc2600000d7ae3/climate/config", stringify(payload), {
1240+
qos: 1,
1241+
retain: true,
1242+
});
1243+
});
1244+
12001245
it("Should discover devices with cover_position", () => {
12011246
let payload;
12021247

test/mocks/data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const DEFAULT_CONFIGURATION = {
2626
"0x18fc2600000d7ae2": {
2727
friendly_name: "bosch_radiator",
2828
},
29+
"0x18fc2600000d7ae3": {
30+
friendly_name: "bosch_rm230z",
31+
},
2932
"0x000b57fffec6a5b2": {
3033
retain: true,
3134
friendly_name: "bulb",

test/mocks/zigbeeHerdsman.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,20 @@ export const devices = {
11371137
"DC Source",
11381138
"FanBee1",
11391139
),
1140+
BTH_RM230Z: new Device(
1141+
"Router",
1142+
"0x18fc2600000d7ae3",
1143+
35902,
1144+
4617,
1145+
[new Endpoint(1, [0, 3, 513, 516, 1029, 2821], [10, 25], "0x18fc2600000d7ae3")],
1146+
InterviewState.Successful,
1147+
"Mains (single phase)",
1148+
"RBSH-RTH0-ZB-EU",
1149+
undefined,
1150+
undefined,
1151+
undefined,
1152+
CUSTOM_CLUSTER_BTHRA,
1153+
),
11401154
};
11411155

11421156
export const mockController = {

0 commit comments

Comments
 (0)