Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-thermostat/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ zwaveManufacturer:
deviceLabel: Fibaro Thermostat
manufacturerId: 0x010F
productType: 0x1301
deviceProfileName: base-radiator-thermostat-10to30C
deviceProfileName: fibaro-heat-controller
- id: "0239/0001/0001"
deviceLabel: Stelpro Ki Thermostat
manufacturerId: 0x0239
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: fibaro-heat-controller
components:
- id: main
capabilities:
- id: temperatureMeasurement
version: 1
- id: thermostatHeatingSetpoint
version: 1
config:
values:
- key: "heatingSetpoint.value"
range: [ 10, 30 ]
- id: thermostatMode
version: 1
- id: battery
version: 1
- id: refresh
version: 1
categories:
- name: Thermostat
preferences:
- name: "regulatorBehaviour"
title: "Regulator Behaviour"
description: "Change regulator behaviour from Rapid to Moderate"
preferenceType: enumeration
required: true
definition:
options:
0: "Rapid"
64: "Moderate"
default: '0'
- preferenceId: tempOffset
explicit: true
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@ components:
- id: battery
version: 1
categories:
- name: GenericSensor
- name: GenericSensor
preferences:
- name: "regulatorBehaviour"
title: "Regulator Behaviour"
description: "Change regulator behaviour from Rapid to Moderate"
preferenceType: enumeration
required: true
definition:
options:
0: "Rapid"
64: "Moderate"
default: '0'
- preferenceId: tempOffset
explicit: true
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local Configuration = (require "st.zwave.CommandClass.Configuration")({version=1
local ApplicationStatus = (require "st.zwave.CommandClass.ApplicationStatus")({version=1})

local utils = require "st.utils"
local log = require "log"

local FIBARO_HEAT_FINGERPRINTS = {
{mfr = 0x010F, prod = 0x1301, model = 0x1000}, -- Fibaro Heat Controller
Expand All @@ -37,6 +38,8 @@ local FIBARO_HEAT_FINGERPRINTS = {

local FORCED_REFRESH_THREAD = "forcedRefreshThread"

local REGULATOR_BEHAVIOUR_DATA = {parameter_number = 2, size = 4, }

local function can_handle_fibaro_heat_controller(opts, driver, device, ...)
for _, fingerprint in ipairs(FIBARO_HEAT_FINGERPRINTS) do
if device:id_match(fingerprint.mfr, fingerprint.prod, fingerprint.model) then
Expand Down Expand Up @@ -72,7 +75,7 @@ local function configuration_report_handler(self, device, cmd)
device:send_to_component(SensorMultilevel:Get({}), "extraTemperatureSensor")
device:send_to_component(Battery:Get({}), "extraTemperatureSensor")
elseif (cmd.args.configuration_value == 0 and utils.table_size(device.st_store.profile.components) > 1) then
device:try_update_metadata({profile = "base-radiator-thermostat"})
device:try_update_metadata({profile = "fibaro-heat-controller"})
end
end
end
Expand Down Expand Up @@ -129,6 +132,7 @@ local function do_refresh(self, device)
device:send(ThermostatSetpoint:Get({setpoint_type = ThermostatSetpoint.setpoint_type.HEATING_1}))
device:send(Battery:Get({}))
device:send(Configuration:Get({parameter_number = 3}))

end

local function endpoint_to_component(device, endpoint)
Expand All @@ -147,9 +151,17 @@ local function component_to_endpoint(device, component)
end
end

local function map_components(self, device)
local function device_init(self, device, args)
device:set_endpoint_to_component_fn(endpoint_to_component)
device:set_component_to_endpoint_fn(component_to_endpoint)

if not device.preferences["regulatorBehaviour"] then
if utils.table_size(device.st_store.profile.components) > 1 then
device:try_update_metadata({profile = "fibaro-heat-extra-sensor"})
else
device:try_update_metadata({profile = "fibaro-heat-controller"})
end
end
end

local function device_added(self, device)
Expand All @@ -163,6 +175,17 @@ local function device_added(self, device)
do_refresh(self, device)
end

local function info_changed (self, device, event, args)
for name, info in pairs(device.preferences) do
if (device.preferences[name] ~= nil and args.old_st_store.preferences[name] ~= device.preferences[name] ) then
local input = device.preferences[name]
if (name == "regulatorBehaviour") then
device:send(Configuration:Set({ parameter_number = REGULATOR_BEHAVIOUR_DATA.parameter_number, size = REGULATOR_BEHAVIOUR_DATA.size, configuration_value = input }))
end
end
end
end

local fibaro_heat_controller = {
NAME = "fibaro heat controller",
zwave_handlers = {
Expand All @@ -187,7 +210,8 @@ local fibaro_heat_controller = {
},
lifecycle_handlers = {
added = device_added,
init = map_components
init = device_init,
infoChanged = info_changed
},
can_handle = can_handle_fibaro_heat_controller
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ local thermostat_endpoints = {

local mock_device = test.mock_device.build_test_zwave_device(
{
profile = t_utils.get_profile_definition("base-radiator-thermostat.yml"),
profile = t_utils.get_profile_definition("fibaro-heat-controller.yml"),
zwave_endpoints = thermostat_endpoints,
zwave_manufacturer_id = 0x010F,
zwave_product_id = 0x1000,
Expand All @@ -56,10 +56,23 @@ local mock_device_extended = test.mock_device.build_test_zwave_device(
}
)

local mock_device_old_profile = test.mock_device.build_test_zwave_device(
{
profile = t_utils.get_profile_definition("base-radiator-thermostat.yml"),
zwave_endpoints = thermostat_endpoints,
zwave_manufacturer_id = 0x010F,
zwave_product_id = 0x1000,
zwave_product_type = 0x1301,
}
)

local function test_init()
test.mock_device.add_test_device(mock_device)
test.mock_device.add_test_device(mock_device_extended)
test.mock_device.add_test_device(mock_device_old_profile)
mock_device_old_profile:expect_metadata_update({profile = "fibaro-heat-controller"})
end

test.set_test_init_function(test_init)

test.register_message_test(
Expand Down Expand Up @@ -293,6 +306,24 @@ test.register_message_test(
}
)

test.register_coroutine_test( "device should receive changes from regulator behaviour setting change",
function()
test.socket.zwave:__set_channel_ordering("relaxed")
test.socket.device_lifecycle:__queue_receive(mock_device:generate_info_changed(
{
preferences = {
regulatorBehaviour = 64,
}
}
))
test.socket.zwave:__expect_send(
zw_test_utilities.zwave_test_build_send_command(
mock_device,
Configuration:Set({parameter_number = 2, size = 4, configuration_value = 64})
)
)
end)

test.register_coroutine_test(
"Device should be polled after receiving ApplicationBusy command",
function()
Expand Down
Loading