Page 1 of 1
[SOLVED] Opening/Closing Venetian Blinds with dzVents
Posted: Wednesday 15 May 2019 11:02
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.
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Wednesday 15 May 2019 11:55
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.
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Wednesday 15 May 2019 13:52
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.
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Wednesday 15 May 2019 15:11
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
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Wednesday 15 May 2019 16:01
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.
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Wednesday 15 May 2019 16:35
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.
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Thursday 16 May 2019 0:44
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
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Thursday 16 May 2019 20:44
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
Re: Opening/Closing Venetian Blinds with dzVents
Posted: Friday 17 May 2019 10:15
by ag74
great !