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?
dzVents and trigger of GPIO for max 250mSec [Solved]
Moderator: leecollings
-
- Posts: 34
- Joined: Thursday 03 August 2017 21:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
dzVents and trigger of GPIO for max 250mSec
Making use of: Raspbian(SSD), dz Beta, Woonveilig, Z-Wave(alarm+multi-sensor), RFLink(blinds), P1, Yeelight, Xiaomi temp sensors, Tasmota(SonoFF, Blitzwolf SHP2, Shelly1)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: dzVents and trigger of GPIO for max 250mSec
In dzVents you can do a switchOff().afterSec(0.250)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 34
- Joined: Thursday 03 August 2017 21:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
Re: dzVents and trigger of GPIO for max 250mSec
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).
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).
Making use of: Raspbian(SSD), dz Beta, Woonveilig, Z-Wave(alarm+multi-sensor), RFLink(blinds), P1, Yeelight, Xiaomi temp sensors, Tasmota(SonoFF, Blitzwolf SHP2, Shelly1)
-
- Posts: 34
- Joined: Thursday 03 August 2017 21:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
Re: dzVents and trigger of GPIO for max 250mSec
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).
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
}
Making use of: Raspbian(SSD), dz Beta, Woonveilig, Z-Wave(alarm+multi-sensor), RFLink(blinds), P1, Yeelight, Xiaomi temp sensors, Tasmota(SonoFF, Blitzwolf SHP2, Shelly1)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: dzVents and trigger of GPIO for max 250mSec [Solved]
did you try to code it like below ?
Code: Select all
beneden.switchOn(),afterSec(0.5)
beneden.switchOff().afterSec(0.750)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 34
- Joined: Thursday 03 August 2017 21:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Contact:
Re: dzVents and trigger of GPIO for max 250mSec
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:
As soon as I set the direction of the GPIO pin to out the LED flashes for 5 seconds at least.
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
Making use of: Raspbian(SSD), dz Beta, Woonveilig, Z-Wave(alarm+multi-sensor), RFLink(blinds), P1, Yeelight, Xiaomi temp sensors, Tasmota(SonoFF, Blitzwolf SHP2, Shelly1)
Who is online
Users browsing this forum: Google [Bot] and 1 guest