Skip to content

Commit

Permalink
v.2.1.0
Browse files Browse the repository at this point in the history
 - Adding valve child device
  • Loading branch information
ikubicki committed Dec 26, 2024
1 parent b4d65db commit 1515894
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 28 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Salus IT600 thermostats integration

Virtual device that allow to control Salus IT600 thermostats. It creates three child devices that show current temperature and humidity. The previous binary switch was removed and replaced with operating status on main device.
Virtual device that allow to control Salus IT600 thermostats. It creates three child devices that show current temperature, humidity and a valve that indicates operating state of the thermostat.

Due to discontinuation of the cloud access, it is necessary to switch to a local mode in Salus Gateway and use a proxy solution.

Expand Down Expand Up @@ -42,6 +42,9 @@ Salus API is locking account for 30 minutes after few invalid login attempts. If

## Change

### v.2.1.0
- Adding valve child device

### v.2.0.0
- Uses local mode
- UX iprovements
Expand Down
2 changes: 1 addition & 1 deletion SalusHumidity.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
Salus humidity sendor child device class
Salus humidity sensor child device class
@author ikubicki
]]

Expand Down
2 changes: 1 addition & 1 deletion SalusTemperature.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
Salus temperature sendor child device class
Salus temperature sensor child device class
@author ikubicki
]]
class 'SalusTemperature' (QuickAppChild)
Expand Down
19 changes: 19 additions & 0 deletions SalusValve.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--[[
Salus valve child device class
@author ikubicki
]]
class 'SalusValve' (QuickAppChild)

function SalusValve:__init(device)
QuickAppChild.__init(self, device)
end

function SalusValve:setName(name)
api.put('/devices/' .. self.id, {
name = name,
})
end

function SalusValve:setValue(value)
self:updateProperty("value", value)
end
25 changes: 13 additions & 12 deletions Salus_It600.fqa

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion i18n.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ phrases = {
['off'] = 'Wyłączony',
['temperature-suffix'] = '%s - Temperatura',
['humidity-suffix'] = '%s - Wilgotność',
['valve-suffix'] = '%s - Zawór',
},
en = {
['name'] = 'Salus - %s',
Expand All @@ -50,6 +51,7 @@ phrases = {
['heating'] = 'Heating',
['off'] = 'Off',
['temperature-suffix'] = '%s - Temperature',
['humidity-suffix'] = '%s - Temperature',
['humidity-suffix'] = '%s - Humidity',
['valve-suffix'] = '%s - Valve',
},
}
52 changes: 40 additions & 12 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--[[
Salus IT600 thermostats integration
@author ikubicki
@version 2.0.0
@version 2.1.0
]]

local REFRESH_BUTTON = "button2_2"
Expand Down Expand Up @@ -43,6 +43,7 @@ function QuickApp:onInit()
self:initChildDevices({
["com.fibaro.temperatureSensor"] = SalusTemperature,
["com.fibaro.humiditySensor"] = SalusHumidity,
["com.fibaro.binarySwitch"] = SalusValve,
})
for id, device in pairs(self.childDevices) do
self.childrenIds[device.type] = id
Expand All @@ -51,16 +52,29 @@ function QuickApp:onInit()
if string.len(self.config:getDeviceID()) > 10 then
if self.childrenIds["com.fibaro.temperatureSensor"] == nil then
local child = self:createChildDevice({
name = self.name .. ' Temperature',
name = string.format(self.i18n:get('temperature-suffix'), self.name),
type = "com.fibaro.temperatureSensor",
initialInterfaces = {"battery"},
}, SalusTemperature)
end
if self.childrenIds["com.fibaro.humiditySensor"] == nil then
local child = self:createChildDevice({
name = self.name .. ' Humidity',
name = string.format(self.i18n:get('humidity-suffix'), self.name),
type = "com.fibaro.humiditySensor",
initialInterfaces = {"battery"},
}, SalusHumidity)
end
if self.childrenIds["com.fibaro.binarySwitch"] == nil then
local child = self:createChildDevice({
name = string.format(self.i18n:get('valve-suffix'), self.name),
type = "com.fibaro.binarySwitch",
initialInterfaces = {"battery"},
initialProperties = {
categories = {"climate"},
deviceRole = "Valve",
},
}, SalusValve)
end
self:run()
else
self:updateView(STATS_LABEL, "text", self.i18n:get('not-configured'))
Expand Down Expand Up @@ -119,27 +133,33 @@ function QuickApp:pullDataFromCloud()
self.failover = false
self:updateView(TITLE_LABEL, "text", "Salus " .. properties.model .. ' - ' .. properties.name)
self:updateView(REFRESH_BUTTON, "text", self.i18n:get('refresh'))

local operatingState = 'Idle'
local isRunningValue = false
if properties.running and properties.running > 0 then
operatingState = 'Heating'
isRunningValue = true
end
if self.childrenIds["com.fibaro.temperatureSensor"] ~= nil then
self.childDevices[self.childrenIds["com.fibaro.temperatureSensor"]]:setValue(properties.temperature)
self.childDevices[self.childrenIds["com.fibaro.temperatureSensor"]]:updateProperty("batteryLevel", SalusUtils:translateBattery(properties.battery))
label2Text = properties.temperature .. "C / " .. properties.heatingSetpoint .. "C"
end
if self.childrenIds["com.fibaro.humiditySensor"] ~= nil then
self.childDevices[self.childrenIds["com.fibaro.humiditySensor"]]:setValue(properties.humidity)
self.childDevices[self.childrenIds["com.fibaro.humiditySensor"]]:updateProperty("batteryLevel", SalusUtils:translateBattery(properties.battery))
label2Text = label2Text .. " / " .. properties.humidity .. "%"
end
local operatingState = 'Idle'
local isRunningValue = 0
if properties.running and properties.running > 0 then
operatingState = 'Heating'
isRunningValue = 1
if self.childrenIds["com.fibaro.binarySwitch"] ~= nil then
self.childDevices[self.childrenIds["com.fibaro.binarySwitch"]]:setValue(isRunningValue)
self.childDevices[self.childrenIds["com.fibaro.binarySwitch"]]:updateProperty("batteryLevel", SalusUtils:translateBattery(properties.battery))
end
self:updateProperty("thermostatOperatingState", operatingState)
if isRunningValue > 0 then
if isRunningValue then
label2Text = self.i18n:get('heating') .. " / " .. label2Text
else
label2Text = self.i18n:get('off') .. " / " .. label2Text
end

self:updateProperty("thermostatOperatingState", operatingState)
self:updateProperty("thermostatMode", SalusUtils:translateHoldType(properties.holdtype))
self:updateProperty("heatingThermostatSetpoint", properties.heatingSetpoint)
self:updateView(STATUS_LABEL, "text", string.format(self.i18n:get('last-update'), os.date('%Y-%m-%d %H:%M:%S')))
Expand Down Expand Up @@ -180,8 +200,11 @@ function QuickApp:searchEvent(param)
self:updateView(STATUS_LABEL, "text", string.format(self.i18n:get('check-select')))
end
local nok = function(r)
local status = '0'
QuickApp:debug(r)
if r and r.status then status = r.status end
self:updateView(SEARCH_BUTTON, "text", self.i18n:get('search-devices'))
self:updateView(STATUS_LABEL, "text", r.status .. ": Unable to pull devices")
self:updateView(STATUS_LABEL, "text", status .. ": Unable to pull devices")
end
self.sdk:searchDevices(searchDevicesCallback, nok)
end
Expand All @@ -203,6 +226,11 @@ function QuickApp:selectDeviceEvent(args)
string.format(self.i18n:get('humidity-suffix'), p.name)
)
end
if self.childrenIds["com.fibaro.binarySwitch"] ~= nil then
self.childDevices[self.childrenIds["com.fibaro.binarySwitch"]]:setName(
string.format(self.i18n:get('valve-suffix'), p.name)
)
end
self:setName(p.name)

end
Expand Down

0 comments on commit 1515894

Please sign in to comment.