I am developing home bridge plugin with mqtt broker for up and down blinds.
So, I want "up and down" blinds with Home App, and also I want "up and down" blinds with with a physical wall switch.
Physical wall switch connected to GPIO0 AND GPIO9 (Sonoff Dual r2, lastes firmware v2.0-20180322)
Control even is [Import#moving] that show // 0 = Stoped , 1=Moving Up , Moving Down.
When app start moving down, App publish 1, after blinds moving finished, sonoff publish 2.
So, I have problem with publish 2.
For some reason after gpio,12,0 mqtt lost connection and dont publish 2, and also mqtt import dont update state moving to 2.
A couple of times pass without problems, but every some time the connection loss is lost, and this is always on this part after gpio,12,0 or gpio,5,0.
----
I make some things easier with mqtt, and never lost connection to the same device son off dual r2. (So, The device is okay)
All Rules Code:
Code: Select all
on Import#moving=0 do
gpio,12,1
Delay [Import#time]
gpio,12,0
Publish RoletneMalaSobaWC/currentPosition,[Import#target]
Publish RoletneMalaSobaWC/statePosition,2
endon
on Import#moving=1 do
gpio,5,1
Delay [Import#time]
gpio,5,0
Publish RoletneMalaSobaWC/currentPosition,[Import#target]
Publish RoletneMalaSobaWC/statePosition,2
endon
on TipkaUp#Stanje=0 do
if [Import#moving]=2
Publish RoletneMalaSobaWC/targetPosition,100
Publish RoletneMalaSobaWC/time,10000
Publish RoletneMalaSobaWC/statePosition,1
endif
endon
on TipkaUp#Stanje=1 do
if [Import#moving]=2
Publish RoletneMalaSobaWC/targetPosition,100
Publish RoletneMalaSobaWC/time,10000
Publish RoletneMalaSobaWC/statePosition,1
endif
endon
on TipkaDown#Stanje=0 do
if [Import#moving]=2
Publish RoletneMalaSobaWC/targetPosition,0
Publish RoletneMalaSobaWC/time,10000
Publish RoletneMalaSobaWC/statePosition,0
endif
endon
on TipkaDown#Stanje=1 do
if [Import#moving]=2
Publish RoletneMalaSobaWC/targetPosition,0
Publish RoletneMalaSobaWC/time,10000
Publish RoletneMalaSobaWC/statePosition,0
endif
endon