Page 1 of 1

How to do this

Posted: Wednesday 01 March 2023 10:59
by edwin1234
I have a virtual device called “airco stroom”
That shows amperage when airco is running
I want when airco stroom is above 0 another virtual device called airco goes on.
And when airco stroom is 0 virtual device airco goes off

How to do that?
Thanks

Edwin.

Re: How to do this

Posted: Wednesday 01 March 2023 14:57
by willemd
Create a dzvents script with this content:

Code: Select all

return {
	on = {
		devices = {
			'airco stroom'
		}
	},
	logging = {
		level = domoticz.LOG_INFO,
		marker = 'example',
	},
	execute = function(domoticz, device)
		domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
		
		if domoticz.devices('airco stroom').current>0 and domoticz.devices('airco').state=="Off"
		then
		    domoticz.devices('airco').switchOn()
		else
		    if domoticz.devices('airco stroom').current==0 and domoticz.devices('airco').state=="On"
		    then
		        domoticz.devices('airco').switchOff()
	        end
	    end     
	end
}
Note: naming of your devices has to match exactly with the code.
This assumes you use a ampere device and a switch device.
For more details have a look here
https://www.domoticz.com/wiki/DzVents:_ ... _scripting

Re: How to do this

Posted: Wednesday 01 March 2023 17:42
by edwin1234
Thank you ,
I’m gonna try it.

Regards
Edwin