Domoticz smart thermostat: Difference between revisions

From IOT4
Jump to navigation Jump to search
(Created page with " <code> local heating_probe = 'Nappali' local thermostat_setpoint = 'Thermo' local heating_unit = 'futes' local hysteresis = 0.1 commandArray = {} -- loop through all the...")
 
No edit summary
Line 1: Line 1:
First create a virtual device Name: Thermo Sensor type: Thermostat setpoint


<code>
 
 
 
<source lang=lua>
local heating_probe = 'Nappali'  
local heating_probe = 'Nappali'  
local thermostat_setpoint = 'Thermo'
local thermostat_setpoint = 'Thermo'
Line 48: Line 52:
return commandArray
return commandArray


</code>
</source>

Revision as of 20:00, 23 May 2017

First create a virtual device Name: Thermo Sensor type: Thermostat setpoint



local heating_probe = 'Nappali' 
local thermostat_setpoint = 'Thermo'
local heating_unit = 'futes'

local hysteresis = 0.1

commandArray = {}


-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
    if (deviceName== thermostat_setpoint ) then
  --      print ("All based event fired1");
      --  print(deviceValue .. "-" ..otherdevices[heating_probe])
        
        if tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then
            
            if (otherdevices[heating_unit] == "On") then
             --   commandArray['SendNotification']='Heating is off'
                commandArray[heating_unit]='Off'
                print("Heating is Off")
            end
            
        elseif tonumber(deviceValue) > tonumber(otherdevices[heating_probe]+hysteresis) then
            -- commandArray['a device name'] = "On"
            -- commandArray['Scene:MyScene'] = "Off"
            if (otherdevices[heating_unit] == "Off") then
                commandArray[heating_unit]='On'
            --    commandArray['SendNotification']='Heating is on'
                print("Heating is On")
            end
        end
    end
end

-- loop through all the variables
for variableName,variableValue in pairs(uservariables) do
--    if (variableName=='myVariable') then
--        if variableValue == 1 then
--            commandArray['a device name'] = "On"
--            commandArray['Group:My Group'] = "Off AFTER 30"
--        end
--    end
end

return commandArray