Skip to content

Commit

Permalink
feat: Support frost_protection_temperature for SONOFF TRVZB (#6425)
Browse files Browse the repository at this point in the history
* feat: add support for Sonoff TRV frost protection

* refactor: moved frost protection into local Sonoff expose

* chore: reword description
  • Loading branch information
photomoose committed Nov 8, 2023
1 parent b6f362d commit 4d93c07
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions src/devices/sonoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as constants from '../lib/constants';
import * as reporting from '../lib/reporting';
import * as utils from '../lib/utils';
import extend from '../lib/extend';
import {Zcl} from 'zigbee-herdsman';
import {Definition, Fz, KeyValue, KeyValueAny, Tz} from '../lib/types';
Expand Down Expand Up @@ -47,6 +48,20 @@ const fzLocal = {
result.open_window = data[0x6000] ? 'ON' : 'OFF';
}

return result;
},
} as Fz.Converter,
frost_protection_temperature: {
cluster: '64529',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const result: KeyValueAny = {};
const data = msg.data;

if (data.hasOwnProperty(0x6002)) {
result.frost_protection_temperature = data[0x6002] / 100;
}

return result;
},
} as Fz.Converter,
Expand Down Expand Up @@ -81,6 +96,20 @@ const tzLocal = {
};
},
} as Tz.Converter,
frost_protection_temperature: {
key: ['frost_protection_temperature'],
convertGet: async (entity, key, meta) => {
await entity.read(0xFC11, [0x6002]);
},
convertSet: async (entity, key, value, meta) => {
await entity.write(0xFC11, {0x6002: {value: utils.toNumber(value) * 100, type: Zcl.DataType.int16}});
return {
state: {
[key]: value,
},
};
},
} as Tz.Converter,
};

const definitions: Definition[] = [
Expand Down Expand Up @@ -413,19 +442,26 @@ const definitions: Definition[] = [
.withLabel('Open window detection')
.withDescription('Automatically turns off the radiator when local temperature drops by more than 1.5°C in 4.5 minutes.')
.withAccess(ea.ALL),
e.numeric('frost_protection_temperature', ea.ALL)
.withValueMin(4.0)
.withValueMax(35.0)
.withValueStep(0.5)
.withUnit('°C')
.withDescription(
'Minimum temperature at which to automatically turn on the radiator, if system mode is off, to prevent pipes freezing.'),
],
fromZigbee: [fz.thermostat, fz.battery, fzLocal.child_lock, fzLocal.open_window],
fromZigbee: [fz.thermostat, fz.battery, fzLocal.child_lock, fzLocal.open_window, fzLocal.frost_protection_temperature],
toZigbee: [
tz.thermostat_local_temperature, tz.thermostat_local_temperature_calibration, tz.thermostat_occupied_heating_setpoint,
tz.thermostat_system_mode, tz.thermostat_running_state, tzLocal.child_lock, tzLocal.open_window],
tz.thermostat_system_mode, tz.thermostat_running_state, tzLocal.child_lock, tzLocal.open_window, tzLocal.frost_protection_temperature],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['hvacThermostat']);
await reporting.thermostatTemperature(endpoint);
await reporting.thermostatOccupiedHeatingSetpoint(endpoint);
await reporting.thermostatSystemMode(endpoint);
await endpoint.read('hvacThermostat', ['localTemperatureCalibration']);
await endpoint.read(64529, [0x0000, 0x6000]);
await endpoint.read(0xFC11, [0x0000, 0x6000, 0x6002]);
},
},
];
Expand Down

0 comments on commit 4d93c07

Please sign in to comment.