mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-04 11:01:40 +00:00
fix: Home Assistant: Translate boolean to state topic for current_humidity_topic (#30014)
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
@@ -1681,6 +1681,10 @@ export class HomeAssistant extends Extension {
|
||||
payload.action_topic = stateTopic;
|
||||
}
|
||||
|
||||
if (payload.current_humidity_topic) {
|
||||
payload.current_humidity_topic = stateTopic;
|
||||
}
|
||||
|
||||
// Override configuration with user settings.
|
||||
if (entity.options.homeassistant != null) {
|
||||
const add = (obj: KeyValue, ignoreName: boolean): void => {
|
||||
|
||||
@@ -164,6 +164,7 @@ describe("Extension: Bridge", () => {
|
||||
"0x0017880104a44559": {friendly_name: "J1_cover"},
|
||||
"0x0017880104e43559": {friendly_name: "U202DST600ZB"},
|
||||
"0x0017880104e44559": {friendly_name: "3157100_thermostat"},
|
||||
"0x18fc2600000d7ae3": {friendly_name: "bosch_rm230z"},
|
||||
"0x0017880104e45517": {friendly_name: "remote", retain: true},
|
||||
"0x0017880104e45520": {friendly_name: "button", retain: false},
|
||||
"0x0017880104e45521": {
|
||||
|
||||
@@ -1197,6 +1197,51 @@ describe("Extension: HomeAssistant", () => {
|
||||
overrideSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("Should discover Bosch BTH-RM230Z with a current_humidity attribute", () => {
|
||||
const payload = {
|
||||
action_template:
|
||||
"{% set values = {None:None,'idle':'idle','heat':'heating','cool':'cooling','fan_only':'fan'} %}{{ values[value_json.running_state] }}",
|
||||
action_topic: "zigbee2mqtt/bosch_rm230z",
|
||||
availability: [{topic: "zigbee2mqtt/bridge/state", value_template: "{{ value_json.state }}"}],
|
||||
current_humidity_template: "{{ value_json.humidity }}",
|
||||
current_humidity_topic: "zigbee2mqtt/bosch_rm230z",
|
||||
current_temperature_template: "{{ value_json.local_temperature }}",
|
||||
current_temperature_topic: "zigbee2mqtt/bosch_rm230z",
|
||||
default_entity_id: "climate.bosch_rm230z",
|
||||
device: {
|
||||
identifiers: ["zigbee2mqtt_0x18fc2600000d7ae3"],
|
||||
manufacturer: "Bosch",
|
||||
model: "Room thermostat II 230V",
|
||||
model_id: "BTH-RM230Z",
|
||||
name: "bosch_rm230z",
|
||||
via_device: "zigbee2mqtt_bridge_0x00124b00120144ae",
|
||||
},
|
||||
max_temp: "30",
|
||||
min_temp: "5",
|
||||
mode_command_topic: "zigbee2mqtt/bosch_rm230z/set/system_mode",
|
||||
mode_state_template: "{{ value_json.system_mode }}",
|
||||
mode_state_topic: "zigbee2mqtt/bosch_rm230z",
|
||||
modes: ["off", "heat", "cool"],
|
||||
name: null,
|
||||
object_id: "bosch_rm230z",
|
||||
origin,
|
||||
temp_step: 0.5,
|
||||
temperature_high_command_topic: "zigbee2mqtt/bosch_rm230z/set/occupied_cooling_setpoint",
|
||||
temperature_high_state_template: "{{ value_json.occupied_cooling_setpoint }}",
|
||||
temperature_high_state_topic: "zigbee2mqtt/bosch_rm230z",
|
||||
temperature_low_command_topic: "zigbee2mqtt/bosch_rm230z/set/occupied_heating_setpoint",
|
||||
temperature_low_state_template: "{{ value_json.occupied_heating_setpoint }}",
|
||||
temperature_low_state_topic: "zigbee2mqtt/bosch_rm230z",
|
||||
temperature_unit: "C",
|
||||
unique_id: "0x18fc2600000d7ae3_climate_zigbee2mqtt",
|
||||
};
|
||||
|
||||
expect(mockMQTTPublishAsync).toHaveBeenCalledWith("homeassistant/climate/0x18fc2600000d7ae3/climate/config", stringify(payload), {
|
||||
qos: 1,
|
||||
retain: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("Should discover devices with cover_position", () => {
|
||||
let payload;
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ export const DEFAULT_CONFIGURATION = {
|
||||
"0x18fc2600000d7ae2": {
|
||||
friendly_name: "bosch_radiator",
|
||||
},
|
||||
"0x18fc2600000d7ae3": {
|
||||
friendly_name: "bosch_rm230z",
|
||||
},
|
||||
"0x000b57fffec6a5b2": {
|
||||
retain: true,
|
||||
friendly_name: "bulb",
|
||||
|
||||
@@ -1137,6 +1137,20 @@ export const devices = {
|
||||
"DC Source",
|
||||
"FanBee1",
|
||||
),
|
||||
BTH_RM230Z: new Device(
|
||||
"Router",
|
||||
"0x18fc2600000d7ae3",
|
||||
35902,
|
||||
4617,
|
||||
[new Endpoint(1, [0, 3, 513, 516, 1029, 2821], [10, 25], "0x18fc2600000d7ae3")],
|
||||
InterviewState.Successful,
|
||||
"Mains (single phase)",
|
||||
"RBSH-RTH0-ZB-EU",
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
CUSTOM_CLUSTER_BTHRA,
|
||||
),
|
||||
};
|
||||
|
||||
export const mockController = {
|
||||
|
||||
Reference in New Issue
Block a user