I solved it with a file on the SD card:
Code: Select all
local myFile = "www/LightSettings.json"
local f = assert(io.open(myFile, "r"))
local t = f:read("*all")
f:close()
Then you can read the json from t
Moderator: leecollings
Code: Select all
local myFile = "www/LightSettings.json"
local f = assert(io.open(myFile, "r"))
local t = f:read("*all")
f:close()
Can you try this one ? (moved from JSON formatted var to internal / persistent data)Skippiemanz wrote: ↑Friday 30 November 2018 17:31 Maybe anyone has a idea for the user variables limitation
Code: Select all
--[[
version: 20181130-02
This script manage the different heating zones
Before making this script active you should first enter your rooms , sensors and valves indexes below in function initPersistent
define a switch for chiller if there is a main switch
define a switch for heater if there is a main switch
the value heater is the idx or name of the main heater switch. If your system does not have this, leave it out completely
the value cooler is the idx or name of the main cooler switch. If your system does not have this, leave it out completely.
the value selector is the idx or name of the selector switch that control if the heating or cooling system is active or stopped both.
the values room1, room2 etc, are the zonenames or roomnames and can be changed
the value after "s" is the id of the setpoint device in that room
the value after "t" is the id of the temperature sensor in that room
the value after "v" is the id of the radiator valve in that room (can be valvetype switch or valvetype setPoint )
idx are without "" and names are with ""
Change history:
20181012-01 Initial setup
20181012-02 Add Season selector
20181012-03 Add optional control for main heater / cooler device. Moved some code to functions
20181012-04 Add optional control for main heater / cooler device
20181013-01 Moved heater, cooler and selector idx to (JSON) uservariable
20181014-01 Bugfixes: defined local heating inside if block causing it to be nil.
return false from open and shut function could overwrite previous true state
20181114-01 Open and Shut also for setPoint TRV's
20181130-01 Add On and Off Hysterisis
20181130-02 Use internal / persistent table for systems with more than 3 rooms
]]--
return {
on = { timer = { "every minute" }, -- adjust to your needs
},
logging = { level = domoticz.LOG_DEBUG, -- Comment this and the next line if script execute as expected
marker = "zoneTemperatures" },
data = { heating = { initial = {} },
},
execute = function(dz)
-- initialize table
t = {}
openTemperature = 28
closeTemperature = 16.5
local function initPersistent()
t.heater = 1095
t.cooler = 1096
t.selector = "Season"
t.rooms = {}
t.rooms = { -- Fill table below with roomNames, setPoint IDX, temp sensors IDX,and valve IDX
{room="room1",s=1088,t=144,v=1093},
{room="room2",s=1089,t=145,v=1094},
{room="room3",s=1090,t=146,v=1095},
{room="room4",s=1091,t=147,v=1096},
{room="room5",s=1092,t=148,v=1097},
}
dz.data.heating = t
end
-- do everything :-)
local function processRooms(t)
local heating if t.heater ~= nil then heating = dz.devices(t.heater) end
local cooling if t.cooler ~= nil then cooling = dz.devices(t.cooler) end
local action if t.selector ~= nil then action = dz.devices(t.selector).levelName else action = "Heating" end -- defaults to "Heating"
local hysteresisOn = 0.5
local hysteresisOff = 0.2
local openHeatingValves
local openCoolingValves
local function open(device)
if device == nil then return openHeatingValves end
if device.deviceSubType == "SetPoint" then
device.updateSetPoint(openTemperature)
else
device.switchOn().checkFirst()
end
return true
end
local function shut(device)
if device == nil then return openCoolingValves end
if device.deviceSubType == "SetPoint" then
device.updateSetPoint(closeTemperature)
else
device.switchOff().checkFirst()
end
end
for i=1,#t.rooms do -- loop trough the rooms
local roomName = t.rooms[i].room
local setPoint = dz.devices(t.rooms[i].s).setPoint
local temperature = dz.devices(t.rooms[i].t).temperature
local radiatorValve = dz.devices(t.rooms[i].v)
if action == "Cooling" then
if temperature < setPoint then shut(radiatorValve) -- stop cooling
elseif temperature > ( setPoint + hysteresis ) then openCoolingValves = open(radiatorValve) end --start cooling
elseif action == "Heating" then
if temperature > ( setPoint - hysteresisOff ) then shut(radiatorValve) -- stop heating
elseif temperature < ( setPoint - hysteresisOn ) then openHeatingValves = open(radiatorValve) end --start heating
elseif action == "Stop" then
shut(cooling) shut(heating) shut(radiatorValve)
end
end
if openCoolingValves then open(cooling) else shut(cooling) end
if openHeatingValves then open(heating) else shut(heating) end
end
-- Get table from init function or persistent data
if not next(dz.data.heating) then
initPersistent()
else
t = dz.data.heating
end
processRooms(t)
end
}
waaren wrote: ↑Friday 30 November 2018 20:13Can you try this one ? (moved from JSON formatted var to internal / persistent data)Skippiemanz wrote: ↑Friday 30 November 2018 17:31 Maybe anyone has a idea for the user variables limitation
Code: Select all
--[[ version: 20181130-02 This script manage the different heating zones Before making this script active you should first enter your rooms , sensors and valves indexes below in function initPersistent define a switch for chiller if there is a main switch define a switch for heater if there is a main switch the value heater is the idx or name of the main heater switch. If your system does not have this, leave it out completely the value cooler is the idx or name of the main cooler switch. If your system does not have this, leave it out completely. the value selector is the idx or name of the selector switch that control if the heating or cooling system is active or stopped both. the values room1, room2 etc, are the zonenames or roomnames and can be changed the value after "s" is the id of the setpoint device in that room the value after "t" is the id of the temperature sensor in that room the value after "v" is the id of the radiator valve in that room (can be valvetype switch or valvetype setPoint ) idx are without "" and names are with "" Change history: 20181012-01 Initial setup 20181012-02 Add Season selector 20181012-03 Add optional control for main heater / cooler device. Moved some code to functions 20181012-04 Add optional control for main heater / cooler device 20181013-01 Moved heater, cooler and selector idx to (JSON) uservariable 20181014-01 Bugfixes: defined local heating inside if block causing it to be nil. return false from open and shut function could overwrite previous true state 20181114-01 Open and Shut also for setPoint TRV's 20181130-01 Add On and Off Hysterisis 20181130-02 Use internal / persistent table for systems with more than 3 rooms ]]-- return { on = { timer = { "every minute" }, -- adjust to your needs }, logging = { level = domoticz.LOG_DEBUG, -- Comment this and the next line if script execute as expected marker = "zoneTemperatures" }, data = { heating = { initial = {} }, }, execute = function(dz) -- initialize table t = {} openTemperature = 28 closeTemperature = 16.5 local function initPersistent() t.heater = 1095 t.cooler = 1096 t.selector = "Season" t.rooms = {} t.rooms = { -- Fill table below with roomNames, setPoint IDX, temp sensors IDX,and valve IDX {room="room1",s=1088,t=144,v=1093}, {room="room2",s=1089,t=145,v=1094}, {room="room3",s=1090,t=146,v=1095}, {room="room4",s=1091,t=147,v=1096}, {room="room5",s=1092,t=148,v=1097}, } dz.data.heating = t end -- do everything :-) local function processRooms(t) local heating if t.heater ~= nil then heating = dz.devices(t.heater) end local cooling if t.cooler ~= nil then cooling = dz.devices(t.cooler) end local action if t.selector ~= nil then action = dz.devices(t.selector).levelName else action = "Heating" end -- defaults to "Heating" local hysteresisOn = 0.5 local hysteresisOff = 0.2 local openHeatingValves local openCoolingValves local function open(device) if device == nil then return openHeatingValves end if device.deviceSubType == "SetPoint" then device.updateSetPoint(openTemperature) else device.switchOn().checkFirst() end return true end local function shut(device) if device == nil then return openCoolingValves end if device.deviceSubType == "SetPoint" then device.updateSetPoint(closeTemperature) else device.switchOff().checkFirst() end end for i=1,#t.rooms do -- loop trough the rooms local roomName = t.rooms[i].room local setPoint = dz.devices(t.rooms[i].s).setPoint local temperature = dz.devices(t.rooms[i].t).temperature local radiatorValve = dz.devices(t.rooms[i].v) if action == "Cooling" then if temperature < setPoint then shut(radiatorValve) -- stop cooling elseif temperature > ( setPoint + hysteresis ) then openCoolingValves = open(radiatorValve) end --start cooling elseif action == "Heating" then if temperature > ( setPoint - hysteresisOff ) then shut(radiatorValve) -- stop heating elseif temperature < ( setPoint - hysteresisOn ) then openHeatingValves = open(radiatorValve) end --start heating elseif action == "Stop" then shut(cooling) shut(heating) shut(radiatorValve) end end if openCoolingValves then open(cooling) else shut(cooling) end if openHeatingValves then open(heating) else shut(heating) end end -- Get table from init function or persistent data if not next(dz.data.heating) then initPersistent() else t = dz.data.heating end processRooms(t) end }
Can you please elaborate on the "not managing to get it working bit" ?JvDorst wrote: ↑Sunday 27 January 2019 21:30 The developed scripts look usefull for my situation. More specific, I use the following devices 4 Popp radiator valves, 2 Honeywell radiator valves (controlled by Fibaro switches) and a thermostat (Essent e-thermostat). Unfortunately I'm not managing to get it working.
Users browsing this forum: No registered users and 1 guest