matterbridge-tado-hw
Version:
A Matterbridge plugin that connects Tado° V2/V3/V3+ hot water control to the Matter smart home ecosystem
69 lines • 2.79 kB
JavaScript
// Matterbridge plugin for Tado hot water control
// Copyright © 2025 Alexander Thoukydides
// Device types for the Extension Kit or Wireless Receiver
const DEVICE_TYPES_HW = ['BU01', 'EK01'];
// Control of a single Tado hot water zone
export class TadoHWZone {
log;
config;
tado;
home_id;
zone;
// The device(s) in the zone responsible for hot water control
devices;
// Details of the hot water control device
// (suitable for the Matter Bridged Device Basic Information Cluster)
deviceName;
serialNumber;
productName;
softwareVersion;
// Create a new zone instance
constructor(log, config, tado, home_id, zone) {
this.log = log;
this.config = config;
this.tado = tado;
this.home_id = home_id;
this.zone = zone;
// Attempt to identify the device(s) responsible for hot water control
this.devices = this.getDevices();
// Extract interesting details about the device
this.deviceName = zone.name;
this.serialNumber = this.devices[0]?.serialNo ?? '?';
this.productName = this.devices[0]?.deviceType ?? '?';
this.softwareVersion = this.devices[0]?.currentFwVersion ?? '?';
}
// Identify the device(s) responsible for hot water control
getDevices() {
// Note: ZoneDevice is incorrectly derived from Zone (instead of Device)
// Note: DeviceType only allows "VA02", "SU02" (not "BU01", "EK01" etc)
const devices = this.zone.devices;
const devicesHW = devices.filter(device => DEVICE_TYPES_HW.includes(device.deviceType));
if (devicesHW.length !== 1) {
this.log.warn(`Expected a single hot water control device for ${this.zone.name} but ${devicesHW.length} found`);
this.log.debug(`Devices:\n${JSON.stringify(devices, null, 4)}`);
}
return devicesHW.length ? devicesHW : devices;
}
// Identify the hot water zone
async identify() {
for (const device of this.getDevices()) {
await this.tado.identifyDevice(device.serialNo);
}
}
// Get the current state of the hot water zone
async getPower() {
const state = await this.tado.getZoneState(this.home_id, this.zone.id);
this.log.debug('Zone state:', state);
return state.setting.power === 'ON';
}
// Set the state of the hot water zone (until the next scheduled time block)
async setPower(on) {
// https://github.com/mattdavis90/node-tado-client/issues/127
const zoneOverlay = {
zone_id: this.zone.id,
power: on ? 'ON' : 'OFF'
};
await this.tado.setZoneOverlays(this.home_id, [zoneOverlay], 'NEXT_TIME_BLOCK');
}
}
//# sourceMappingURL=tado-zone-hw.js.map