Request: Help for Danfoss LC13 issues

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Request: Help for Danfoss LC13 issues

Post by mcmikev »

Hi,

I use the heating script to heat my rooms.
Per room i have a temp/hum sensor and a Danfoss LC13 per heating unit.
I don't have a boiler but city heating. So I use a virtual switch to start or stop the heating.
That virtual switch changes to On or Off and that triggers an lua script that commandarray update device my LC13 device.

I already have a repeat in the dzvent script turn on after 3 min and turn off after 3 min to make sure that the valve is shut or opened.
This sometimes is not the case so the room wil remain cold or heats up to tropical temps.
My wife and young kids don't like either :-)

Even though the repeat on or off command is there it still sometimes does not work.
And NO there is no problem with my Z-wave network. I have ,anu always on devices per room and floor so that every device is always "connected".
The command is given and for example in the livingroom there are 2 heaters and then the left one closes but the right one remains open.
Weird and defeninitly unwanted!

I would like to have the following: (have searched my head off but cannot find it)
When heating is off and the temp is higher then setpoint, check if the LC13 device is higher then 5 degrees if so then turn it off again, and again if needed. (switch of the virtual switch again or direct change the LC13 setpiont to 5)
This will make sure that the heater must close sometime to prevent overheating.

Can someone help me out with this? Preverable in the scripts made by Dannybloe and described here (viewtopic.php?f=59&t=18258&p=140661&hilit=lc13#p140661

Thank you
arkoko
Posts: 34
Joined: Saturday 17 December 2016 12:13
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Estonia
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by arkoko »

Your LC13 are battery powered and thus they wakeup for listening periodically (probably each 5 minutes) and if you send commands more often, then some of commands can be unseen by thermostat. Maybe there is reason of script unstable work?

Sent from my SM-T585 using Tapatalk
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

Can’t you make a timer script that exactly does this checking? Periodically check for that specific unwanted situation.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

Can’t you make a timer script that exactly does this checking? Periodically check for that specific unwanted situation.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

I would like to :-) But don't know how to code that.

How to read the current setpoint value on the LC13 with dzventz? or with lua ?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

Ok, it should be fairly easy with dzVents. First you have to check if you can read the current setpoint value. See the documentation.

Code: Select all

return {
	on = {
		timer = { 'every minute'}
	},
	execute = function(domoticz, timer) 
		domoticz.log(domoticz.devices('name of the setpoint valve').setPoint) -- fill in the name or idx of the valve
	end
}
So this script is just a test to see if you can read the current setpoint. Lemme know if you see the current value.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

Tried it but no value

Code: Select all

2017-11-26 14:13:00.542 dzVents: Info: ------ Start internal script: 0-Test:, trigger: every minute
2017-11-26 14:13:00.574 dzVents: Info: ------ Finished 0-Test
Named the script 0-Test by the way
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

Had to change the logging level. No i see the setpoint in INFO

Code: Select all

2017-11-26 14:16:00.574 dzVents: Info: ------ Start internal script: 0-Test:, trigger: every minute
2017-11-26 14:16:00.590 dzVents: Info: 24
2017-11-26 14:16:00.590 dzVents: Info: ------ Finished 0-Test
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

Ok, that's a start :)
Cozy temperature though :)
Anyway... so, now you have to create some testing logic. Let's say you do this every minute:

Code: Select all

return {
	on = {
		timer = { 'every minute'}
	},
	execute = function(domoticz, timer)
		local valve = domoticz.devices('valvedevicename')
		local temperature = domoticz.devices(' tempdevicename').temperature
		local heating = domoticz.device('...dummy switch..')
		
		if (heating.state == 'Off' and temperature > setPoint) then
			-- temperature is too high, send off command
			valve.switchOff() -- assuming you can do that with this device
		end
	end
}
Just a rough sketch, but this is the idea.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

Hi this temp is not the room temp but the temp on de LC13 on the radiator. It must be higher than the setpoint of the roomthermostat (virtual) otherwise no heating.
The LC13 cannot turned off. You can set temp. Lowest =5 highest is 28 (degrees)

So how to do that then?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

Ah, ok, well, I think you get the idea here. Just check your devices and create some logic to deal with your valves. So instead of switching the device off you probably change the setpoint?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

Yes I change the setpoint by means of lua code

Code: Select all

commandArray = {}
     if (devicechanged['State-CV-WK'] == 'On' and otherdevices['TempHi-WK'] == 'Off') then
         commandArray[1]={['UpdateDevice']='310|0|23'}
         commandArray[2]={['UpdateDevice']='312|0|23'}
     elseif (devicechanged['State-CV-WK'] == 'Off') then
         commandArray[1]={['UpdateDevice']='310|0|5'}
         commandArray[2]={['UpdateDevice']='312|0|5'}
But how to send setpoint from dzventz to this device?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

eww.. use dzVents for this. This code is unreadable for me.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

:-) that is why I asked how to set setpoint with dzventz LOL
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

haha.. ok.. well, first of all, read the documentation :)
Second, each device, depending on what kind of device it is, has different attributes and methods. In this case it is a setpoint device and it has a setPoint property and an updateSetPoint() method: Thermostat set point.
So you would do something like this: domoticz.devices('my valve').updateSetPoint(22) or something like that.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

Hi,

I thought to be smart and change the code to update the setpoint instead of the switch.
It does work but the setpoint goes from 5 to 24 with this example code.
it turns to 5, some minutes later to 24 and vice versa.

Code: Select all

if (avgTemp >= setpointValue and boiler.state == 'On' or domoticz.devices('CV-Badkamer').setPoint>5) then
         if LOGGING then domoticz.log('Target temperature reached, boiler off') end
         --domoticz.notify('CV Badkamer uit', 'Temp hoger dan Setpoint', domoticz.PRIORITY_NORMAL)
         boiler.switchOff()
         domoticz.devices('CV-Badkamer').updateSetPoint(5)
      end

      if (avgTemp < setpointValue and boiler.state == 'Off' and override.state == 'Off' or domoticz.devices('CV-Badkamer').setPoint<15) then
         if (avgTemp < switchOnTemp) then
            if LOGGING then domoticz.log('Heating is required, boiler switched on') end
            --domoticz.notify('CV Badkamer aan', 'Temp lager dan Setpoint', domoticz.PRIORITY_NORMAL)
            boiler.switchOn()
            domoticz.devices('CV-Badkamer').updateSetPoint(24)
         else
            if LOGGING then domoticz.log('Average temperature below setpoint but within hysteresis range, waiting for temperature to drop to ' .. switchOnTemp) end
         end
      end
Any view that can help me out if there is something wrong?

This code should check if heating is needed or not. If not and the setpoint is higher then 5 then put setpoint to 5 else if heating is needed and setpoint is lower than 15 then put setpioint on 24
The boiler switch is only for visible status of heating or not heating mode.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by dannybloe »

First of all, use the logging option to control specific module logging instead of creating your own LOGGING switches. Keeps the code clean ;-)

I haven't looked at it closely yet but could it be that your if-conditions need some parenthesis? A and B or C ... I never use that just to make sure it behaves like I want it: (A and B) or C .. A and (B or C)... totally different results.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mcmikev
Posts: 146
Joined: Tuesday 26 May 2015 8:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: right here
Contact:

Re: Request: Help for Danfoss LC13 issues

Post by mcmikev »

Figured it out and got it working with some headache :-)
In stead of flipping a switch I now check the thermostat valve (Danfoss LC-13) for the setpiont level and If that is above or below a specific level then do start the heating by setting the setpoint on the LC-13. It does flip a dummy switch so you can see if the heating is on or off (handy with HomeKit app on iPhone)

I post it here, maybe someone can use it, or make it even better! Thank you @dannybloe for getting me started.

Code: Select all

-- assumptions:
-- the setpoint is set by a selector dummy device where the values are numeric temperatures
-- but you can easily change it to a setpoint device

local BOILER_DEVICE = 'State-CV-WK' -- switch device to display on or off mode heating
local SETPOINT_DEVICE = 'Thermostaat WK' -- selector dummy device thermostat
local TEMPERATURE_SENSOR = 'TH-Woonkamer' -- temp sensor
local HYSTERESIS = 0.2 -- temp has to drop this value below setpoint before boiler is on again
local SMOOTH_FACTOR = 3 --number of readings to even out the temp
local OVERRIDE_SWITCH = 'CV-WK-Override' -- override switch to prevent heating to turn on

return {
   on = {
      timer = { 'every minute' },
      device = { TEMPERATURE_SENSOR, SETPOINT_DEVICE }
   },
   data = {
      temperatureReadings = { history = true, maxItems = SMOOTH_FACTOR }
   },
   logging = {
    level = domoticz.LOG_INFO, --log level can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
    marker = "CV-Woonkamer" --info to see what device did what in the log
    },
   active = true,
   execute = function(domoticz, device, triggerInfo)

      local avgTemp
      local temperatureReadings = domoticz.data.temperatureReadings
      local boiler = domoticz.devices(BOILER_DEVICE)
      local setpoint = domoticz.devices(SETPOINT_DEVICE)
      local override = domoticz.devices(OVERRIDE_SWITCH)
      local sensor = domoticz.devices(TEMPERATURE_SENSOR)
      local current = sensor.temperature

      -- first check if the sensor got a new reading or the setpoint was changed:
      if (triggerInfo.type == domoticz.EVENT_TYPE_DEVICE) then

         if (sensor.changed) then
            -- sensor just reported a new reading
            -- add it to the readings table

            if (current ~= 0 and current ~= nil) then
               temperatureReadings.add(current)
            else
               -- no need to be here, weird state detected
               domoticz.log('Strange sensor reading.. skiping', domoticz.LOG_ERROR)
               return
            end

         elseif (domoticz.devices(SETPOINT_DEVICE).changed) then
            -- a new setpoint was set
             domoticz.log('Setpoint was set to ' .. device.state)
         else
            -- no business here, bail out...
            return
         end
      end

      -- now determine what to do

      if (setpoint.state == nil or setpoint.state == 'Off') then
         domoticz.devices('CV-WK-L').updateSetPoint(5)
         domoticz.devices('CV-WK-R').updateSetPoint(5)
         domoticz.devices('State-CV-WK').switchOff().checkFirst()
         return -- we're done here
      end

      local setpointValue = tonumber(setpoint.state)
      -- determine at which temperature the boiler should be
      -- switched on
      local switchOnTemp = setpointValue - HYSTERESIS
      -- don't use the current reading but average it out over
      -- the past <SMOOTH_FACTOR> readings (data smoothing) to get rid of noise, wrong readings etc
      --local avgTemp = temperatureReadings.avg(1, SMOOTH_FACTOR)
      
      local avgTemp = temperatureReadings.avg(1, SMOOTH_FACTOR, current)
         domoticz.log('Average Temp: ' .. avgTemp)
         domoticz.log('Setpoint: ' .. setpointValue)
         domoticz.log('Heating On or Off: ' .. boiler.state)
         domoticz.log('Heating starting at: ' .. switchOnTemp)
      
      if (avgTemp >= setpointValue and (domoticz.devices('CV-WK-L').setPoint>5 or domoticz.devices('CV-WK-R').setPoint>5)) then
         domoticz.log('Target temperature reached, boiler off')
         domoticz.notify('CV WK uit', 'Temp hoger dan Setpoint', domoticz.PRIORITY_LOW)
         domoticz.devices('CV-WK-L').updateSetPoint(5)
         domoticz.devices('CV-WK-R').updateSetPoint(5)
         domoticz.devices('State-CV-WK').switchOff().checkFirst()
     end

      if (avgTemp < setpointValue and (domoticz.devices('CV-WK-L').setPoint<15 or domoticz.devices('CV-WK-R').setPoint<15)) then
         if (avgTemp < switchOnTemp) then
            domoticz.log('Heating needed, heater on')
            domoticz.notify('CV WK aan', 'Temp is lager dan Setpoint', domoticz.PRIORITY_LOW)
            boiler.switchOn()
            domoticz.devices('CV-WK-L').updateSetPoint(24)
            domoticz.devices('CV-WK-R').updateSetPoint(24)
            domoticz.devices('State-CV-WK').switchOn().checkFirst()
         else
            domoticz.log('Average temperature below setpoint but within hysteresis range, waiting for temperature to drop to ' .. switchOnTemp)
         end
      end

--      if ('boiler.state == 'On' and override.state == 'On') then
--           domoticz.log('Override is aan, CV Gang UIT') end
         --domoticz.notify('CV Gang Override', 'Override is aan CV gaat niet aan!', domoticz.PRIORITY_NORMAL)
--         boiler.switchOff()
--            domoticz.devices('CV-Gang').updateSetPoint(5)
--         domoticz.devices('CV-Gang').updateSetPoint(5)
--      end
   end
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest