Virtual Thermostat

Moderator: leecollings

Post Reply
deve87
Posts: 45
Joined: Saturday 08 April 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Virtual Thermostat

Post by deve87 »

Trying to make this work. When I have otherdevices['Varmeovn WC 1.etg'] == 'On' / 'Off'. Script won't execute.

Code: Select all

Setpoint = tonumber(otherdevices_svalues ['WC 1.etg'])
Temp = tonumber(otherdevices_svalues ['WC 1 etg'])
Hysteresis = 0.5

commandArray = {}
if (devicechanged['WC 1.etg'] or devicechanged['WC 1 etg']) then
if (Temp + Hysteresis < Setpoint) and otherdevices['Varmeovn WC 1.etg'] == 'On' then
    commandArray['Varmeovn WC 1.etg'] = 'Off'
    print ("Varmeovn inaktiv")
elseif
(Temp - Hysteresis > Setpoint) and otherdevices['Varmeovn WC 1.etg'] == 'Off' then
    commandArray['Varmeovn WC 1.etg'] = 'On'
    print ("Varmeovn aktiv")
end
end
return commandArray
When I remove otherdevices['Varmeovn WC 1.etg'] == 'xx' Script works but updates every time temp or setpoint changes (of cours)

Code: Select all

Setpoint = tonumber(otherdevices_svalues ['WC 1.etg'])
Temp = tonumber(otherdevices_svalues ['WC 1 etg'])
Hysteresis = 0.5

commandArray = {}
if (devicechanged['WC 1.etg'] or devicechanged['WC 1 etg']) then
if (Temp + Hysteresis < Setpoint) then
    commandArray['Varmeovn WC 1.etg'] = 'Off'
    print ("Varmeovn inaktiv")
elseif
(Temp - Hysteresis > Setpoint) then
    commandArray['Varmeovn WC 1.etg'] = 'On'
    print ("Varmeovn aktiv")
end
end
return commandArray
Why won't script work when otherdevices['Varmeovn WC 1.etg'] == 'On' / 'Off'' is present? I tried change it with a variable. Same thing
deve87
Posts: 45
Joined: Saturday 08 April 2017 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Virtual Thermostat

Post by deve87 »

Found the problem. When I use otherdevices. I cant use . (dot)
So when I changed otherdevices['Varmeovn WC 1.etg'] to otherdevices['Varmeovn WC 1etg']
Script executes

Code: Select all

Setpoint = tonumber(otherdevices_svalues ['WC 1etg']) -- Dummy Setpoint device
Temp = tonumber(otherdevices_svalues ['WC 1.etg']) -- Temperature sensor
Switch = 'Varmeovn WC 1etg' -- Heater name (do not use symbol like . , - etc and start every word with a big letter like 'Test Switch')
Hysteresis = 0.5 -- Changes stop and start point on Setpoint

commandArray = {}
if Temp - Hysteresis >= Setpoint and otherdevices[Switch] == 'On' then
    commandArray[Switch] = 'Off'
   print('Varme AV')
elseif Temp + Hysteresis <= Setpoint and otherdevices[Switch] == 'Off' then
    commandArray[Switch] = 'On'
    print('Varme PÅ')
end
return commandArray
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest