I found a new way for creating a Switch to control your Toon from Domoticz on the Domoticz WIki, I followed the instructions: https://www.domoticz.com/wiki/Toon
Below I added some screenshots from my switch, and this is my code:
Code: Select all
commandArray = {}
-- Settings: Configure as desired
-- Name of the switch with the temperature setpoint.
ThermostatSetPointName = 'Room Setpoint'
-- Temperature SetPoints.
HomeSetPoint = '20.50'
ComfortSetPoint = '21.00'
SleepSetPoint = '16.00'
AwaySetPoint = '12.00'
OffSetPoint = '6.00' --optional
-- Name of the selector for Toon
ToonSelector = 'Toon scene'
-- Name of the levels in the selector
HomeLevel = 'Thuis'
ComfortLevel = 'Comfort'
SleepLevel = 'Slapen'
AwayLevel = 'Weg'
OffLevel = 'Off' --optional
-- Values from each level name
HomeLevelValue = '30'
ComfortLevelValue = '40'
SleepLevelValue = '20'
AwayLevelValue = '10'
OffLevelValue = '0' --optional
-- End of settings
-- Toon Thermostat SetPoint:
ThermostatSetPoint = otherdevices_svalues[ThermostatSetPointName]
if (ThermostatSetPoint == HomeSetPoint) then
--print("SetPoint equals to Home");
if (otherdevices[ToonSelector] ~= HomeLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. HomeLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..HomeLevelValue
end
elseif (ThermostatSetPoint == ComfortSetPoint) then
--print("SetPoint equals to Comfort");
if (otherdevices[ToonSelector] ~= ComfortLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. ComfortLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..ComfortLevelValue
end
elseif (ThermostatSetPoint == SleepSetPoint) then
--print("SetPoint equals to Sleep");
if (otherdevices[ToonSelector] ~= 'Sleep') then
print("Updating '" .. ToonSelector .. "' selector to '" .. SleepLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..SleepLevelValue
end
elseif (ThermostatSetPoint == AwaySetPoint) then
--print("SetPoint equals to Away");
if (otherdevices[ToonSelector] ~= 'Away') then
print("Updating '" .. ToonSelector .. "' selector to '" .. AwayLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..AwayLevelValue
end
-- Optional
elseif (ThermostatSetPoint == OffSetPoint) then
--print("SetPoint equals to Off");
if (otherdevices[ToonSelector] ~= 'Off') then
print("Updating '" .. ToonSelector .. "' selector to '" .. OffLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..OffLevelValue
end
end
return commandArray
2016-03-15 14:50:48.827 LUA: Updating 'Toon scene' selector to 'Weg'
2016-03-15 14:50:48.828 Error: EventSystem: in Toon scenes: [string "commandArray = {} ..."]:62: attempt to concatenate field '?' (a nil value)
So it does see that the temparture is equal to "Weg" (which is correct) but the switch doesn't get updated. Anybody got an idea what I did wrong?