Skip to content

Commit 8b5d1dc

Browse files
committed
fix(bosch): skip cable sensor temperature when disabled
1 parent 1f719f9 commit 8b5d1dc

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

src/lib/bosch.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,6 +3577,18 @@ export const boschThermostatExtend = {
35773577
scale: 100,
35783578
reporting: {min: 30, max: "MAX", change: 20},
35793579
access: "STATE_GET",
3580+
fzConvert: (_model, msg, _publish, _options, meta) => {
3581+
const cableSensorMode = meta.state.cable_sensor_mode ?? msg.endpoint.getClusterAttributeValue("hvacThermostat", "cableSensorMode");
3582+
if (cableSensorMode === "not_used" || cableSensorMode === 0x00) {
3583+
return;
3584+
}
3585+
3586+
const value = msg.data.cableSensorTemperature;
3587+
if (typeof value !== "number") {
3588+
throw new Error("cableSensorTemperature must be a number");
3589+
}
3590+
return {cable_sensor_temperature: value / 100};
3591+
},
35803592
}),
35813593
heaterType: () =>
35823594
m.enumLookup<"hvacThermostat", BoschThermostatCluster>({

test/bosch.test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,66 @@ describe("Bosch thermostats", () => {
3939
expect(definition.toZigbee.some((converter) => converter.key.includes("weekly_schedule"))).toBe(false);
4040
expect(JSON.stringify(definition.exposes)).not.toContain("weekly_schedule");
4141
});
42+
43+
it("does not publish cable sensor temperature when cable sensor mode is disabled", () => {
44+
const device = mockDevice({
45+
modelID: "RBSH-RTH0-ZB-EU",
46+
manufacturerName: "BOSCH",
47+
endpoints: [
48+
{
49+
ID: 1,
50+
inputClusters: ["hvacThermostat"],
51+
},
52+
],
53+
});
54+
const extend = boschThermostatExtend.cableSensorTemperature();
55+
const converter = extend.fromZigbee?.[0];
56+
57+
if (!converter?.convert) throw new Error("No fromZigbee converter for cable_sensor_temperature");
58+
59+
const result = converter.convert(
60+
device,
61+
{
62+
data: {cableSensorTemperature: 2150},
63+
endpoint: device.getEndpoint(1),
64+
} as never,
65+
() => {},
66+
{},
67+
{state: {cable_sensor_mode: "not_used"}} as never,
68+
);
69+
70+
expect(result).toBeUndefined();
71+
});
72+
73+
it("publishes cable sensor temperature when cable sensor mode is enabled", () => {
74+
const device = mockDevice({
75+
modelID: "RBSH-RTH0-ZB-EU",
76+
manufacturerName: "BOSCH",
77+
endpoints: [
78+
{
79+
ID: 1,
80+
inputClusters: ["hvacThermostat"],
81+
},
82+
],
83+
});
84+
const extend = boschThermostatExtend.cableSensorTemperature();
85+
const converter = extend.fromZigbee?.[0];
86+
87+
if (!converter?.convert) throw new Error("No fromZigbee converter for cable_sensor_temperature");
88+
89+
const result = converter.convert(
90+
device,
91+
{
92+
data: {cableSensorTemperature: 2150},
93+
endpoint: device.getEndpoint(1),
94+
} as never,
95+
() => {},
96+
{},
97+
{state: {cable_sensor_mode: "cable_sensor_without_regulation"}} as never,
98+
);
99+
100+
expect(result).toStrictEqual({cable_sensor_temperature: 21.5});
101+
});
42102
});
43103

44104
describe("Bosch thermostat relayState extension", () => {

0 commit comments

Comments
 (0)