Toon selector script: names to idx

Moderator: leecollings

Post Reply
User avatar
HansieNL
Posts: 964
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Toon selector script: names to idx

Post by HansieNL »

I wanna change the script to use idx numbers instead of names for ThermostatSetPointName and ToonSelector.
Now I have to use different names for the setpoint and selector switch and wanna have same name because both using the same hardware/device.
Can someone tell me how to change this script?

Code: Select all

-- script_time_toonselector.lua
-- Reads the Toon Thermostat Setpoint Temperature and updates the
-- selector in Domoticz to represent the current Active State.
-- Off scene is an option, leave it out if not needed.
-- Action commands will not be executed.
 
commandArray = {}
 
-- Settings: Configure as desired
 
-- Name of the switch with the temperature setpoint.
ThermostatSetPointName = 'Room Setpoint' --Must match the name of you SetPoint device
 
-- Temperature SetPoints.
OffSetPoint = '6.00' --optional 
AwaySetPoint = '17.50'
SleepSetPoint = '19.00' 
HomeSetPoint = '20.50'   
ComfortSetPoint = '21.00'
 
-- Name of the selector for Toon
ToonSelector = 'Toon Scenes' --Must match (including case) the name of your Selector Switch
 
-- Name of the levels in the selector
OffLevel = 'Off' --optional
AwayLevel = 'Away'
SleepLevel = 'Sleep'
HomeLevel = 'Home'
ComfortLevel = 'Comfort'
 
-- Values from each level name
OffLevelValue = '0' --optional
AwayLevelValue = '10'
SleepLevelValue = '20'
HomeLevelValue = '30'
ComfortLevelValue = '40'
 
-- 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] ~= SleepLevel) 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] ~= AwayLevel) 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] ~= OffLevel) then
		print("Updating '" .. ToonSelector .. "' selector to '" .. OffLevel .. "'")
		commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..OffLevelValue
		end
end
 
return commandArray
Blah blah blah
User avatar
lonebaggie
Posts: 86
Joined: Tuesday 31 January 2017 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: England
Contact:

Re: Toon selector script: names to idx

Post by lonebaggie »

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest