1414
1515local log = require " log"
1616local capabilities = require " st.capabilities"
17- --- @type st.utils
18- local utils = require " st.utils"
1917--- @type st.zwave.CommandClass
2018local cc = require " st.zwave.CommandClass"
21- --- @type st.zwave.constants
22- local constants = require " st.zwave.constants"
23- --- @type st.zwave.CommandClass.ThermostatSetpoint
24- local ThermostatSetpoint = (require " st.zwave.CommandClass.ThermostatSetpoint" )({ version = 1 })
2519--- @type st.zwave.CommandClass.SensorMultilevel
2620local SensorMultilevel = (require " st.zwave.CommandClass.SensorMultilevel" )({ version = 5 })
2721--- @type st.zwave.CommandClass.ThermostatMode
2822local ThermostatMode = (require " st.zwave.CommandClass.ThermostatMode" )({ version = 2 })
2923
30- local THERMOSTAT_MIN_HEATING_SETPOINT = 5.0
31- local THERMOSTAT_MAX_HEATING_SETPOINT = 30.0
32-
3324local STELPRO_KI_THERMOSTAT_FINGERPRINTS = {
3425 { manufacturerId = 0x0239 , productType = 0x0001 , productId = 0x0001 } -- Stelpro Ki Thermostat
3526}
@@ -44,35 +35,6 @@ local function can_handle_stelpro_ki_thermostat(opts, driver, device, cmd, ...)
4435 return false
4536end
4637
47- local function set_heating_setpoint (driver , device , command )
48- local value = command .args .setpoint
49- if (value >= 40 ) then -- assume this is a fahrenheit value
50- value = utils .f_to_c (value )
51- end
52- if THERMOSTAT_MIN_HEATING_SETPOINT <= value and THERMOSTAT_MAX_HEATING_SETPOINT >= value then
53- local scale = device :get_field (constants .TEMPERATURE_SCALE )
54- if (scale == ThermostatSetpoint .scale .FAHRENHEIT ) then
55- value = utils .c_to_f (value ) -- the device has reported using F, so set using F
56- end
57-
58- local set = ThermostatSetpoint :Set ({
59- setpoint_type = ThermostatSetpoint .setpoint_type .HEATING_1 ,
60- scale = scale ,
61- value = value
62- })
63- device :send_to_component (set , command .component )
64-
65- local follow_up_poll = function ()
66- device :send_to_component (
67- ThermostatSetpoint :Get ({setpoint_type = ThermostatSetpoint .setpoint_type .HEATING_1 }),
68- command .component
69- )
70- end
71-
72- device .thread :call_with_delay (1 , follow_up_poll )
73- end
74- end
75-
7638local function sensor_multilevel_report_handler (self , device , cmd )
7739 if (cmd .args .sensor_type == SensorMultilevel .sensor_type .TEMPERATURE ) then
7840 if cmd .args .scale ~= SensorMultilevel .scale .temperature .CELSIUS and cmd .args .scale ~= SensorMultilevel .scale .temperature .FAHRENHEIT then
@@ -115,22 +77,6 @@ local function thermostat_mode_report_handler(self, device, cmd)
11577 end
11678end
11779
118- local function thermostat_supported_modes_report_handler (self , device , cmd )
119- -- The DTH for this device supported heat and eco, so we've mirrored that here, despite
120- -- the existing, more accurate "energy save heat" mode
121- local supported_modes = {}
122- table.insert (supported_modes , capabilities .thermostatMode .thermostatMode .heat .NAME )
123- table.insert (supported_modes , capabilities .thermostatMode .thermostatMode .eco .NAME )
124-
125- device :emit_event_for_endpoint (
126- cmd .src_channel ,
127- capabilities .thermostatMode .supportedThermostatModes (
128- supported_modes ,
129- { visibility = { displayed = false }}
130- )
131- )
132- end
133-
13480local function set_thermostat_mode (driver , device , command )
13581 local modes = capabilities .thermostatMode .thermostatMode
13682 local mode = command .args .mode
158104
159105local function device_added (self , device )
160106 -- device:emit_event(capabilities.temperatureAlarm.temperatureAlarm.cleared())
107+
108+ -- The DTH for this device supported heat and eco, so we've mirrored that here, despite
109+ -- the existing, more accurate "energy save heat" mode
110+ local supported_modes = {}
111+ table.insert (supported_modes , capabilities .thermostatMode .thermostatMode .heat .NAME )
112+ table.insert (supported_modes , capabilities .thermostatMode .thermostatMode .eco .NAME )
113+
114+ device :emit_event (
115+ capabilities .thermostatMode .supportedThermostatModes (
116+ supported_modes ,
117+ { visibility = { displayed = false }}
118+ )
119+ )
161120end
162121
163122local stelpro_ki_thermostat = {
@@ -168,13 +127,10 @@ local stelpro_ki_thermostat = {
168127 },
169128 [cc .THERMOSTAT_MODE ] = {
170129 [ThermostatMode .REPORT ] = thermostat_mode_report_handler ,
171- [ThermostatMode .SUPPORTED_REPORT ] = thermostat_supported_modes_report_handler
130+ [ThermostatMode .SUPPORTED_REPORT ] = function ( driver , device , cmd ) end
172131 }
173132 },
174133 capability_handlers = {
175- [capabilities .thermostatHeatingSetpoint .ID ] = {
176- [capabilities .thermostatHeatingSetpoint .commands .setHeatingSetpoint .NAME ] = set_heating_setpoint
177- },
178134 [capabilities .thermostatMode .ID ] = {
179135 [capabilities .thermostatMode .commands .setThermostatMode .NAME ] = set_thermostat_mode
180136 }
0 commit comments