Script for heating with Danfoss

Moderator: leecollings

Post Reply
koles142
Posts: 2
Joined: Sunday 17 February 2019 12:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Script for heating with Danfoss

Post by koles142 »

Hi.
I'm starting coding in LUA, so sorry if my question is dumb.

I have window sensor xiaomi, temperature sensor xiaomi and Danfoss Living z-wave. I would like make a script:
- when window is closed and time from change status (from open to closed) is <5 min and temperature in room is <25 degrees then set temperautre 20 degrees on danfoss
- when window is opened and temperature in room is <25 degrees set temperature on danfoss to 5 degrees.

Basic script (below) is working:

Code: Select all

commandArray = {}
if (devicechanged['Sypialnia okno'] == 'Closed' and otherdevices['Sypialnia'] < '25')
then
commandArray [ 'SetSetPoint:43']='20' and print('Grzejnik 20 st')
elseif (otherdevices[ 'Sypialnia okno'] == 'Opened' and otherdevices[ 'Sypialnia']<'25')
then
commandArray [ 'SetSetPoint:43']='5' and print('Grzejnik 5 st')
end
return commandArray
but i can't change temperature manually on danfoss for eg. for 23 degrees because automaticaly go back for 20 degrees after connection with z-wave controller. So I need add chcecking time from closed window. I made like this:

Code: Select all

commandArray = {}
function timedifference(timestamp)
  y, m, d, H, M, S = timestamp:match("(%d+)-(%d+)-(%d+) (%d+):(%d+):(%d+)")
  difference = os.difftime(os.time(), os.time{year=y, month=m, day=d, hour=H, min=M, sec=S})
  return difference
end
local Sypialnia okno_changed = false
if (Sypialnia okno_changed ~= nil and devicechanged['Sypialnia okno']) then
    mydevice_changed = true
end

s = otherdevices_lastupdate[ 'Sypialnia okno']
if (otherdevices[ 'Sypialnia okno'] == 'Closed' and timedifference (s) < 600 and not Sypialnia okno_changed and otherdevices[ 'Sypialnia']<'25')
then
commandArray [ 'SetSetPoint:43']='20' and print ("Grzejnik 20 st")
elseif (otherdevices[ 'Sypialnia okno'] == 'Opened' and otherdevices[ 'Sypialnia']<'25')
then
commandArray [ 'SetSetPoint:43']='5' and print("Grzejnik 5 st")
end
return commandArray
but not working. Can somebody help?

Danfoss in Domoticz is named: Sypialnia grzejnik and has idx 43
window sensor in Domoticz is named: Sypialnia okno

Thank You
chrominator
Posts: 19
Joined: Sunday 25 December 2016 7:27
Target OS: Linux
Domoticz version: 2024.7
Contact:

Re: Script for heating with Danfoss

Post by chrominator »

Don't know how to debug this, however there is a built-in function in Danfoss Living Connect that looks like what you're trying to do :
Hope that helps.

Screenshot_2019-02-27 living-connect_VIIDH102 pdf.png
Screenshot_2019-02-27 living-connect_VIIDH102 pdf.png (57.09 KiB) Viewed 777 times
User guide : http://heating.danfoss.com/PCMPDF/livin ... IDH102.pdf
alanlsmith
Posts: 132
Joined: Monday 07 August 2017 17:17
Target OS: Linux
Domoticz version: Latest β
Location: Near London (Saaarf!)
Contact:

Re: Script for heating with Danfoss

Post by alanlsmith »

If it's any help this is a snippet of the code I use to control Danfoss TRVs and when you set them they stay set.

Code: Select all

local TRVidx = 43
local lowsetpoint = 20
local highsetpoint = 25

commandArray[#commandArray+1] = {['OpenURL']='http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx=' ..TRVidx.. '&nvalue=0&svalue='..lowsetpoint }
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest