Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lib/bosch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3577,6 +3577,18 @@ export const boschThermostatExtend = {
scale: 100,
reporting: {min: 30, max: "MAX", change: 20},
access: "STATE_GET",
fzConvert: (_model, msg, _publish, _options, meta) => {
const cableSensorMode = meta.state.cable_sensor_mode ?? msg.endpoint.getClusterAttributeValue("hvacThermostat", "cableSensorMode");
if (cableSensorMode === "not_used" || cableSensorMode === 0x00) {
return;
}

const value = msg.data.cableSensorTemperature;
if (typeof value !== "number") {
throw new Error("cableSensorTemperature must be a number");
}
return {cable_sensor_temperature: value / 100};
},
}),
heaterType: () =>
m.enumLookup<"hvacThermostat", BoschThermostatCluster>({
Expand Down
60 changes: 60 additions & 0 deletions test/bosch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,66 @@ describe("Bosch thermostats", () => {
expect(definition.toZigbee.some((converter) => converter.key.includes("weekly_schedule"))).toBe(false);
expect(JSON.stringify(definition.exposes)).not.toContain("weekly_schedule");
});

it("does not publish cable sensor temperature when cable sensor mode is disabled", () => {
const device = mockDevice({
modelID: "RBSH-RTH0-ZB-EU",
manufacturerName: "BOSCH",
endpoints: [
{
ID: 1,
inputClusters: ["hvacThermostat"],
},
],
});
const extend = boschThermostatExtend.cableSensorTemperature();
const converter = extend.fromZigbee?.[0];

if (!converter?.convert) throw new Error("No fromZigbee converter for cable_sensor_temperature");

const result = converter.convert(
device,
{
data: {cableSensorTemperature: 2150},
endpoint: device.getEndpoint(1),
} as never,
() => {},
{},
{state: {cable_sensor_mode: "not_used"}} as never,
);

expect(result).toBeUndefined();
});

it("publishes cable sensor temperature when cable sensor mode is enabled", () => {
const device = mockDevice({
modelID: "RBSH-RTH0-ZB-EU",
manufacturerName: "BOSCH",
endpoints: [
{
ID: 1,
inputClusters: ["hvacThermostat"],
},
],
});
const extend = boschThermostatExtend.cableSensorTemperature();
const converter = extend.fromZigbee?.[0];

if (!converter?.convert) throw new Error("No fromZigbee converter for cable_sensor_temperature");

const result = converter.convert(
device,
{
data: {cableSensorTemperature: 2150},
endpoint: device.getEndpoint(1),
} as never,
() => {},
{},
{state: {cable_sensor_mode: "cable_sensor_without_regulation"}} as never,
);

expect(result).toStrictEqual({cable_sensor_temperature: 21.5});
});
});

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