Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved sysytem_mode/preset handling #1864

Merged
merged 1 commit into from Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions converters/fromZigbee.js
Expand Up @@ -485,7 +485,7 @@ const saswellThermostat = (model, msg, publish, options, meta) => {
if (value) {
return {away_mode: 'ON', preset_mode: 'away'};
} else {
return {away_mode: 'OFF'};
return {away_mode: 'OFF', preset_mode: 'none'};
}
case common.TuyaDataPoints.saswellScheduleMode:
if (common.TuyaThermostatScheduleMode.hasOwnProperty(value)) {
Expand All @@ -496,7 +496,10 @@ const saswellThermostat = (model, msg, publish, options, meta) => {
}
break;
case common.TuyaDataPoints.saswellScheduleEnable:
return {preset_mode: value ? 'Schedule' : 'none'};
if ( value ) {
return {system_mode: 'auto'};
}
break;
case common.TuyaDataPoints.saswellScheduleSet:
// Never seen being reported, but put here to prevent warnings
break;
Expand Down
25 changes: 7 additions & 18 deletions converters/toZigbee.js
Expand Up @@ -3789,13 +3789,14 @@ const converters = {
},
},
saswell_thermostat_mode: {
key: ['preset'],
key: ['system_mode'],
convertSet: async (entity, key, value, meta) => {
if ( value == 'off' ) {
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, false);
} else if ( value == 'Schedule' ) {
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, true);
}
const schedule = (value === 'auto');
const enable = !(value === 'off');
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellState, enable);
// Older versions of Saswell TRVs need the delay to work reliably
await utils.sleepMs(3000);
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, schedule);
},
},
saswell_thermostat_away: {
Expand All @@ -3805,21 +3806,9 @@ const converters = {
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellAwayMode, true);
} else {
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellAwayMode, false);
// HA does not send preset_mode when exiting 'away'
// We have no way to check whether 'Schedule' is on, so we need to set it here
await utils.sleepMs(2000);
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, false);
meta.logger.error('Saswell: Sending prog 0');
// return {state: {preset_mode: 'none'}};
}
},
},
saswell_thermostat_standby: {
key: ['system_mode'],
convertSet: async (entity, key, value, meta) => {
await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellState, value === 'heat');
},
},
saswell_thermostat_child_lock: {
key: ['child_lock'],
convertSet: async (entity, key, value, meta) => {
Expand Down
12 changes: 4 additions & 8 deletions devices.js
Expand Up @@ -13674,7 +13674,6 @@ const devices = [
toZigbee: [
tz.saswell_thermostat_current_heating_setpoint,
tz.saswell_thermostat_mode,
tz.saswell_thermostat_standby,
tz.saswell_thermostat_away,
tz.saswell_thermostat_child_lock,
tz.saswell_thermostat_window_detection,
Expand All @@ -13687,7 +13686,6 @@ const devices = [
thermostat: {
weeklyScheduleMaxTransitions: 4,
weeklyScheduleSupportedModes: [1], // bits: 0-heat present, 1-cool present (dec: 1-heat,2-cool,3-heat+cool)
weeklyScheduleFirstDayDpId: common.TuyaDataPoints.saswellSchedule,
weeklyScheduleConversion: 'saswell',
},
},
Expand All @@ -13698,8 +13696,8 @@ const devices = [
exposes: [
e.battery_low(), e.window_detection(), e.child_lock(), exposes.climate()
.withSetpoint('current_heating_setpoint', 5, 30, 0.5).withLocalTemperature()
.withSystemMode(['off', 'heat']).withRunningState(['idle', 'heat'])
.withPreset(['Schedule']).withAwayMode(),
.withSystemMode(['off', 'heat', 'auto']).withRunningState(['idle', 'heat'])
.withAwayMode(),
],
},
{
Expand All @@ -13723,7 +13721,6 @@ const devices = [
toZigbee: [
tz.saswell_thermostat_current_heating_setpoint,
tz.saswell_thermostat_mode,
tz.saswell_thermostat_standby,
tz.saswell_thermostat_away,
tz.saswell_thermostat_child_lock,
tz.saswell_thermostat_window_detection,
Expand All @@ -13738,7 +13735,6 @@ const devices = [
thermostat: {
weeklyScheduleMaxTransitions: 4,
weeklyScheduleSupportedModes: [1], // bits: 0-heat present, 1-cool present (dec: 1-heat,2-cool,3-heat+cool)
weeklyScheduleFirstDayDpId: common.TuyaDataPoints.saswellSchedule,
weeklyScheduleConversion: 'saswell',
},
},
Expand All @@ -13749,8 +13745,8 @@ const devices = [
exposes: [
e.battery_low(), e.window_detection(), e.child_lock(), exposes.climate()
.withSetpoint('current_heating_setpoint', 5, 30, 0.5).withLocalTemperature()
.withSystemMode(['off', 'heat']).withRunningState(['idle', 'heat'])
.withPreset(['Schedule']).withAwayMode(),
.withSystemMode(['off', 'heat', 'auto']).withRunningState(['idle', 'heat'])
.withAwayMode(),
],
},

Expand Down