Page 1 of 1

dzvents script for control of heatpump

Posted: Monday 16 October 2017 22:14
by eeduu
Hello,
Though I'm new to the forum but im using domoticz for over a year now and i think its really great. I recently start to use the dzvents scripting.
I'm trying to get a script to work to control my heatpump. The idea is to switch a dummy switch when there is need for heating in one of my rooms. i use dummy thermostats that switch a relay for the valves on the floorheating. Im using a lua script for this and this is working fine.
I started with only the ground floor and when i get it to work i want to add the second floor to.
I've been struggling with it for a few days now and it is very unpredictable.
This is the script im using :

Code: Select all

return {
    on = {
        
        devices = {
            'verwarming woonkamer',
            'verwarming SLK beneden',
            'verwarming keuken',
            'verwarming badkamer'
        }
    },
    execute = function(domoticz, device)
        
          
       if  ((device.name =='verwarming woonkamer'or 'verwarming SLK beneden' or'verwarming keuken'or 'verwarming badkamer') and device.state == 'On') then
            domoticz.devices ('warmtevraag') .switchOn().checkFirst() else
                
        if ((device.name == 'verwarming woonkamer'and'verwarming SLK beneden' and 'verwarming keuken'and'verwarming badkamer')and device.state == 'Off') then
            domoticz.devices ('warmtevraag') .switchOff ().checkFirst()
         end
    end
 
end

}
I have changed the layout a few times and added and removed stuff, but the outcome is mostly the same.
Sometimes the switch is enabled but will not switch off and vice-versa.

I hope someone can help me to get this to work.

Regards Eeduu

Re: dzvents script for control of heatpump

Posted: Monday 16 October 2017 22:41
by Lokonli
Hi Eeduu,
Your if statements seem to be incorrect.

Try something like:

Code: Select all

if (domoticz.devices('verwarming woonkamer').active or
	     domoticz.devices('verwarming SLK beneden').active or
	     domoticz.devices('verwarming keuken').active or
	     domoticz.devices('verwarming badkamer').active) then
    domoticz.devices ('warmtevraag') .switchOn().checkFirst()
end

if (domoticz.devices('verwarming woonkamer').active==false and
	domoticz.devices('verwarming SLK beneden').active==false and
	domoticz.devices('verwarming keuken').active==false and
	domoticz.devices('verwarming badkamer').active==false) then
     domoticz.devices ('warmtevraag') .switchOff ().checkFirst()
end

Re: dzvents script for control of heatpump

Posted: Monday 16 October 2017 23:16
by eeduu
Thank you very much for your reply Lokonli,

It seems to be working better now, though sometimes I end up with switching on and off several times.
I will go on with testing tomorrow...