Hi,
what is preferred way (if exists) to read state of output GPIO within rules and GPIO is not defined within Taks/Devices? Is there a way to make such
I have relays on GPIO 15 and GPIO4 and i want to make following if clause (below example doesn't work):
if [GPIO#15]=1 and [GPIO#4]=1
GPIO,15,0
GPIO,4,0
endif
Reading (output) GPIO state within rules
Moderators: grovkillen, Stuntteam, TD-er
Re: Reading (output) GPIO state within rules
See the "monitor" command: https://espeasy.readthedocs.io/en/lates ... ore-events
N.B. this does require a recent build.
N.B. this does require a recent build.
Re: Reading (output) GPIO state within rules
I use Monitor function on input GPIOs in order to get event when state is changed (button pressed).
I am asking for solution to get state of output GPIO which is used for controlling relay. Since I dont want to get events when changed I am asking for solution like in example in documentation
but for this I have to define every output as task/device.
Is Monitor command also useful for monitoring output GPIOs without using events which are generated on change? How many system resources does Monitor command consume?
if YES I assume that after enabling Monitor on output GPIO (eg. GPIO15) I will be able to
if [GPIO#15]=1
// do something
endif
I am asking for solution to get state of output GPIO which is used for controlling relay. Since I dont want to get events when changed I am asking for solution like in example in documentation
Code: Select all
if [Plugin#GPIO#Pinstate#13]=0
// do something
endif
but for this I have to define every output as task/device.
Is Monitor command also useful for monitoring output GPIOs without using events which are generated on change? How many system resources does Monitor command consume?
if YES I assume that after enabling Monitor on output GPIO (eg. GPIO15) I will be able to
if [GPIO#15]=1
// do something
endif
Re: Reading (output) GPIO state within rules
Hi
I´m only beginner at this topic but according my understanding the monitoring function is always enabled for Gpios.
I use the monitor function for additional GPIOs of a PCF8574 IO-Extender and here you have to enable it by rule. But not for GPIOs and therefore your last example can be used directly.
Best regards
P.S.: If I´m wrong regarding enabled monitoring for GPIOs... I use it for 6pcs PCF8574 IOs and have not recognized any load or memory impact.
Only as example how I use it. I like to get an update by Mqtt after reboot about the status of the output and an update in case of a change.
I haven´t had enough free devices to do this by internal input/switch.
I´m only beginner at this topic but according my understanding the monitoring function is always enabled for Gpios.
I use the monitor function for additional GPIOs of a PCF8574 IO-Extender and here you have to enable it by rule. But not for GPIOs and therefore your last example can be used directly.
Best regards
P.S.: If I´m wrong regarding enabled monitoring for GPIOs... I use it for 6pcs PCF8574 IOs and have not recognized any load or memory impact.
Only as example how I use it. I like to get an update by Mqtt after reboot about the status of the output and an update in case of a change.
I haven´t had enough free devices to do this by internal input/switch.
Code: Select all
on System#Boot do
Monitor,pcf,1
Monitor,pcf,2
Monitor,pcf,4
Monitor,pcf,5
Monitor,pcf,7
Monitor,pcf,8
pcfgpio,1,1
pcfgpio,2,0
pcfgpio,4,0
pcfgpio,5,1
pcfgpio,7,1
pcfgpio,8,0
endon
on MQTT#Connected do
Publish,%sysname%/PCFGPIO/P1Gruen,[plugin#pcfgpio#pinstate#1]
Publish,%sysname%/PCFGPIO/P2Rot,[plugin#pcfgpio#pinstate#2]
Publish,%sysname%/PCFGPIO/P4BlauET1,[plugin#pcfgpio#pinstate#4]
Publish,%sysname%/PCFGPIO/P5BlauET2,[plugin#pcfgpio#pinstate#5]
Publish,%sysname%/PCFGPIO/P7GelbAT1,[plugin#pcfgpio#pinstate#7]
Publish,%sysname%/PCFGPIO/P8GelbAGarten,[plugin#pcfgpio#pinstate#8]
endon
on pcf#1 do
Publish,%sysname%/PCFGPIO/P1Gruen,[plugin#pcfgpio#pinstate#1]
endon
on pcf#2 do
Publish,%sysname%/PCFGPIO/P2Rot,[plugin#pcfgpio#pinstate#2]
endon
on pcf#4 do
Publish,%sysname%/PCFGPIO/P4BlauET1,[plugin#pcfgpio#pinstate#4]
endon
on pcf#5 do
Publish,%sysname%/PCFGPIO/P5BlauET2,[plugin#pcfgpio#pinstate#5]
endon
on pcf#7 do
Publish,%sysname%/PCFGPIO/P7GelbAT1,[plugin#pcfgpio#pinstate#7]
endon
on pcf#8 do
Publish,%sysname%/PCFGPIO/P8GelbAGarten,[plugin#pcfgpio#pinstate#8]
endon
Re: Reading (output) GPIO state within rules
Yes, monitor command operates also on output pins.I am asking for solution to get state of output GPIO which is used for controlling relay. Since I dont want to get events when changed I am asking for solution like in example in documentation
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 0 guests