Script Heating Control Issues  [Solved]

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

Moderator: leecollings

Post Reply
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Script Heating Control Issues

Post by jkimmel »

I'm still playing around with the following script

Code: Select all

-- assumptions:
-- the setpoint is set by a selector dummy device where the values are numeric temperatures

local BOILER_DEVICE = 'FB 42 Heizkreis Bad' -- switch device
local INFRAROT_DEVICE = 'FB 31 Infrarot'      -- switch device
local SETPOINT_DEVICE = 'Solltemperatur Bad' -- selector dummy device
local TEMPERATURE_SENSOR = 'Bad'
local MODUS_DEVICE = 'Modus Waermepumpe' -- selector dummy device
local LOGGING = true

return {
	on = {
		
	timer = {'every 10 minutes'},
	
	    logging =   
    {
        level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
        marker = 'setSetpoint', 
    },


	active = true,
	execute = function(domoticz, timer)

		local sensor = domoticz.devices(TEMPERATURE_SENSOR)
		local current = sensor.temperature
		local boiler = domoticz.devices(BOILER_DEVICE)
		local setpoint = domoticz.devices(SETPOINT_DEVICE)
		local modus = domoticz.devices(MODUS_DEVICE)
		local infrarot = domoticz.devices(INFRAROT_DEVICE)
		
	    
		-- now determine what to do
		if (setpoint.state == nil or setpoint.state == 'Off') then
			boiler.switchOff()
			infrarot.switchOff()
			return -- we're done here
		end

		local setpointValue = tonumber(setpoint.state)


		if LOGGING then
			domoticz.log('Setpoint: ' .. setpointValue, domoticz.LOG_DEBUG)
			domoticz.log('Current boiler state: ' .. boiler.state, domoticz.LOG_DEBUG)
		end

		if (current > setpointValue and boiler.state == 'On') then
			if LOGGING then domoticz.log('Target temperature reached, boiler off') end
			boiler.switchOff()
			infrarot.switchOff()
		end

		if (current <= setpointValue and boiler.state == 'Off' and  modus.state == 'Heizen' ) then
			if LOGGING then domoticz.log('Target temperature not reached, boiler on') end
		boiler.switchOn()
		infrarot.switchOn()
		
		end
end
}
}
I skipped smoothing, hysteresis and triggering by device.
I think monitoring temperature and setpoint every 10 minutes does the job.
But the script as is does not switch the devices as it should so I need help oncemore.

The days coming I'll have a lot of time tinkering around because here (Mallorca) we are bound to stay at home at least the next week ;)
Rfxcom
Raspi 4
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Script Heating Control Issues

Post by waaren »

jkimmel wrote: Saturday 14 March 2020 16:16 But the script as is does not switch the devices as it should so I need help oncemore.
can you try this and if not working yet share what you see in the log ?

Code: Select all

-- assumptions:
-- the setpoint is set by a selector dummy device where the values are numeric temperatures

local BOILER_DEVICE = 'FB 42 Heizkreis Bad' -- switch device
local INFRAROT_DEVICE = 'FB 31 Infrarot'      -- switch device
local SETPOINT_DEVICE = 'Solltemperatur Bad' -- selector dummy device
local TEMPERATURE_SENSOR = 'Bad'
local MODUS_DEVICE = 'Modus Waermepumpe' -- selector dummy device
local LOGGING = true

return 
{
    on = 
    {
        timer = 
        {
            'every 10 minutes'
        },
    },

    logging =   
    {
        level = LOGGING and domoticz.LOG_DEBUG or domoticz.LOG_ERROR,
        marker = 'setSetpoint', 
    },

    execute = function(dz)

        local boiler = dz.devices(BOILER_DEVICE)
        local infrarot = dz.devices(INFRAROT_DEVICE)

        local temperature = dz.devices(TEMPERATURE_SENSOR).temperature
        local setpoint = dz.devices(SETPOINT_DEVICE).levelName
        local modusState = dz.devices(MODUS_DEVICE).state

        local boilerState = boiler.state
        local setpointValue = tonumber(setpoint)

        dz.log('Setpoint: ' .. setpointValue, dz.LOG_DEBUG)
        dz.log('Current boiler state: ' .. boilerState, dz.LOG_DEBUG)

        -- now determine what to do
        if setpoint == 'Off' then
            boiler.switchOff()
            infrarot.switchOff()
        elseif temperature > setpointValue and boilerState == 'On' then
            dz.log('Target temperature reached, boiler off')
            boiler.switchOff()
            infrarot.switchOff()
        elseif temperature <= setpointValue and boilerState == 'Off' and modusState == 'Heizen'  then
            dz.log('Target temperature not reached, boiler on')
            boiler.switchOn()
            infrarot.switchOn()
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Script Heating Control Issues

Post by jkimmel »

Thanks Waaren script is running except I don't see any logging, only

Code: Select all

2020-03-15 11:24:00.940 Status: dzVents: Info: setSetpoint: ------ Start internal script: Heizung Bad:, trigger: "every 3 minutes"
2020-03-15 11:24:00.974 Status: dzVents: Debug: setSetpoint: Processing device-adapter for FB 42 Heizkreis Bad: Switch device adapter
2020-03-15 11:24:00.977 Status: dzVents: Debug: setSetpoint: Processing device-adapter for FB 31 Infrarot: Switch device adapter
2020-03-15 11:24:00.979 Status: dzVents: Debug: setSetpoint: Processing device-adapter for Bad: Temperature+humidity device adapter
2020-03-15 11:24:00.980 Status: dzVents: Debug: setSetpoint: Processing device-adapter for Solltemperatur Bad: Switch device adapter
2020-03-15 11:24:00.982 Status: dzVents: Debug: setSetpoint: Processing device-adapter for Modus Waermepumpe: Switch device adapter
2020-03-15 11:24:00.983 Status: dzVents: Debug: setSetpoint: Setpoint: 18
2020-03-15 11:24:00.983 Status: dzVents: Debug: setSetpoint: Current boiler state: Off
2020-03-15 11:24:00.983 Status: dzVents: Info: setSetpoint: ------ Finished Heizung Bad
My loglevel = Debug (everything)

Also other scripts show no logging
Rfxcom
Raspi 4
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Script Heating Control Issues

Post by waaren »

jkimmel wrote: Sunday 15 March 2020 11:25 except I don't see any logging, only
What kind of additional logging do you expect ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Script Heating Control Issues  [Solved]

Post by jkimmel »

Code: Select all

 dz.log('Setpoint: ' .. setpointValue, dz.LOG_DEBUG)
        dz.log('Current boiler state: ' .. boilerState, dz.LOG_DEBUG

Code: Select all

dz.log('setpoint = Off or Modus >< Heizen', domoticz.LOG_INFO)

Code: Select all

dz.log('Target temperature reached, boiler off', domoticz.LOG_INFO)

Code: Select all

dz.log('Target temperature not reached, boiler on', domoticz.LOG_INFO)
These are excerpts from my script. None of them show up

Edit:
I did not read the log carefully enough.
Everything is ok
Rfxcom
Raspi 4
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest