I tried the use of EXTGPIO command inside a rule with a recent version (Mega dev10) and it doesn't work!
On which version did you try ? To understand when it broke.
Tks
Moderators: grovkillen, Stuntteam, TD-er
i attached an image in the link bottom my post
Hi all,uhrheber wrote: ↑28 Sep 2016, 21:19 Ok, found it.
Define device one as Switch Input, Push Button Active Low, pullup on, GPIO 13. Name it Lightswitch. Name the value1 as value.
Define device two as Switch Input, Normal Switch, pullup off, GPIO 12. Name it GPIO12. Name the value1 as value.
Connect a push button from GPIO 13 to ground, and an LED from GPIO 12 to ground.
Now write the following rules:
Now you can push the button to toggle the LED.Code: Select all
on Lightswitch#value do if [GPIO12#value] = 0 GPIO,12,1 else GPIO,12,0 endif endon on toggle do if [GPIO12#value] = 1 GPIO,12,0 else GPIO,12,1 endif endon
And every time you call http://<IP_of_your_ESP8266>/control?cmd=event,toggle , the LED toggles as well.
You can also switch the LED explicitly on or off by calling: http://<IP_of_your_ESP8266>/control?cmd=GPIO,12,on (or ,off).
The next button press or call of the toggle URL will toggle the LED to the opposite state.
Have fun!
Thanks Pulse control works nicely! In the rules no less.toffel969 wrote: ↑16 Feb 2017, 07:59xbmcnut wrote:I'm using R148 and I have two switches, SHORTENED
hi, in a similiar setup(using udp sento> i had problems with reliability. after some weeks i found, the 1-state was not detected--> the timer never fired --> relais stayed at1. now im using "pulse" command, which includes the off command. not sure how to use it with mqtt.
Short pulses
To send a pulse to a certain pin:
http://<ESP IP address>/control?cmd=Pulse,<pin>,<state>,<duration>
Example to send an active high pulse on GPIO 2 for 500 mSeconds:
http://<ESP IP address>/control?cmd=Pulse,2,1,500
Code: Select all
On System#Boot do
gpio,15,0
endon
On garage#door=1 do
pulse,15,1,100
gpio,15,0
publish /MyHome/Garage/Door/,The Garage Door is Moving
//if else needed for garage#door=1 > 1000
//publish /MyHome/Garage/, RELAY FAULT - URGENT
endon
Code: Select all
// Topic == Payload
/%sysname%/Garage/cmd == GPIO,15,1,status,
/%sysname%/Garage/gpio/15/[b],[/b]1 //This one I don't like because I can't figure out how to get a JSON output to /$sysname$/status
/%sysname%/Garage/cmd == PULSE,15,1,status, // With this one I don't actually need the rule in the Code above but will keep it for redundancy, so I can't leave the relay on.
Code: Select all
On btn#Switch do
gpio,12,[btn#Switch]
endon
Code: Select all
On btn#Switch Do
If [btn#Switch]=0
event,ToggleSwitch=1
Else
event,ToggleSwitch=0
EndIf
EndOn
On ToggleSwitch Do
gpio,12,%eventvalue%
EndOn
Code: Select all
event,ToggleSwitch=1
Code: Select all
event,ToggleSwitch=0
Code: Select all
On btn#Switch Do
publish,shm/%sysname%/button,event[btn#Switch]
If [btn#Switch]=0
event,ToggleSwitch=1
Else
event,ToggleSwitch=0
EndIf
EndOn
On ToggleSwitch=0 Do
gpio,12,%eventvalue%
publish,shm/%sysname%/relay,%eventvalue%
EndOn
On ToggleSwitch=1 Do
gpio,12,%eventvalue%
publish,shm/%sysname%/relay,%eventvalue%
publish,shm/%sysname%/timerset,%systime%
timerset,1,10 // run timer for 10 sec
EndOn
On Rules#Timer=1 do
event,ToggleSwitch=0
publish,shm/%sysname%/timerend,%systime%
endon
Code: Select all
on lamp_on do
gpio,12,1
gpio,13,0
endon
on lamp_off do
gpio,12,0
gpio,13,1
endon
on lamp_change do
if [rele#Switch]=1
event,lamp_off
SendToHTTP 192.168.1.253,8080,/json.htm?type=command¶m=switchlight&idx=19&switchcmd=Off
else
event,lamp_on
SendToHTTP 192.168.1.253,8080,/json.htm?type=command¶m=switchlight&idx=19&switchcmd=On
endif
endon
on SW01#Switch do
event,lamp_change
endon
Users browsing this forum: Ahrefs [Bot] and 140 guests