[SOLVED] Opening/Closing Venetian Blinds with dzVents

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

Moderator: leecollings

Post Reply
ag74
Posts: 7
Joined: Wednesday 15 May 2019 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

[SOLVED] Opening/Closing Venetian Blinds with dzVents

Post by ag74 »

Hi all,

I'm developping a small dzVents script to automate my venetian blinds.

In domoticz v4.10717, if I want to open a blind I have issue a Off command and a On command if I want to close it.
So with dzVents if I call domoticz.devices( 'blind' ).switchOn() it closes the blind and domoticz.devices( 'blind' ).switchOff() it opens the blind.

But there are also the functions domoticz.devices( 'blind' ).open() and domoticz.devices( 'blind' ).close() but the open() function issues a On command so it closes the blind and the close() function issues a Off command so it opens the blind.

Here the code of those functions https://github.com/domoticz/domoticz/bl ... device.lua :

Code: Select all

		
function device.close()
	return TimedCommand(domoticz, device.name, 'Off', 'device', device.state)
end

function device.open()
	return TimedCommand(domoticz, device.name, 'On', 'device', device.state)
end

function device.stop() -- blinds
	return TimedCommand(domoticz, device.name, 'Stop', 'device', device.state)
end
So what is wrong ?
The close() and the open() functions of the dzVents API or the way the blinds work ?

In my script I will use switchOn() and switchOff() so I won't get confused with open() and close() but I think either the dzVents functions or the blinds commands should be fixed.
Last edited by ag74 on Friday 17 May 2019 10:15, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by waaren »

I guess this is a matter of interpretation /perception.

DzVents will never satisfy everyone in this case, especial given the fact that blinds can also be set to inverted. The Chosen relation between open/ close and Off/ On have been as it is now since the start of dzVents and users that created scripts based on this setting would not like that it will change now.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ag74
Posts: 7
Joined: Wednesday 15 May 2019 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by ag74 »

I understand your point of view and you're right but it doesn't mean dzVent can't be improved because people already wrote plugins.
I think my request is not incompatible with your point of view.

device.open() and device.close() are high level functions that should not only issue simple On or Off commands but should be able to identify what kind of device is getting open or close and issue the right command or the right sequence of commands according the device's properties.

So people using close() and open() in their scripts won't get impacted because those functions will still do their jobs but in a more intelligent way.
ag74
Posts: 7
Joined: Wednesday 15 May 2019 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by ag74 »

Here a quick fix on how open() and close() could be implemented.
I know there's a better and cleaner way too improve open() and close() but I don't know the internals of the dzVents engine cause this quick fix works for my use case which uses generic Venetian blinds but domoticz developpers could think of many more use cases.

Code: Select all

function device.close()
	local cmd = 'Off'
	if ( device.deviceType == 'Light/Switch' and device.switchType == 'Venetian Blinds EU' ) then
		cmd = 'On'
	end
	return TimedCommand(domoticz, device.name, cmd, 'device', device.state)
end

function device.open()
	local cmd = 'On'
	if ( device.deviceType == 'Light/Switch' and device.switchType == 'Venetian Blinds EU' ) then
		cmd = 'Off'
	end
	return TimedCommand(domoticz, device.name, cmd, 'device', device.state)
end
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by waaren »

ag74 wrote: Wednesday 15 May 2019 13:52 device.open() and device.close() are high level functions that should not only issue simple On or Off commands but should be able to identify what kind of device is getting open or close and issue the right command or the right sequence of commands according the device's properties.
So people using close() and open() in their scripts won't get impacted because those functions will still do their jobs but in a more intelligent way.
You have a point here and thanks for the quick fix examples in your next post. Need to do some testing but the solution you propose look promising.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ag74
Posts: 7
Joined: Wednesday 15 May 2019 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by ag74 »

I can contribute through Github and using a pull request but I'm not sure this should be done in these functions or elsewhere in a more generic function or using an array of specific devices with a callback.

That's why I think domoticz dev will do it in much more cleaner way.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by waaren »

ag74 wrote: Wednesday 15 May 2019 16:35 I can contribute through Github and using a pull request but I'm not sure this should be done in these functions or elsewhere in a more generic function or using an array of specific devices with a callback.

That's why I think domoticz dev will do it in much more cleaner way.
Send you a PM on this
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by waaren »

ag74 wrote: Wednesday 15 May 2019 16:35 I can contribute through Github and using a pull request but I'm not sure this should be done in these functions or elsewhere in a more generic function or using an array of specific devices with a callback.

That's why I think domoticz dev will do it in much more cleaner way.
PR is ready for review
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ag74
Posts: 7
Joined: Wednesday 15 May 2019 10:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Opening/Closing Venetian Blinds with dzVents

Post by ag74 »

great !
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest