Page 1 of 1
heater Control
Posted: Friday 23 November 2018 9:26
by honselbonsel
Hi Community,
right now i am testing to install an heater control for the whole house. While i am doing some evaluation - dry run. I had the following effect when steering the valves of the Wallheaters.
In the first version i implemented an logic like - if temp goes below point then valve on - to haet and so on. Works fine but.
if the incoming temp is like 0.1 degress changing the valve goes on and then off / on /off /off so it flaps for measuring tolerance.
The Idea was now to say - lets check the temp over a period of time like 2 minutes and if the temp continuously stays below.... then set a switch so that the heating valve will get on.
The question is now - Is there a simple way in domoticz to measure a value over a period of time like in that graphical stats shown. There must be some access to this data? or just measuring - maybe an lua script may do something.
Thank You - for ideas

Re: heater Control
Posted: Wednesday 28 November 2018 12:44
by Stephan83
You can add a HYSTERESIS to you code. By doing that the difference between the setpoint and the actual switch moment will be a bit more (depending on the value you add).
An example:
in the top of your dzvents code:
Code: Select all
local HYSTERESIS = 0.2 -- temp has to drop this value below setpoint before boiler is on again
At the calculation:
Code: Select all
domoticz.devices('Woonkamer temp').temperature < (domoticz.devices('Woonkamer thermostaat').setPoint - HYSTERESIS)
I think you can also do this in blocky but I did not try.
I used the same mechanism in my multizone heating system see:
viewtopic.php?f=34&t=25882
Re: heater Control
Posted: Tuesday 11 December 2018 16:48
by honselbonsel
Hi, thanks for the reply.
menawhile i developed some ruby scripts which i run as cronjob every 5 minutes.
I share the code here all comments are german- but it is very simple and therfore self explaining.
the point ist that the domoticz db is getting updated every 5 mins. so i have no flapping in temperature.
I have a script for each room. And so i test now the relais and all that stuff
Code: Select all
require 'json'
require 'net/http'
require 'net/https'
require 'sqlite3'
require 'uri'
require 'logger'
require 'date'
d = Time.now
d = d.strftime("%d%m%Y-%H-%M-%s").to_s
logfile = "/var/log/heatscript#{d}.log"
#create Logs of script
logger = Logger.new(logfile)
tempist = 0
#tempSoll
uritsoll = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=devices&rid=34")
restsoll = Net::HTTP.get_response(uritsoll)
resulttsoll= restsoll.body
parsedtsoll = JSON.parse(resulttsoll)
#puts parsed
tempsoll = parsedtsoll ['result'][0]['Data'].to_f
name = parsedtsoll ['result'][0]['Name']
logger.info "Temperatur Soll: #{tempsoll} Grad"
#awaytemp
#
uriawaytemp = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=devices&rid=42")
restawaytemp = Net::HTTP.get_response(uriawaytemp)
resultawaytemp = restawaytemp.body
parsedawaytemp = JSON.parse(resultawaytemp)
awaytemp = parsedawaytemp ['result'][0]['Data'].to_f
#puts "AwayTemp Soll: #{awaytemp} Grad"
logger.info "AwayTemp Soll: #{awaytemp} Grad"
#presence
uripresence = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=devices&rid=72")
restpresence = Net::HTTP.get_response(uripresence)
resultpresence= restpresence.body
parsedpresence = JSON.parse(resultpresence)
presence = parsedpresence ['result'][0]['Status']
#puts "Presence Status: #{presence} "
logger.info {"Presence Status: #{presence} " }
#nighttemp setpointnighttemp41
urinighttemp = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=devices&rid=34")
restnighttemp = Net::HTTP.get_response(urinighttemp)
resultnighttemp = restnighttemp.body
parsednighttemp = JSON.parse(resultnighttemp)
nighttemp = parsednighttemp ['result'][0]['Data'].to_f
#puts "Nachttemp Soll: #{nighttemp} Grad"
logger.info {"Nachttemp Soll: #{nighttemp} Grad " }
#zeitschaltuhrküche38
uritimeswitch = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=devices&rid=38")
resttimeswitch = Net::HTTP.get_response(uritimeswitch)
resulttimeswitch = resttimeswitch.body
parsedtimeswitch = JSON.parse(resulttimeswitch)
timeswitch = parsedtimeswitch ['result'][0]['Status']
logger.info "Zeitschaltuhr Status: #{timeswitch} "
#temp IST
db = SQLite3::Database.open "/pathto/domoticz.db"
db.results_as_hash = true
stm = db.prepare "select temperature from Temperature where DeviceRowID=66 order by rowid desc limit 1"
resultset= stm.execute
resultset.each do |row|
# puts row
$tempist =row["Temperature"].to_f
end
#subroutines Ventile
def valveon
uriswon = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=command¶m=switchlight&idx=13&switchcmd=On")
response = Net::HTTP.get_response(uriswon)
end
def valveoff
uriswoff = URI.parse("http://xxx.xxx.xxx.xxx:8080/json.htm?type=command¶m=switchlight&idx=13&switchcmd=Off")
response = Net::HTTP.get_response(uriswoff)
end
puts $tempist
#Logik: jemand zuhause ja und zeitschaltuhr an
#
#-----------------------------------
case presence
when "On"
case timeswitch
when "On"
if $tempist < tempsoll
logger.info "jemand da und tag Ventil auf"
valveon
else
logger.info "jemand da und tag Ventil schliessen"
valveoff
end
when "Off"
#timeswitch off also Nachtzeit
if $tempist < nighttemp
logger.info "jemand da und nacht Ventil auf"
valveon
else
loggerinfo "jemand da und nacht Ventil schliessen"
valveoff
end
else
logger.error "Error: Timeswitch has an invalid value (#{timeswitch})"
end
when "Off"
logger.info "Presence Status #{presence} Alle Abwesend"
if $tempist < awaytemp
logger.info "keiner da Ventil auf"
valveon
else
logger.info "keiner daVentil schliessen"
valveoff
end
else
logger.error "Error: Presence has an invalid value (#{presence})"
end