Page 1 of 1
dzVents and trigger of GPIO for max 250mSec
Posted: Wednesday 16 October 2019 20:07
by imdos
Is it possible to trigger a hardware (sysfs GPIO) connected remote control only for a short period of time.
I now have added the sysfs underneath hardware and get the exposed ports that I have configured as a regular on/off switch.
I only managed to switch off the device after 1 sec in the GUI itself. However I see the LED on the remote flashing at least 4 times.
But there is no .forMilliSec or something similar. Would this work in dzVents or in Python?
Re: dzVents and trigger of GPIO for max 250mSec
Posted: Wednesday 16 October 2019 20:28
by waaren
imdos wrote: ↑Wednesday 16 October 2019 20:07
But there is no .forMilliSec or something similar. Would this work in dzVents or in Python?
In dzVents you can do a switchOff().afterSec(0.250)
Re: dzVents and trigger of GPIO for max 250mSec
Posted: Thursday 17 October 2019 15:14
by imdos
Great; that works, I had to play with the timeout and changed it to 150 though.
Now I get it; while looking at the
Availability this is only applicable for afterXXX.
Next problem however is that it doesn't work inside a switchselector with GPIOx.switchOn() and direcly underneath the GPIOx.switchOff().afterSec(0.250).
Nor does it work when I have the switchselector only with GPIOx.switchOn() and in a separate script (the original for the GPIO itself with a trigger of GPIOx) the GPIOx.switchOff().afterSec(0.250).
Re: dzVents and trigger of GPIO for max 250mSec
Posted: Tuesday 21 January 2020 13:48
by imdos
Here is an update to my current script. I am able to turn it off for .150 milliseconds, after the switchOn and it appears to only press the button once.
But how can I use this in a switchselector or have its state show the right value if I am unable to use it as a simple button.
So the bold code does work; but the italic marked code doesn't work (those are my tests and aren't correctly defined right now).
Code: Select all
pi@raspberrypi:~ $ cat /domoticz/scripts/dzVents/scripts/somfy-off.lua
--[[
Somfy afstandsbediening bedienen via GPIO.
Voorwaarde is wel dat de GPIO poorten worden vrijgegeven,
voordat Domoticz is gestart.
Deze worden geopend via setup-GPIO.sh
Daarnaast moeten de HW-=> GPIO worden vertaald naar de acties.
https://www.domoticz.com/forum/viewtopic.php?f=59&t=29773
switchOff().afterSec(0.250)
]]--
return {
active = true,
on = {
devices = {
-- 'Somfy' -- de switch selector
('somfy-test-oranje')-- , 'somfy-test-geel', 'somfy-test-groen')
}
},
logging = {
level = domoticz.LOG_INFO,
marker = "Somfy Control v2"
},
execute = function(domoticz, somfyctl)
local beneden = domoticz.devices('somfy-test-oranje')
local my1 = domoticz.devices('somfy-test-geel')
local boven = domoticz.devices('somfy-test-groen')
[b] if (somfyctl.active)then
--state == 'Off' )then
-- switch selector op: My
-- my1.switchOn()
beneden.switchOff().afterSec(0.150)
domoticz.log('Somfy naar beneden', domoticz.LOG_INFO)
end[/b]
--[[
[i] elseif (somfyctl.state == 'boven' )then
-- switch selector op: boven
boven.switchOn()
boven.switchOff().afterSec(0.250)
domoticz.log('Somfy naar boven', domoticz.LOG_INFO)
elseif (somfyctl.state == 'beneden' )then
-- switch selector op: beneden
beneden.switchOn().forSec(0.250)
domoticz.log('Somfy naar beneden', domoticz.LOG_INFO)
end[/i]
]]--
end
}
Re: dzVents and trigger of GPIO for max 250mSec [Solved]
Posted: Tuesday 21 January 2020 15:48
by waaren
imdos wrote: ↑Tuesday 21 January 2020 13:48
But how can I use this in a switchselector or have its state show the right value if I am unable to use it as a simple button.
did you try to code it like below ?
Code: Select all
beneden.switchOn(),afterSec(0.5)
beneden.switchOff().afterSec(0.750)
Re: dzVents and trigger of GPIO for max 250mSec
Posted: Thursday 23 January 2020 17:14
by imdos
Thanks; this works like a charm. Why I haven't tought about that myself.
dzVents code is solved.
Now I have to find out why the LED flashes for a while when I enable the GPIO ports. This is done prior to loading Domoticz, with the following:
Code: Select all
sudo echo 17 > /sys/class/gpio/export ; sleep 0.2; sudo echo out > /sys/class/gpio/gpio17/direction ; sleep 0.2; sudo echo 0 > /sys/class/gpio/gpio17/value ; gpio exports
As soon as I set the direction of the GPIO pin to out the LED flashes for 5 seconds at least.