enesbcs wrote: ↑24 Sep 2018, 18:10
Code: Select all
on B_UP#Longpress do
if [global#longpressUP]>0 // if longpressUP is '1'
taskvalueset,4,2,0 // global is task 4th, longpressUp is 2nd value, set it to "0'
Publish domoticz/in,{"idx":12,"nvalue":0.00,"svalue":"Off"} // report idx:12 is in state OFF
else
taskvalueset,4,1,1 // global is task 4th, longpressUp is 2nd value, set it to "1'
Publish domoticz/in,{"idx":12,"nvalue":1.00,"svalue":"On"} // report idx:12 is in state ON
endif
endon
etc...
In this way i think the longpress state is recorded in a dummy in ESPEasy, and also it is reported to Domoticz by MQTT.
This is a simple example only, need to be combined with previous output commands, and you need a similar block for all events, you wish to use.
hi, i'm here after hours of tests with poor results.
i try to explain what i do and my problems.
i'm starting from this rules that the only thing that is missing is:
- when i press long (more than 4sec) the button (gpio3 or gpio1) the relay stay active for the 6seconds, BUT in only this case (longpress) domoticz is not able to recognize and update the position (if for example domoticz show open blind, and i press for more than 4sec (longpress) the gpio3 -> relay gpio12 is active for 6sec -> bling go DOWN -> domoticz is not update, it will show agan OPEN)
if i use shortpress, domoticz is update
this is my rules:
Code: Select all
on B_UP#Shortpress do
if [relayp#R_UP]>0
output,relayp,0,0
else
output,relayp,1,0
output,relayp,0,1
SendToHTTP 192.168.0.105,8085,/json.htm?type=command¶m=switchlight&idx=31&switchcmd=Off
timerset,1,2
endif
endon
on B_UP#Longpress do
event,event_UP_domoticz
endon
on event_UP_domoticz do
if [relayp#R_UP]>0
output,relayp,0,0
else
output,relayp,1,0
output,relayp,0,1
timerset,1,6 // 6 sec as test to simulate completly UP
endif
endon
on B_DOWN#Shortpress do
if [relayp#R_DOWN]>0
output,relayp,1,0
else
output,relayp,0,0
output,relayp,1,1
SendToHTTP 192.168.0.105,8085,/json.htm?type=command¶m=switchlight&idx=31&switchcmd=On
timerset,2,2
endif
endon
on B_DOWN#Longpress do
event,event_DOWN_domoticz
endon
on event_DOWN_domoticz do
if [relayp#R_DOWN]>0
output,relayp,1,0
else
output,relayp,0,0
output,relayp,1,1
timerset,2,6 // 6 sec as test to simulate completly DOWN
endif
endon
on Rules#Timer=1 do
output,relayp,0,0
endon
on Rules#Timer=2 do
output,relayp,1,0
endon
if i add on event_UP_domoticz an API http string to update domoticz, i will have a ping pong activation of relay, because in domoticz under the dummy switch i have:
- Image8.jpg (99.33 KiB) Viewed 31472 times
using your suggestion i go ahed creating a dummy device in espeasy:
- Image3.jpg (166.75 KiB) Viewed 31472 times
that is configurated in this way:
- Image1.jpg (127.95 KiB) Viewed 31472 times
- Image2.jpg (35.45 KiB) Viewed 31472 times
now i created in domoticz 2 dummy switch device: idx 35 and 36
- Image4.jpg (72.01 KiB) Viewed 31472 times
and i add this rule:
Code: Select all
on B_UP#Longpress do
if [global#longpressUP]>0 // if longpressUP is '1'
taskvalueset,3,2,0 // global is task 3rd, longpressUp is 2nd value, set it to "0'
Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF
else
taskvalueset,3,1,1 // global is task 3rd, shortpressUp is 1st value, set it to "1'
Publish domoticz/in,{"idx":35,"nvalue":1.00,"svalue":"On"} // report idx:35 is in state ON
endif
endon
on B_DOWN#Longpress do
if [global#longpressDOWN]>0 // if longpressDOWN is '1'
taskvalueset,3,4,0 // global is task 3rd, longpressDOWN is 4rd value, set it to "0'
Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF
else
taskvalueset,3,3,1 // global is task 3rd, shortpressDOWN is 1st value, set it to "1'
Publish domoticz/in,{"idx":36,"nvalue":1.00,"svalue":"On"} // report idx:35 is in state ON
endif
endon
now if i long press for > 4sec (longpress) the wall switch (gpio3 or gpio1) i see switch on the dummy device inside domoticz goes to ON, but it remain to ON, and never come back to OFF even if i shortpress the gpio3 or gpio1 why?
i also modify the dummy switch in domoticz idx=31 to a selector like this:
- Image7.jpg (164.97 KiB) Viewed 31471 times
and now i change again the rules as it:
Code: Select all
on B_UP#Shortpress do
if [relayp#R_UP]>0
output,relayp,0,0
else
output,relayp,1,0
output,relayp,0,1
SendToHTTP 192.168.0.105,8085,/json.htm?type=command¶m=switchlight&idx=31&switchcmd=Set%20Level&level=40
timerset,1,2
endif
endon
on B_UP#Longpress do
event,event_UP_domoticz
endon
on event_UP_domoticz do
if [relayp#R_UP]>0
output,relayp,0,0
else
output,relayp,1,0
output,relayp,0,1
timerset,1,6 // 6 sec as test to simulate completly UP
endif
endon
on B_DOWN#Shortpress do
if [relayp#R_DOWN]>0
output,relayp,1,0
else
output,relayp,0,0
output,relayp,1,1
SendToHTTP 192.168.0.105,8085,/json.htm?type=command¶m=switchlight&idx=31&switchcmd=Set%20Level&level=0
endif
endon
on B_DOWN#Longpress do
event,event_DOWN_domoticz
endon
on event_DOWN_domoticz do
if [relayp#R_DOWN]>0
output,relayp,1,0
else
output,relayp,0,0
output,relayp,1,1
timerset,2,6 // 6 sec as test to simulate completly DOWN
endif
endon
on Rules#Timer=1 do
output,relayp,0,0
endon
on Rules#Timer=2 do
output,relayp,1,0
endon
on B_UP#Longpress do
if [global#longpressUP]>0 // if longpressUP is '1'
taskvalueset,3,2,0 // global is task 3rd, longpressUp is 2nd value, set it to "0'
Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF
else
taskvalueset,3,1,1 // global is task 3rd, shortpressUp is 1st value, set it to "1'
Publish domoticz/in,{"idx":35,"nvalue":1.00,"svalue":"On"} // report idx:35 is in state ON
endif
endon
on B_DOWN#Longpress do
if [global#longpressDOWN]>0 // if longpressDOWN is '1'
taskvalueset,3,4,0 // global is task 3rd, longpressDOWN is 4rd value, set it to "0'
Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF
else
taskvalueset,3,3,1 // global is task 3rd, shortpressDOWN is 1st value, set it to "1'
Publish domoticz/in,{"idx":36,"nvalue":1.00,"svalue":"On"} // report idx:35 is in state ON
endif
endon
again all is working except:
1) if i long press (more than 4sec) wall switch (gpio3 or gpio1) the corrisponding relay is correctly actived for long time (6seconds) BUT domoticz is not able to recognize the pressing of longress of wall switch
and i could not put on the rules:
on event_UP_domoticz do
if [relayp#R_UP]>0
output,relayp,0,0
else
output,relayp,1,0
output,relayp,0,1
SendToHTTP 192.168.0.105,8085,/json.htm?type=command¶m=switchlight&idx=31&switchcmd=Set%20Level&level=40
timerset,1,6 // 6 sec as test to simulate completly UP
endif
endon
otherwise for sure domoticz recognize the status and it will be updated, but due to the commands written inside domoticz:
action on =
http://192.168.0.154/control?cmd=event, ... N_domoticz
action off =
http://192.168.0.154/control?cmd=event, ... P_domoticz
domoticz stop immediatly the relay and it could not stay activated for 6seconds as longress ask.
- Image8.jpg (99.33 KiB) Viewed 31472 times
2) i do not have any idea how to implement espeasy rules to have positioning of 25% - 50% - 75%
and i have no idea what command insert in domoticz in the corrisponding percentage areas
3) the two dummy switch device in domoticz: "UP" (=idx35) and "DOWN" (=idx36) is correctly put as ON if i longress the wall switch gpio3 or gpio1 but at the first time that they go ON it will remain ON permanently
and, how i have to use this two domoticz dummy switch for my purpose?
thanks
.....i'm realy getting crazy and testing for hours and hours....big frustrating, and what i achieve till now is ONLY thanks to you and the forum...very huge help (and headhake from my side)
thanks thanks thanks thanks