How to do this

Moderator: leecollings

Post Reply
edwin1234
Posts: 252
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

How to do this

Post 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.
willemd
Posts: 630
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: How to do this

Post 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
edwin1234
Posts: 252
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to do this

Post by edwin1234 »

Thank you ,
I’m gonna try it.

Regards
Edwin
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests