Skip to content

Commit

Permalink
Introducing min/max/step to local_temperature_calibration (#3341)
Browse files Browse the repository at this point in the history
* introducing min/max/step to local_temperature_calibration

* eslint

* saswell_thermostat_calibration cleanup
  • Loading branch information
Drafteed committed Nov 13, 2021
1 parent 00b042c commit 563d7b2
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 22 deletions.
2 changes: 0 additions & 2 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5299,8 +5299,6 @@ const converters = {
saswell_thermostat_calibration: {
key: ['local_temperature_calibration'],
convertSet: async (entity, key, value, meta) => {
if (value > 6) value = 6;
if (value < -6) value = -6;
if (value < 0) value = 0xFFFFFFFF + value + 1;
await tuya.sendDataPointValue(entity, tuya.dataPoints.saswellTempCalibration, value);
},
Expand Down
2 changes: 1 addition & 1 deletion devices/bitron.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = [
tz.thermostat_running_state, tz.thermostat_temperature_display_mode, tz.thermostat_keypad_lockout, tz.thermostat_system_mode],
exposes: [e.battery(), exposes.climate().withSetpoint('occupied_heating_setpoint', 7, 30, 0.5).withLocalTemperature()
.withSystemMode(['off', 'auto', 'heat']).withRunningState(['idle', 'heat', 'cool'])
.withLocalTemperatureCalibration(), e.keypad_lockout()],
.withLocalTemperatureCalibration(-20, 20, 1), e.keypad_lockout()],
meta: {battery: {voltageToPercentage: '3V_2500_3200'}},
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
Expand Down
6 changes: 4 additions & 2 deletions devices/centralite.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ module.exports = [
exposes: [e.battery(), exposes.climate().withSetpoint('occupied_heating_setpoint', 10, 30, 1).withLocalTemperature()
.withSystemMode(['off', 'heat', 'cool', 'emergency_heating'])
.withRunningState(['idle', 'heat', 'cool', 'fan_only']).withFanMode(['auto', 'on'])
.withSetpoint('occupied_cooling_setpoint', 10, 30, 1).withLocalTemperatureCalibration()],
.withSetpoint('occupied_cooling_setpoint', 10, 30, 1)
.withLocalTemperatureCalibration(-20, 20, 1)],
meta: {battery: {voltageToPercentage: '3V_1500_2800'}},
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
Expand All @@ -179,7 +180,8 @@ module.exports = [
exposes: [e.battery(), exposes.climate().withSetpoint('occupied_heating_setpoint', 10, 30, 1).withLocalTemperature()
.withSystemMode(['off', 'heat', 'cool', 'emergency_heating'])
.withRunningState(['idle', 'heat', 'cool', 'fan_only']).withFanMode(['auto', 'on'])
.withSetpoint('occupied_cooling_setpoint', 10, 30, 1).withLocalTemperatureCalibration()],
.withSetpoint('occupied_cooling_setpoint', 10, 30, 1)
.withLocalTemperatureCalibration(-20, 20, 1)],
meta: {battery: {voltageToPercentage: '3V_1500_2800'}},
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
Expand Down
3 changes: 2 additions & 1 deletion devices/ecozy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = [
tz.thermostat_weekly_schedule, tz.thermostat_clear_weekly_schedule, tz.thermostat_relay_status_log,
tz.thermostat_pi_heating_demand, tz.thermostat_running_state],
exposes: [e.battery(), exposes.climate().withSetpoint('occupied_heating_setpoint', 7, 30, 1).withLocalTemperature()
.withSystemMode(['off', 'auto', 'heat']).withRunningState(['idle', 'heat']).withLocalTemperatureCalibration()
.withSystemMode(['off', 'auto', 'heat']).withRunningState(['idle', 'heat'])
.withLocalTemperatureCalibration(-20, 20, 1)
.withPiHeatingDemand(ea.STATE_GET)],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(3);
Expand Down
2 changes: 1 addition & 1 deletion devices/elko.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = [
'(quick) wooden floors.'),
exposes.climate().withSetpoint('occupied_heating_setpoint', 5, 50, 1)
.withLocalTemperature(ea.STATE)
.withLocalTemperatureCalibration()
.withLocalTemperatureCalibration(-20, 20, 1)
.withSystemMode(['off', 'heat']).withRunningState(['idle', 'heat'])
.withSensor(['air', 'floor', 'supervisor_floor']),
exposes.numeric('floor_temp', ea.STATE_GET).withUnit('°C')
Expand Down
3 changes: 2 additions & 1 deletion devices/eurotronic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports = [
tz.thermostat_remote_sensing, tz.thermostat_local_temperature, tz.thermostat_running_state,
tz.eurotronic_current_heating_setpoint, tz.eurotronic_trv_mode, tz.eurotronic_valve_position],
exposes: [e.battery(), exposes.climate().withSetpoint('occupied_heating_setpoint', 5, 30, 0.5).withLocalTemperature()
.withSystemMode(['off', 'auto', 'heat']).withRunningState(['idle', 'heat']).withLocalTemperatureCalibration()
.withSystemMode(['off', 'auto', 'heat']).withRunningState(['idle', 'heat'])
.withLocalTemperatureCalibration(-20, 20, 1)
.withPiHeatingDemand(),
exposes.enum('trv_mode', exposes.access.ALL, [1, 2])
.withDescription('Select between direct control of the valve via the `valve_position` or automatic control of the '+
Expand Down
2 changes: 1 addition & 1 deletion devices/hgkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = [
tz.moes_thermostat_deadzone_temperature, tz.moes_thermostat_max_temperature_limit],
exposes: [e.child_lock(), e.deadzone_temperature(), e.max_temperature_limit(),
exposes.climate().withSetpoint('current_heating_setpoint', 5, 30, 1, ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withSystemMode(['off', 'cool'], ea.STATE_SET).withRunningState(['idle', 'heat', 'cool'], ea.STATE)
.withPreset(['hold', 'program']).withSensor(['IN', 'AL', 'OU'], ea.STATE_SET)],
onEvent: tuya.onEventSetLocalTime,
Expand Down
3 changes: 2 additions & 1 deletion devices/leviton.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ module.exports = [
exposes: [
exposes.climate().withSetpoint('occupied_heating_setpoint', 10, 30, 1).withLocalTemperature()
.withSystemMode(['off', 'auto', 'heat', 'cool']).withFanMode(['auto', 'on', 'smart'])
.withSetpoint('occupied_cooling_setpoint', 10, 30, 1).withLocalTemperatureCalibration().withPiHeatingDemand()],
.withSetpoint('occupied_cooling_setpoint', 10, 30, 1)
.withLocalTemperatureCalibration(-20, 20, 1).withPiHeatingDemand()],
},
];
7 changes: 4 additions & 3 deletions devices/moes.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = [
tz.moes_thermostat_deadzone_temperature, tz.moes_thermostat_max_temperature_limit],
exposes: [e.child_lock(), e.deadzone_temperature(), e.max_temperature_limit(),
exposes.climate().withSetpoint('current_heating_setpoint', 5, 30, 1, ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withSystemMode(['off', 'heat'], ea.STATE_SET).withRunningState(['idle', 'heat', 'cool'], ea.STATE)
.withPreset(['hold', 'program']).withSensor(['IN', 'AL', 'OU'], ea.STATE_SET)],
onEvent: tuya.onEventSetLocalTime,
Expand Down Expand Up @@ -209,7 +209,8 @@ module.exports = [
exposes.binary('window', ea.STATE, 'CLOSED', 'OPEN').withDescription('Window status closed or open '),
exposes.climate()
.withLocalTemperature(ea.STATE).withSetpoint('current_heating_setpoint', 5, 35, 0.5, ea.STATE_SET)
.withLocalTemperatureCalibration(ea.STATE_SET).withPreset(['programming', 'manual', 'temporary_manual', 'holiday'],
.withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withPreset(['programming', 'manual', 'temporary_manual', 'holiday'],
'MANUAL MODE ☝ - In this mode, the device executes manual temperature setting. '+
'When the set temperature is lower than the "minimum temperature", the valve is closed (forced closed). ' +
'PROGRAMMING MODE ⏱ - In this mode, the device executes a preset week programming temperature time and temperature. ' +
Expand Down Expand Up @@ -308,7 +309,7 @@ module.exports = [
exposes.numeric('error_status', ea.STATE).withDescription('Error status'),
// exposes.binary('boost_mode', ea.STATE_SET).withDescription('Enables/disables boost mode'),
exposes.climate().withSetpoint('current_heating_setpoint', 5, 29.5, 1, ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withSystemMode(Object.values(tuya.tvThermostatMode), ea.STATE_SET)
.withPreset(Object.values(tuya.tvThermostatPreset)),
],
Expand Down
3 changes: 2 additions & 1 deletion devices/saswell.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ module.exports = [
},
exposes: [e.battery_low(), e.window_detection(), e.child_lock(), exposes.climate()
.withSetpoint('current_heating_setpoint', 5, 30, 0.5, ea.STATE_SET).withLocalTemperature(ea.STATE)
.withSystemMode(['off', 'heat', 'auto'], ea.STATE_SET).withLocalTemperatureCalibration(ea.STATE_SET)
.withSystemMode(['off', 'heat', 'auto'], ea.STATE_SET)
.withLocalTemperatureCalibration(-6, 6, 1, ea.STATE_SET)
.withAwayMode()],
},
];
2 changes: 1 addition & 1 deletion devices/schneider_electric.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ module.exports = [
exposes.climate()
.withSetpoint('occupied_heating_setpoint', 7, 30, 0.5, ea.STATE_SET)
.withLocalTemperature(ea.STATE)
.withLocalTemperatureCalibration(ea.STATE_SET)
.withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withPiHeatingDemand()],
meta: {battery: {voltageToPercentage: '3V_2500'}},
configure: async (device, coordinatorEndpoint, logger) => {
Expand Down
8 changes: 4 additions & 4 deletions devices/tuya.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ module.exports = [
e.child_lock(), e.window_detection(), e.battery_low(), e.valve_detection(), e.position(),
exposes.climate().withSetpoint('current_heating_setpoint', 5, 35, 0.5, ea.STATE_SET)
.withLocalTemperature(ea.STATE).withSystemMode(['heat', 'auto', 'off'], ea.STATE_SET)
.withLocalTemperatureCalibration(ea.STATE_SET)
.withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withAwayMode().withPreset(['schedule', 'manual', 'boost', 'complex', 'comfort', 'eco']),
e.auto_lock(), e.away_mode(), e.away_preset_days(), e.boost_time(), e.comfort_temperature(), e.eco_temperature(), e.force(),
e.max_temperature(), e.min_temperature(), e.away_preset_temperature(),
Expand All @@ -805,7 +805,7 @@ module.exports = [
exposes: [
e.battery_low(), e.window_detection(), e.child_lock(), e.comfort_temperature(), e.eco_temperature(),
e.open_window_temperature(), e.holiday_temperature(),
exposes.climate().withPreset(['auto', 'manual', 'holiday']).withLocalTemperatureCalibration(ea.STATE_SET)
exposes.climate().withPreset(['auto', 'manual', 'holiday']).withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET)
.withLocalTemperature(ea.STATE).withSetpoint('current_heating_setpoint', 0, 30, 0.5, ea.STATE_SET),
exposes.numeric('boost_timeset_countdown', ea.STATE_SET).withUnit('second').withDescription('Setting '+
'minimum 0 - maximum 465 seconds boost time. The boost (♨) function is activated. The remaining '+
Expand Down Expand Up @@ -903,7 +903,7 @@ module.exports = [
exposes.binary('heating', ea.STATE, 'ON', 'OFF').withDescription('Device valve is open or closed (heating or not)'),
exposes.climate()
.withLocalTemperature(ea.STATE).withSetpoint('current_heating_setpoint', 5, 35, 0.5, ea.STATE_SET)
.withLocalTemperatureCalibration(ea.STATE_SET).withPreset(['auto', 'manual', 'off', 'on'],
.withLocalTemperatureCalibration(-20, 20, 1, ea.STATE_SET).withPreset(['auto', 'manual', 'off', 'on'],
'MANUAL MODE ☝ - In this mode, the device executes manual temperature setting. ' +
'When the set temperature is lower than the "minimum temperature", the valve is closed (forced closed). ' +
'AUTO MODE ⏱ - In this mode, the device executes a preset week programming temperature time and temperature. ' +
Expand Down Expand Up @@ -1418,7 +1418,7 @@ module.exports = [
exposes: [exposes.climate().withSetpoint('occupied_heating_setpoint', 5, 30, 0.5).withLocalTemperature()
.withSystemMode(['off', 'auto', 'heat'], ea.ALL)
.withRunningState(['idle', 'heat', 'cool'], ea.STATE)
.withLocalTemperatureCalibration(ea.ALL).withPiHeatingDemand()],
.withLocalTemperatureCalibration(-20, 20, 1, ea.ALL).withPiHeatingDemand()],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(9);
await reporting.bind(endpoint, coordinatorEndpoint, ['hvacThermostat', 'hvacFanCtrl']);
Expand Down
2 changes: 1 addition & 1 deletion devices/zen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = [
tz.thermostat_weekly_schedule, tz.thermostat_clear_weekly_schedule, tz.thermostat_relay_status_log],
exposes: [exposes.climate().withSetpoint('occupied_heating_setpoint', 10, 30, 0.5).withLocalTemperature()
.withSystemMode(['off', 'auto', 'heat', 'cool']).withRunningState(['idle', 'heat', 'cool'])
.withLocalTemperatureCalibration().withPiHeatingDemand()],
.withLocalTemperatureCalibration(-20, 20, 1).withPiHeatingDemand()],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(3) || device.getEndpoint(1);
const binds = ['genBasic', 'genIdentify', 'genPowerCfg', 'genTime', 'hvacThermostat', 'hvacUserInterfaceCfg'];
Expand Down
5 changes: 3 additions & 2 deletions lib/exposes.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,10 @@ class Climate extends Base {
return this;
}

withLocalTemperatureCalibration(access=a.ALL) {
withLocalTemperatureCalibration(min, max, step, access=a.ALL) {
assert(!this.endpoint, 'Cannot add feature after adding endpoint');
this.features.push(new Numeric('local_temperature_calibration', access).withUnit('°C').withDescription('Offset to be used in the local_temperature'));
this.features.push(new Numeric('local_temperature_calibration', access)
.withValueMin(min).withValueMax(max).withValueStep(step).withUnit('°C').withDescription('Offset to be used in the local_temperature'));
return this;
}

Expand Down

0 comments on commit 563d7b2

Please sign in to comment.