rules for roller shutter on nodemcu+relays 2ch

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

rules for roller shutter on nodemcu+relays 2ch

#1 Post by megamarco83 » 23 Sep 2018, 01:22

hi, i have:
n°1 nodemcu with espeasy 192.168.0.151
n° raspberry with domoticz 192.168.0.105
n°1 ralay arduino 2ch

i want to:
control with wall switch the blind (up and down)
control with domoticz (up and down...and STOP)
put with domoticz at 50% opening or 20% opening or 80%opening and so on...

now, i created on espeasy this tasks:
Image
and under esp rules i create this rules:

Code: Select all

on pulsante_gpio3#Switch do
  if [pulsante_gpio3#Switch]=1
    gpio,12,1 //closing
  else
    gpio,12,0
  endif
endon

on pulsante_gpio1#Switch do
  if [pulsante_gpio1#Switch]=1
    gpio,15,1  //opening
  else
    gpio,15,0
  endif
endon



on rele_gpio12#Switch do
if [rele_gpio12#Switch]=1 //closing
gpio,15,0  // set off relay to opening
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=24&switchcmd=On
timerSet,1,6 //timer 1 set for 6 secondi
endif
endon

on STOP#Switch do
if [rele_gpio12#Switch]=0 or [rele_gpio15#Switch]=0
timerSet,1,0 //timer to STOP
endon

On Rules#Timer=1 do  
   gpio,12,0 //stop relè
   gpio,15,0
endOn




on rele_gpio15#Switch do
if [rele_gpio15#Switch]=1  //now opening
gpio,12,0 //put off relay of closing
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=24&switchcmd=Off
timerSet,1,6 //timer 1 set for 6 secondi
endif
endon
with external wall switch is perfect:
if i put GPIO3 (wall switch UP) or GPIO1 (wall switch DOWN) to GND the relay (GPIO12 UP or GPIO15 DOWN) are activated for 10seconds and then turn off
i added a rule to prevent that if i click on wall switch gpio1 down and i press gpio3 up when the gpio1 is still active the system stop GPIO1 and acrivate GPIO3.
and also that works well

the problems come with domoticz
i put same idx=24 in rele_gpio12 and rele_gpio15 because when i create a dummy sensor as switch and then i modify it from switch web page in "venetian blinds EU" i have only to commad to write here:
1) action for power on
2) action for power off

Image

i write there:
http://192.168.0.151/control?cmd=GPIO,12,1
that activate relay ch1 to go UP

http://192.168.0.151/control?cmd=GPIO,15,1
that activate relay ch2 to go DOWN

if i click open the relay ch1 open for 6sec (ok)
if i click close the relay ch2 open for 6sec (ok)

but howto i can stop if i not want to wait 6sec?
how can i change the rules to have for example: if i press the wall switch for 3second -> open the relay for 6sec; if i press the wall switch for less than 3 second, put off thre relativle channel relay?

what i have to do to control the blinds with domoticz? and also manage the stop? and the percentage opening?
Image
thanks

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#2 Post by grovkillen » 23 Sep 2018, 08:48

What you can do is to have a 1 second timer that will once every run add +1 to a dummy value. But each run it will also look at another dummy value. If that secund dummy value is 0 it'll proceed as normal but if it's 1 it'll stop and turn off/on the relay.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#3 Post by megamarco83 » 23 Sep 2018, 10:57

thanks for your help
i think that i understand you, but i'm tring without any succes
Image
i create that dummy device in domoticz, is well configurate?
could you help me to create a working rule?
1) using the two wall switch (up and down) that are connected to gpio3 (down) and gpio1 (up)
if they are pressed domoticz shuld recognize
2) if i press down -> (relay on gp12 active) and after up (relay on gpio15 acrive), the relay to down must be deactivated. (only one relay (gpio12 or gpio15) could be active in the same time)
3) if i presss for 4sec. one wall switch (gpio3 down or gpio1 up) the up relay (gpio15) and down relay (gpio12) will be active for 20sec (totaly up or totally down)
if i press for time < 4sec the up relay or the down relay corrispondig remain active just for that time (1sec, 3sec, 3sec)
4) create in domoticz the command to have: up moviment for 20 sec (blind totaly up) + down moviment for 20sec (blind totallu down) and if i pres for example up in domoticz, when i pres down (in a time < 20sec) the relay of up should be deactivated and the blind should stop its moviment

thanks
i'm getting crazy for 10 hours yesterday and today the same :( :oops:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#4 Post by grovkillen » 23 Sep 2018, 11:48

The dummy isn't used for sending values to a server so just leave those settings as you have pictured (unchecked, no idx, 0 interval).

Rules have a wiki page and I'm trying to not do the heavy lifting for the users as my time isn't unlimited. Have you tried anything regarding rules? If so, can we see it?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#5 Post by grovkillen » 23 Sep 2018, 12:25

Given that the dummy device is a quad device and that the task/device is named RelayStates and the values are named IsRunning, Direction, TimerForHalt, and Value4. The task number I use is task number 12, so for example setting the value 3 to a given number you would use this command:

TaskValueSet,12,3,<whatever float number you want>

and to retrieve that value you would then do something like this

Timer,1,[RelayStates#TimerForHalt]

If the dummy value is 30 for example this would render in the timer 1 to execute a 30 second delay.

In my example below you have the relay in series since you can have one for alternating the power to the motor (NO=up, NC=down) and the in-going current to that relay would be controlled by the second relay which would then only control ON or OFF.

That way you know that you never get a signal to the motor that is both up and down.

The relay controlling the up or down is set to GPIO 15 and the on or off is set to GPIO 12. I name them as BlindsPower and BlindsDirection and their value is named State (for both).

I'm not sure what your button (wall switch?) is doing, if it's connected to the ESP or not. But I will use a switch plugin in this example and name the switch Button and its value State.

So the rule would then be something like:

Code: Select all

on System#Boot do
  TaskValueSet,12,1,0  //[RelayStates#IsRunning]=0
  GPIO,12,0                 //Just to make sure
  TaskValueSet,12,2,0  //[RelayStates#Direction]=0 (down)
  GPIO,15,0                 //Just to make sure
  TaskValueSet,12,3,120  //[RelayStates#TimerForHalt]=120 (seconds)
endon

on Button#State do
  if [RelayStates#IsRunning]=0
    event,RunBlinds,1
  else
    event,RunBlinds,0
  endif
endon

on RunBlinds do
  if %eventvalue%>0
    TaskValueSet,12,1,1 //its running
    event,DirectionOfBlinds
  else
    GPIO,12,0 //turn the relay to current off
	TaskValueSet,12,1,0 //it's not running anymore..
	Timer,1,0 //disable the timer
  endif
endon

on DirectionOfBlinds do
  if [RelayStates#Direction]=0
    GPIO,15,0 //NC=up
	TaskValueSet,12,2,1
	GPIO,12,1 //Turn on the power to the motor
	event,TimeToRun,[RelayStates#TimerForHalt]
  else
    GPIO,15,1 //NO=down
	TaskValueSet,12,2,0
	event,TimeToRun,[RelayStates#TimerForHalt]
  endif
endon

on TimeToRun do
	GPIO,12,1 //Turn on the power to the motor
	Timer,1,%eventvalue%
endon

on Rules#Timer=1 do
  event,RunBlinds,0
endon
I have not tested this myself but you get the idea.. .and I'm really upset with myself for not letting you do this yourself ;)

EDIT: I realize now that I didn't use the switch devices for the relays... so either you use the dummy as I did or you add the relays to a switch device and use them (their values) instead of a dummy. Either way works but using dummy only cost you 1 task spot on the list compared to using switches to know their states which would cost you 2.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#6 Post by megamarco83 » 23 Sep 2018, 12:34

grovkillen wrote: 23 Sep 2018, 11:48 The dummy isn't used for sending values to a server so just leave those settings as you have pictured (unchecked, no idx, 0 interval).

Rules have a wiki page and I'm trying to not do the heavy lifting for the users as my time isn't unlimited. Have you tried anything regarding rules? If so, can we see it?
yes, i read the wiki about rules and after that i create this:

Code: Select all

on pulsante_gpio3#Switch do
  if [pulsante_gpio3#Switch]=1
    gpio,12,1 //CHIUSURA
  else
    gpio,12,0
  endif
endon

on pulsante_gpio1#Switch do
  if [pulsante_gpio1#Switch]=1
    gpio,15,1  //APERTURA
  else
    gpio,15,0
  endif
endon



on rele_gpio12#Switch do
if [rele_gpio12#Switch]=1 //STO CHIUDENDO
gpio,15,0  // metto OFF RELE APERTURA
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=On
timerSet,1,6 //timer 1 set for 6 secondi
endif
endon

on STOP#Switch do
if [rele_gpio12#Switch]=0 or [rele_gpio15#Switch]=0
timerSet,1,0 //timer to STOP
endon

On Rules#Timer=1 do  
   gpio,12,0 //stop relè
   gpio,15,0
endOn




on rele_gpio15#Switch do
if [rele_gpio15#Switch]=1  //STO APRENDO
gpio,12,0 //metto OFF RELE CHIUSURA
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Off
timerSet,1,6 //timer 1 set for 6 secondi
endif
endon
i do not understand how to use the dummy device that i create in espeasy

anyway with this rules (i put 6 seconds instead of 20sec just to make quick test) and:
1)it works for push wall switch (gpio3 and gpio1) -> the relay stay active for 6 sec and then switch off

2)works if i pres gpio3->relay gpio12 go down and after a time < 6sec press gpio1->reley gpio15 go up ->gpio12 deactivate immediatly and gpio15 run for 6sec

3)works the domoticz updating dummy switch device if i press wall switch (gpio3 or gpio12)

is not implemented because i'm not able to write a solution for my rules:

A) if i presss for 4sec. one wall switch (gpio3 down or gpio1 up) the up relay (gpio15) and down relay (gpio12) will be active for 20sec (totaly up or totally down)
if i press for time < 4sec the up relay or the down relay corrispondig remain active just for that time (1sec, 3sec, 3sec)
B) create in domoticz the command to have:
-)up moviment for 20 sec (blind totaly up)
-) down moviment for 20sec (blind totallu down)
-) condition if i pres for example up in domoticz, when i pres down (in a time < 20sec) the relay of up should be deactivated and the blind should stop its moviment

this two things are impossibile for me :(
and i'm getting crazy to implement
could you or someone help me? thanks very very very very much!

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#7 Post by megamarco83 » 23 Sep 2018, 12:47

grovkillen wrote: 23 Sep 2018, 12:25

In my example below you have the relay in series since you can have one for alternating the power to the motor (NO=up, NC=down) and the in-going current to that relay would be controlled by the second relay which would then only control ON or OFF.

That way you know that you never get a signal to the motor that is both up and down.
ehmm no, i need two different relay for shutter blind, one to go up, and another to go down
Image
that's the reason why i use:
gpio12 -> relè ch1 ->down
gpio3 -> fisical connect to wall switch down
gpio15 -> relè ch2 ->up
gpio1 -> fisical connect to wall switch up
grovkillen wrote: 23 Sep 2018, 12:25 The relay controlling the up or down is set to GPIO 15 and the on or off is set to GPIO 12. I name them as BlindsPower and BlindsDirection and their value is named State (for both).

I'm not sure what your button (wall switch?) is doing, if it's connected to the ESP or not. But I will use a switch plugin in this example and name the switch Button and its value State.
Image
the wall switch is connected to esy (nodemcu)
gpio12 -> relè ch1 ->down
gpio3 -> fisical connect to wall switch down (put gpio3 to GND when it's pressed)
gpio15 -> relè ch2 ->up
gpio1 -> fisical connect to wall switch up (put gpio1 to GND when it's pressed)
grovkillen wrote: 23 Sep 2018, 12:25 EDIT: I realize now that I didn't use the switch devices for the relays... so either you use the dummy as I did or you add the relays to a switch device and use them (their values) instead of a dummy. Either way works but using dummy only cost you 1 task spot on the list compared to using switches to know their states which would cost you 2.
i not catch this point what you mean?...sorry :(

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#8 Post by megamarco83 » 23 Sep 2018, 13:23

Image
this is the connection of esp (nodemcu)
the wall switch is connected to esy (nodemcu)
gpio12 -> relè ch1 ->down
gpio3 (green cable)-> fisical connect to wall switch down (put gpio3 to GND when it's pressed)
gpio15 -> relè ch2 ->up
gpio1 (yellow cable)-> fisical connect to wall switch up (put gpio1 to GND when it's pressed)

this is the domoticz dymmy switch device that i create
Image

could you help me to create a working rule that:

1) DOMOTICZ RECOGNIZE CHANGE STATUS
using the two wall switch (up and down) that are connected to gpio3 (down) and gpio1 (up)
if they are pressed domoticz shuld recognize

2) GPIO WALL SWITCH MOVIMENT
if i press wall switch down (gpio3 green cable) -> (relay on gp12 active)

BUT if after up (gpio1 to GND -> relay on gpio15 active), i press again up the relay to up must be deactivated
OR if after up (gpio1 to GND -> relay on gpio15 active) i pres DOWN direction (gpio3 to GND -> relay on gpio12 active) the relay on GPIO15 MUST BE deactivate, otherwise the motor receive up and down direction simmultaneously: only one relay (gpio12 or gpio15) could be active in the same time

3) RECOGNISE TIME OF PRESSURE OF WALL SWITCH GPIO
if i presss up or down ((gpio1 or gpio3) for time >= 4sec. one wall switch (gpio3 down (green cable)) i want to:
-> the down relay (gpio12) will be acrivated for 20sec ( 20sec is the time to completly go down of my blind)
(of course the same story for direction up (reley up=GPIO15 and wall switch to up=GPIO15 (yellow cable))
and of course

if i press up or down (gpio1 or gpio3) for time < 4sec the corrisponding rele (gpio15 or gpio12) will be activate only for the amount of time that i press (1sec or 2sec or 3sec)


4) DOMOTICZ USING OF RELAY
create in domoticz the command to have: up moviment for 20 sec (blind totaly up) + down moviment for 20sec (blind totallu down) and if i pres for example up in
domoticz, when i pres down (in a time < 20sec) the relay of up should be deactivated and the blind should stop its moviment

thanks so much

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#9 Post by grovkillen » 23 Sep 2018, 16:21

I don't use Domoticz myself do that part is not my speciality. But have you tried to modify my example rule to fit your need?

Regarding adding switch devices/tasks to monitor the relay is just as good as having dummy devices/tasks but you can only have one relay per task so that makes it a bit bulky. You seem to use the switch device round route so then you don't need to care about populating the dummy. Anyway, you should probably try to write simple rules until you start with this bigger rule. If I do it for you, you will not learn I think.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#10 Post by enesbcs » 23 Sep 2018, 17:33

I think you should start little steps. There are several good solutions, but in your place i would start like this:

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
  timerset,1,2
 endif 
endon

on B_UP#Longpress do
 if [relayp#R_UP]>0
  output,relayp,0,0
 else
  output,relayp,1,0
  output,relayp,0,1
  timerset,1,20
 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
  timerset,2,2
 endif 
endon

on B_DOWN#Longpress do
 if [relayp#R_DOWN]>0
  output,relayp,1,0
 else
  output,relayp,0,0
  output,relayp,1,1
  timerset,2,20
 endif 
endon

on Rules#Timer=1 do
 output,relayp,0,0
endon

on Rules#Timer=2 do
 output,relayp,1,0
endon 
Shortpress and Longpress provided by P159 plugin:
https://github.com/enesbcs/ESPEasyPlugi ... button.ino
Output command and output gpio state registering, with cross-blocking provided by P160 plugin:
https://github.com/enesbcs/ESPEasyPlugi ... tMulti.ino
These two plugin has to be compiled, proposed settings attached as image.

For Domoticz communication, perhaps the Publish command would be useful. This part has to be found out.
Attachments
P159&amp;P160 settings
P159&P160 settings
blind_settings.jpg (122.73 KiB) Viewed 27922 times

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#11 Post by megamarco83 » 23 Sep 2018, 17:40

grovkillen wrote: 23 Sep 2018, 16:21 I don't use Domoticz myself do that part is not my speciality. But have you tried to modify my example rule to fit your need?
yes sure, i'm trying since this morning but with no succes on using your suggestion of dummy

grovkillen wrote: 23 Sep 2018, 16:21 Regarding adding switch devices/tasks to monitor the relay is just as good as having dummy devices/tasks but you can only have one relay per task so that makes it a bit bulky. You seem to use the switch device round route so then you don't need to care about populating the dummy. Anyway, you should probably try to write simple rules until you start with this bigger rule. If I do it for you, you will not learn I think.
ok, true, but i tried to write rule...9hours yesterday and today, and i'm very frustrating because...what i'm succed on making rule working for 1 click = 20sec activation relay.
and also to prevent double activation, and i succed on give to domoticz the right positioning using rules
what for me is impossible is to implement the check about pressing wall switch for less than 4 sec and for more than 4 sec.
anyway i need to use 2 different phisical relay: first relay to go up and second relay to go down
could you help me on that?

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#12 Post by megamarco83 » 23 Sep 2018, 17:51

enesbcs wrote: 23 Sep 2018, 17:33
Shortpress and Longpress provided by P159 plugin:
https://github.com/enesbcs/ESPEasyPlugi ... button.ino
Output command and output gpio state registering, with cross-blocking provided by P160 plugin:
https://github.com/enesbcs/ESPEasyPlugi ... tMulti.ino
These two plugin has to be compiled, proposed settings attached as image.
thanks so mutch for your suggestion!!
now i download on my windows pc the two sketch .ino
i see this guide:
https://www.letscontrolit.com/wiki/inde ... are_Upload
but if i open the ESPEasy.ino the tutorla say:
In the top of the .ino file you find the defines you can uncomment to enable a plugin set:

//build all the normal stable plugins
//#define PLUGIN_BUILD_NORMAL

//build all plugins that are in test stadium
//#define PLUGIN_BUILD_TESTING

//build all plugins that still are being developed and are broken or incomplete
//#define PLUGIN_BUILD_DEV

Remove the // from the plugin sets that you want to enable.
but there are not that lines...and...how i can add the two .ino that you suggest to compile my .bin file to flash?
thanks

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#13 Post by enesbcs » 23 Sep 2018, 18:43

megamarco83 wrote: 23 Sep 2018, 17:51 thanks so mutch for your suggestion!!
now i download on my windows pc the two sketch .ino
i see this guide:
https://www.letscontrolit.com/wiki/inde ... are_Upload
but if i open the ESPEasy.ino the tutorla say:
In the top of the .ino file you find the defines you can uncomment to enable a plugin set:

//build all the normal stable plugins
//#define PLUGIN_BUILD_NORMAL

//build all plugins that are in test stadium
//#define PLUGIN_BUILD_TESTING

//build all plugins that still are being developed and are broken or incomplete
//#define PLUGIN_BUILD_DEV

Remove the // from the plugin sets that you want to enable.
but there are not that lines...and...how i can add the two .ino that you suggest to compile my .bin file to flash?
thanks
Defines are moved to ESPEasy-Globals.h in recent versions:
#define PLUGIN_BUILD_TESTING
if you uncomment the above line, and copies the two ino files to the ESPEasy sources, than you are ready to compile.

Anyway, i attached a 4M binary for nodemcu with the plugins.
Attachments
ESPEasy.4M_241_Nodemcu.zip
(514.04 KiB) Downloaded 320 times

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#14 Post by megamarco83 » 23 Sep 2018, 19:28

enesbcs wrote: 23 Sep 2018, 18:43
Remove the // from the plugin sets that you want to enable.
enesbcs wrote: 23 Sep 2018, 18:43 Defines are moved to ESPEasy-Globals.h in recent versions:
#define PLUGIN_BUILD_TESTING
if you uncomment the above line, and copies the two ino files to the ESPEasy sources, than you are ready to compile.

Anyway, i attached a 4M binary for nodemcu with the plugins.
i thanks for the info
i tryed to flash your file .bin
but after flash not visible the wifi: esp_0

i tried also to use arduino sketch and compile modify the ESPEasy-Globals.h
like this:
//build all the normal stable plugins (on by default)
//#define PLUGIN_BUILD_NORMAL

//build all plugins that are in test stadium
#define PLUGIN_BUILD_TESTING

but also in this way is not visible the wifi esp_0


if i use #define PLUGIN_BUILD_NORMAL and compile from arduino sketch the wifi appear, but of course the firmware is without this two plugin

how i can solve?
thanks again!

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#15 Post by enesbcs » 23 Sep 2018, 20:23

megamarco83 wrote: 23 Sep 2018, 19:28 i thanks for the info
i tryed to flash your file .bin
but after flash not visible the wifi: esp_0

i tried also to use arduino sketch and compile modify the ESPEasy-Globals.h
like this:
//build all the normal stable plugins (on by default)
//#define PLUGIN_BUILD_NORMAL

//build all plugins that are in test stadium
#define PLUGIN_BUILD_TESTING

but also in this way is not visible the wifi esp_0


if i use #define PLUGIN_BUILD_NORMAL and compile from arduino sketch the wifi appear, but of course the firmware is without this two plugin

how i can solve?
thanks again!
The binary i have built is trying to connect to an SSID named "indebuurt1" with password "VnsqrtnrsddbrN". If it can't than after approx 30 seconds the ESP_Easy_0 AP should appear.
Hint: Try to erase all before flashing the binary, to avoid errors by possible different SPIFF data structures.

Or try to remove this line from the beginning of the two plugin:
#ifdef PLUGIN_BUILD_TESTING

and this from the end:
#endif

Now, you can try to recompile and reflash the resulting binary without PLUGIN_BUILD_TESTING enabled.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#16 Post by megamarco83 » 23 Sep 2018, 23:36

enesbcs wrote: 23 Sep 2018, 20:23
Hint: Try to erase all before flashing the binary, to avoid errors by possible different SPIFF data structures.

Or try to remove this line from the beginning of the two plugin:
#ifdef PLUGIN_BUILD_TESTING

and this from the end:
#endif

Now, you can try to recompile and reflash the resulting binary without PLUGIN_BUILD_TESTING enabled.
perfect, it works, i delete the memory
and then i use the suggestion about removing the beginning line and compiling...perfect!!!
i'm working with this since, and i put the comment just to be helpful for someone elese, i'll reply no to your code to stay in topic and to show my progess (only thanks you)
thanks

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#17 Post by megamarco83 » 24 Sep 2018, 00:16

enesbcs wrote: 23 Sep 2018, 17:33
Shortpress and Longpress provided by P159 plugin:
https://github.com/enesbcs/ESPEasyPlugi ... button.ino
Output command and output gpio state registering, with cross-blocking provided by P160 plugin:
https://github.com/enesbcs/ESPEasyPlugi ... tMulti.ino
These two plugin has to be compiled, proposed settings attached as image.
thanks to this 2 plugin the life is more easier :D
i compile them and configure as your image, so now we can share the rules and test.
i tested yours and working perfectly!!!!
amazing!!!
using wall switch logpress or shortpress the relay are activate correctly and never both together, wonderfull!
enesbcs wrote: 23 Sep 2018, 17:33 For Domoticz communication, perhaps the Publish command would be useful. This part has to be found out.
now the last tricky part...
to send to domoticz the message about opening or closing i modify your rules adding:
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Off
or
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=On
take into account that for domoticz:
action off = UP(open)
action on = DOWN(close)
and i create in domoticz a dummy switch device that as idx=31 and i set it as "venetian blinds EU"
Image
this is the rule modify:

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&param=switchlight&idx=31&switchcmd=Off     //send the status to domoticz  dummy switch idx=31
  timerset,1,2   // 2 sec as test to simulate single pulse of UP
 endif 
endon

on B_UP#Longpress 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&param=switchlight&idx=31&switchcmd=Off    //send the status to domoticz  dummy switch idx=31
  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&param=switchlight&idx=31&switchcmd=On   //send the status to domoticz  dummy switch idx=31
  timerset,2,2   // 2 sec as test to simulate single pulse of DOWN
 endif 
endon

on B_DOWN#Longpress 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&param=switchlight&idx=31&switchcmd=On   //send the status to domoticz  dummy switch idx=31
  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 
in this way i'm now be able to see on domoticz the correct status if i use the wall switch (gpio3 to down or gpio1 to UP)

what is still missing now: is to know the position of blind (i know that to open my blind it required 24sec for example and i want to use that time to know the position)


there is alo the function :

Code: Select all

SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Stop
but i try to put this function here:
on Rules#Timer=1 do
output,relayp,0,0
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Stop
endon

on Rules#Timer=1 do
output,relayp,0,0
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Stop
endon

but is not good because in this way when i look into domoticz i will not know if i have the blinds open or close. :|


i try to use that function because now the problem is in domoticz...how can i move the blind?

inside the dummy switch device in domoticz i could set two action:
action off = UP(open)
action on = DOWN(close)
Image

now, if i put on open: http://192.168.0.154/control?cmd=GPIO,15,1
and for closing: http://192.168.0.154/control?cmd=GPIO,12,1



it create a mess because, when i use the wall switch ,thanks to espeasy rule that i added above domoticz recognize for example that i close, and set the dummy switch to close, but consequently if i write on close( http://192.168.0.154/control?cmd=GPIO,12,1) now domoticz send to esp the command to put relay on gpio12 to on (close) and i have a loop :shock:
how i can solve this two last problems: now the position in domoticz and use domoticz to open/close the blind

thanks for huge support!

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#18 Post by megamarco83 » 24 Sep 2018, 01:21

....mybe a tricky part is to simulate for domoticz not the relay as i tried with:
command to open:
http://192.168.0.154/control?cmd=GPIO,15,1

command to close:
http://192.168.0.154/control?cmd=GPIO,12,1


but simulate the wall switch, so the GPIO3 and GPIO1

but if i use in domoticz for example:
http://192.168.0.154/control?cmd=GPIO,3,1
the button on task2 of espeasy that has state = 0 does not change to state =1...why?!?!
what's the http command to change the status of members of plugin "Switch input - Pushbutton" ?
thanks

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#19 Post by grovkillen » 24 Sep 2018, 06:43

If you create an event you can call that event by simply using this of syntax:

Code: Select all

http://192.168.0.154/control?cmd=event,<Event Name>
You can give the event up to four values to parse if that is needed.

viewtopic.php?t=3868

In the topic above you get the idea behind it.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#20 Post by enesbcs » 24 Sep 2018, 07:13

megamarco83 wrote: 24 Sep 2018, 01:21 ....mybe a tricky part is to simulate for domoticz not the relay as i tried with:
command to open:
http://192.168.0.154/control?cmd=GPIO,15,1

command to close:
http://192.168.0.154/control?cmd=GPIO,12,1


but simulate the wall switch, so the GPIO3 and GPIO1

but if i use in domoticz for example:
http://192.168.0.154/control?cmd=GPIO,3,1
the button on task2 of espeasy that has state = 0 does not change to state =1...why?!?!
what's the http command to change the status of members of plugin "Switch input - Pushbutton" ?
thanks
As grovkillen suggest it, you can use your own events.

http://192.168.0.154/control?cmd=GPIO,3,1 will never be good. Really, do some events, not so complicated.

Code: Select all

on myEventThatStartsUP 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&param=switchlight&idx=31&switchcmd=Off    //send the status to domoticz  dummy switch idx=31
  timerset,1,6   // 6 sec as test to simulate completly UP
 endif 
endon
This url will activate the above event:
http://192.168.0.154/control?cmd=event, ... atStartsUP

If you use P160 than please do NOT use GPIO command, use output instead as in the example rules!
And you need all commands inside "B_UP#Longpress", not just one... the state of the blind can be recorded in a spare Dummy variable inside ESPEasy.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#21 Post by megamarco83 » 24 Sep 2018, 09:52

enesbcs wrote: 24 Sep 2018, 07:13
As grovkillen suggest it, you can use your own events.

http://192.168.0.154/control?cmd=GPIO,3,1 will never be good. Really, do some events, not so complicated.
just to know, why is not correct to use directly GPIO ?
enesbcs wrote: 24 Sep 2018, 07:13 This url will activate the above event:
http://192.168.0.154/control?cmd=event, ... atStartsUP
ok, thanks, so i modify with this 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&param=switchlight&idx=31&switchcmd=Off
  timerset,1,2
 endif 
endon

on B_UP#Longpress 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&param=switchlight&idx=31&switchcmd=Off
  timerset,1,6
 endif 
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&param=switchlight&idx=31&switchcmd=On
  timerset,2,2
 endif 
endon

on B_DOWN#Longpress 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&param=switchlight&idx=31&switchcmd=On
  timerset,2,6
 endif 
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 
i removed SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=On (and Off) from event_DOWN_domoticz (or event_UP_domoticz)

in this way i'm able to control in domoticz
with:
action on:http://192.168.0.154/control?cmd=event,event_ON_domoticz
action off:http://192.168.0.154/control?cmd=event,event_DOWN_domoticz
(twisted)
from wall switch all woks well as previous, and in domoticz, i'm able:
if i press one direction, this direction will be activated for longpress time, if during this time i press again the same direction in domoticz the relay stop, if i press opposite direction the first relay stop and the second direction is activated
so good!
but the code is not as suggested, and i think that my code is wasting of line and not "well programmed"


if i use suggestion i modify 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&param=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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Off
  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&param=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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=On
  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 
i add event and i put inside the call SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=On (and Off)
in this way i'm able to control in domoticz
with:
action on:http://192.168.0.154/control?cmd=event,event_DOWN_domoticz
action off:http://192.168.0.154/control?cmd=event,event_UP_domoticz
(no twisted this time)

but now is worst than previous rules because if i press a command UP orDOWN in domoticz the relay is activate just for a while
enesbcs wrote: 24 Sep 2018, 07:13 If you use P160 than please do NOT use GPIO command, use output instead as in the example rules!
And you need all commands inside "B_UP#Longpress", not just one... the state of the blind can be recorded in a spare Dummy variable inside ESPEasy.
why i need inside longpress and shortpress ?
i create a dummy device in easpeasy
i select 4 sensors
and the name are:
shorpressUP
longressUP
shorpressDOWN
longressDOWN

but now how i can record the variable inside and let know domoticz to the positioning?
thanks

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#22 Post by enesbcs » 24 Sep 2018, 18:10

megamarco83 wrote: 24 Sep 2018, 09:52 just to know, why is not correct to use directly GPIO ?
When you issue gpio command, than output changes it states. Period.
When you issue output,relayp command, than output changes it states, checks if it collides with the Blocker expression, and register the output state in the specified UserVar (0-4) which can be read by relayp#R01...

When you use gpio command, than output state in P160 variables will not be in sync.
megamarco83 wrote: 24 Sep 2018, 09:52 but the code is not as suggested, and i think that my code is wasting of line and not "well programmed"
I think would use a selector switch in Domoticz, that can issue 10 several commands.
But can be done with multiple simple state switches.
megamarco83 wrote: 24 Sep 2018, 09:52 but now is worst than previous rules because if i press a command UP orDOWN in domoticz the relay is activate just for a while
You can do an ON event without the "timerset" command, in that case, the relay will not be deactivated, until you switch it off from Domoticz side. (more ever, at every Domoticz "Switch" device, you can specify an automatic off delay, after the switched on device turned to off state automatically)
megamarco83 wrote: 24 Sep 2018, 09:52 why i need inside longpress and shortpress ?

i create a dummy device in easpeasy
i select 4 sensors
and the name are:
shorpressUP
longressUP
shorpressDOWN
longressDOWN

but now how i can record the variable inside and let know domoticz to the positioning?
You can do any rules insided longpress & shortpress you wish. :)
If you have a Dummy device named "global" (and Task number in ESPEasy is 4) with values like shorpressUP, longressUP and for example you have created Dummy MQTT devices with IDX 11 and 12 (if you use the same idx-es for status reporting that you use for controlling the device it can cause an endless loop, so i suggesting new virtual IDX numbers for this purpose) for them, than:

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.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#23 Post by megamarco83 » 25 Sep 2018, 01:16

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&param=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&param=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
Image8.jpg (99.33 KiB) Viewed 27791 times

using your suggestion i go ahed creating a dummy device in espeasy:
Image3.jpg
Image3.jpg (166.75 KiB) Viewed 27791 times
that is configurated in this way:
Image1.jpg
Image1.jpg (127.95 KiB) Viewed 27791 times
Image2.jpg
Image2.jpg (35.45 KiB) Viewed 27791 times
now i created in domoticz 2 dummy switch device: idx 35 and 36
Image4.jpg
Image4.jpg (72.01 KiB) Viewed 27791 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
Image7.jpg (164.97 KiB) Viewed 27790 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&param=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&param=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&param=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
Image8.jpg (99.33 KiB) Viewed 27791 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

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#24 Post by grovkillen » 25 Sep 2018, 05:49

Just a quick thing. How about adding a SendToHTTP I'm the event_UP_domoticz event? Just to update Domoticz.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#25 Post by enesbcs » 25 Sep 2018, 07:06

grovkillen wrote: 25 Sep 2018, 05:49 Just a quick thing. How about adding a SendToHTTP I'm the event_UP_domoticz event? Just to update Domoticz.
Good idea!

megamarco83:
Also if you put a SendToHTTP or Publish in section "on Rules#Timer...", that will update Domoticz in case of switching to OFF-ed by a timer automatically. I suspect it causes to never go off.
And for some reason you are using several "B_UP#Longpress" event handlers, i am not sure if it is a good thing, i am always using one from each "on ... endon" block. (with same name)

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#26 Post by grovkillen » 25 Sep 2018, 08:04

Yes the rules parser will trigger only the first appearance of an event.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#27 Post by megamarco83 » 25 Sep 2018, 08:55

enesbcs wrote: 25 Sep 2018, 07:06
grovkillen wrote: 25 Sep 2018, 05:49 Just a quick thing. How about adding a SendToHTTP I'm the event_UP_domoticz event? Just to update Domoticz.
Good idea!

megamarco83:
Also if you put a SendToHTTP or Publish in section "on Rules#Timer...", that will update Domoticz in case of switching to OFF-ed by a timer automatically. I suspect it causes to never go off.
And for some reason you are using several "B_UP#Longpress" event handlers, i am not sure if it is a good thing, i am always using one from each "on ... endon" block. (with same name)
sorry i do not understand your suggestion and the suggestion of grovkillen
if i put:

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&param=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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=40
 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&param=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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
 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


so this two row in both event domoticz UP and DOWN :

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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
endif
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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=40
endif
endon


and in domoticz i have:
Image1.jpg
Image1.jpg (155.38 KiB) Viewed 27764 times
After this adding:
when i press for long time (longress UP or longpress DOWN) i have the corrisponding relay triggered NOT for the 6sec but only for one second (it is activated and immediatly disactivated). So the longpress is not working (if i do not add the SendToHTTP above, the longress work but not report the status to domoticz)
same story if i press OPEN or CLOSE from domoticz, since i when adding the code SendToHTTP as show above, the corrisponding relay triggered from pressing in domoticz is not anymore for 6sec, but just for a second.(if i do not add the SendToHTTP above, the domoticz press of OPEN or CLOSE work for 6second and not only for a single pulse)

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#28 Post by enesbcs » 25 Sep 2018, 17:01

megamarco83 wrote: 25 Sep 2018, 08:55 sorry i do not understand your suggestion and the suggestion of grovkillen
I really do not understand what do you want to achieve with this SendtoHTTP thing.. i suggest to sit down a little, and rethink your code.

Code: Select all

on event_DOWN_domoticz do
 ...
 SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
 ...
endon
^
The above line calls the IDX:31 device at Domoticz - i assume it is "Tapparelle Generale" - and triggers its Level 0 action, which calls
http://192.168.0.154/control?cmd=event, ... N_domoticz, which calls again the IDX:31 device with the SendtoHTTP call,
which triggers again the event_DOWN_domoticz event on your nodemcu, and it continues for a while i think... Is it good for you?

Creating an ESPEasy rule to Domoticz without knowing one of them is a very brave thing. If you wants to UPDATE a switch status without starting a chain reaction, please read Domoticz forums about it:
https://www.domoticz.com/forum/viewtopi ... 5&start=20

Which is suggested before, to place some Publish statement to "on Rules#Timer=1 do" and "on Rules#Timer=2 do" blocks, because it is a very polite thing
to let it know with the Domoticz server, that the gpio changes it states...

"B_UP#Longpress" and "B_DOWN#Longpress" is also duplicated, it needs to be merged into one event. In the below code, i left out dummies in ESPEasy, but used 4 domoticz dummy idx.

Code: Select all

on B_UP#Shortpress do
 if [relayp#R_UP]>0
  output,relayp,0,0
  Publish domoticz/in,{"idx":45,"nvalue":0.00,"svalue":"Off"} // report idx:45 is in state OFF - shortpressup=0
 else
  output,relayp,1,0
  output,relayp,0,1
  Publish domoticz/in,{"idx":46,"nvalue":0.00,"svalue":"Off"} // report idx:46 is in state OFF - shortpressdown=0
  Publish domoticz/in,{"idx":45,"nvalue":1.00,"svalue":"On"} // report idx:45 is in state ON - shortpressup=1
  timerset,1,2
 endif 
endon

on B_DOWN#Shortpress do
 if [relayp#R_DOWN]>0
  output,relayp,1,0
  Publish domoticz/in,{"idx":46,"nvalue":0.00,"svalue":"Off"} // report idx:46 is in state OFF - shortpressdown=0
 else
  output,relayp,0,0
  output,relayp,1,1
  Publish domoticz/in,{"idx":45,"nvalue":0.00,"svalue":"Off"} // report idx:45 is in state OFF - shortpressup=0
  Publish domoticz/in,{"idx":46,"nvalue":1.00,"svalue":"On"} // report idx:46 is in state ON - shortpressdown=1
  timerset,2,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
  Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF - longpressup=0
 else
  output,relayp,1,0
  output,relayp,0,1
  Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:36 is in state OFF - longpressdown=0
  Publish domoticz/in,{"idx":35,"nvalue":1.00,"svalue":"On"} // report idx:35 is in state ON - longpressup=1
  timerset,1,6   // 6 sec as test to simulate completly UP
 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
  Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:36 is in state OFF - longpressdown=0
 else
  output,relayp,0,0
  output,relayp,1,1
  Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF - longpressup=0
  Publish domoticz/in,{"idx":36,"nvalue":1.00,"svalue":"On"} // report idx:36 is in state ON - longpressdown=1
  timerset,2,6   // 6 sec as test to simulate completly DOWN
 endif 
endon


on Rules#Timer=1 do
 output,relayp,0,0
 Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF
 Publish domoticz/in,{"idx":45,"nvalue":0.00,"svalue":"Off"} // report idx:45 is in state OFF
endon

on Rules#Timer=2 do
 output,relayp,1,0
 Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:36 is in state OFF
 Publish domoticz/in,{"idx":46,"nvalue":0.00,"svalue":"Off"} // report idx:46 is in state OFF
endon 

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#29 Post by megamarco83 » 25 Sep 2018, 18:57

enesbcs wrote: 25 Sep 2018, 17:01 I really do not understand what do you want to achieve with this SendtoHTTP thing.. i suggest to sit down a little, and rethink your code.
With this "SendtoHTTP thing" i would like to tell to domoticz that i press the wall switch (that is connected to nodemcu), and i would like that domoticz recognize the pression showing its status. Example:
if i longpress up wall switch -> domoticz will update the status of idx31 "Tapparelle Generale" as UP
if i shortpress up wall swhitch -> domoticz will update the status of idx31 "Tapparelle Generale" as UP
if logpress DOWN the wall switch -> domoticz will update the status of idx31 "Tapparelle Generale" as DOWN
if i shortpress up wall swhitch -> domoticz will update status of idx31 "Tapparelle Generale" as DOWN

if i press on domoticz: OPEN it will be send to ESP a command that activate the ralay UP for 6seconds
If i press on domoticz: CLOSE it will be to ESP a command that active the relay DOWN for 6 seconds

in both condition (pressing wall switch, or pressing domoticz button CLOSE/OPEN) only one relay must be active due to not burn the motor. for example:
if i press on domoticz CLOSE, and immediately after OPEN the relay gpio15 deactivate and relay GPIO12 activate

this is what i would like to implement...and i'm trying to do this, without success, after minimun 5 hours per day spending on it :( and what i do till now is just ONLY due to your help and support (i really apreciate and sorry for stress)
is it more clear now what i'm try to implement?

the amazing thing should be monitoring also the postion of the blind (ALL OPEN - 25% - 50% - 75% - ALL CLOSED)
but i think that is an impossible job for me, and i think that the only/smart way to do this is counting the seconds of relay pressed (that could be activated by wall switch ESP, or the relay could be activated by domoticz)

enesbcs wrote: 25 Sep 2018, 17:01

Code: Select all

on event_DOWN_domoticz do
 ...
 SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
 ...
endon

^
The above line calls the IDX:31 device at Domoticz - i assume it is "Tapparelle Generale" - and triggers its Level 0 action, which calls
http://192.168.0.154/control?cmd=event, ... N_domoticz, which calls again the IDX:31 device with the SendtoHTTP call,
which triggers again the event_DOWN_domoticz event on your nodemcu, and it continues for a while i think... Is it good for you?

Creating an ESPEasy rule to Domoticz without knowing one of them is a very brave thing. If you wants to UPDATE a switch status without starting a chain reaction, please read Domoticz forums about it:
https://www.domoticz.com/forum/viewtopi ... 5&start=20
correct!
what i'm trying to do without success after minimun 5 hours per day since 6days, is also that
with the SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
i would like to update in domoticz the status of the switch but i do no want to trigger it!!
i read the post, thanks, but i not understand how to change the status of my device idx=31 without triggering it
the post say:
commandArray['UpdateDevice'] = '263|10|10'
263 = idx
10 = level

but it seams a lua code...so could not be used inside a espeasy rule, right?



enesbcs wrote: 25 Sep 2018, 17:01 Which is suggested before, to place some Publish statement to "on Rules#Timer=1 do" and "on Rules#Timer=2 do" blocks, because it is a very polite thing
to let it know with the Domoticz server, that the gpio changes it states...

"B_UP#Longpress" and "B_DOWN#Longpress" is also duplicated, it needs to be merged into one event. In the above code, i left out dummies in ESPEasy, but used 4 domoticz dummy idx.

Code: Select all

on B_UP#Shortpress do
 if [relayp#R_UP]>0
  output,relayp,0,0
  Publish domoticz/in,{"idx":45,"nvalue":0.00,"svalue":"Off"} // report idx:45 is in state OFF - shortpressup=0
 else
  output,relayp,1,0
  output,relayp,0,1
  Publish domoticz/in,{"idx":45,"nvalue":1.00,"svalue":"On"} // report idx:45 is in state ON - shortpressup=1
  timerset,1,2
 endif 
endon

on B_DOWN#Shortpress do
 if [relayp#R_DOWN]>0
  output,relayp,1,0
  Publish domoticz/in,{"idx":46,"nvalue":0.00,"svalue":"Off"} // report idx:46 is in state OFF - shortpressdown=0
 else
  output,relayp,0,0
  output,relayp,1,1
  Publish domoticz/in,{"idx":46,"nvalue":1.00,"svalue":"On"} // report idx:46 is in state ON - shortpressdown=1
  timerset,2,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
  Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF - longpressup=0
 else
  output,relayp,1,0
  output,relayp,0,1
  Publish domoticz/in,{"idx":35,"nvalue":1.00,"svalue":"On"} // report idx:35 is in state ON - longpressup=1
  timerset,1,6   // 6 sec as test to simulate completly UP
 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
  Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:36 is in state OFF - longpressdown=0
 else
  output,relayp,0,0
  output,relayp,1,1
  Publish domoticz/in,{"idx":36,"nvalue":1.00,"svalue":"On"} // report idx:36 is in state ON - longpressdown=1
  timerset,2,6   // 6 sec as test to simulate completly DOWN
 endif 
endon


on Rules#Timer=1 do
 output,relayp,0,0
 Publish domoticz/in,{"idx":35,"nvalue":0.00,"svalue":"Off"} // report idx:35 is in state OFF
 Publish domoticz/in,{"idx":45,"nvalue":0.00,"svalue":"Off"} // report idx:45 is in state OFF
endon

on Rules#Timer=2 do
 output,relayp,1,0
 Publish domoticz/in,{"idx":36,"nvalue":0.00,"svalue":"Off"} // report idx:36 is in state OFF
 Publish domoticz/in,{"idx":46,"nvalue":0.00,"svalue":"Off"} // report idx:46 is in state OFF
endon 
with this code i create in domoticz the idx45 and idx46
now i have reported into domoticz the pressure of the wall switch
but now in what was i can use for my scope that i write in the beninnig this last point?
thanks

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#30 Post by enesbcs » 25 Sep 2018, 19:17

megamarco83 wrote: 25 Sep 2018, 18:57 what i'm trying to do without success after minimun 5 hours per day since 6days, is also that
with the SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
i would like to update in domoticz the status of the switch but i do no want to trigger it!!
i read the post, thanks, but i not understand how to change the status of my device idx=31 without triggering it
the post say:
commandArray['UpdateDevice'] = '263|10|10'
263 = idx
10 = level

but it seams a lua code...so could not be used inside a espeasy rule, right?
You are right that's pure LUA. You can watch IDX 35,36... as in the sample code is showed, at the Domoticz side in LUA.
Or you can try the "udevice" command which is the same: does not trigger itself, just refreshing the state of the Domoticz value.

Code: Select all

OFF
/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=0 
ON
/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=1
megamarco83 wrote: 25 Sep 2018, 18:57 with this code i create in domoticz the idx45 and idx46
now i have reported into domoticz the pressure of the wall switch
but now in what was i can use for my scope that i write in the beninnig this last point?
You can try the above udevice json commands to the original IDX:31 for first. (you have to replace necessary publish statements at the rules) but as i see the selector switch may not honor udevice command.
Or the second way is to hold the current Publish values and watch the new 35,36,45,46 "devicechanged" event in LUA scripts at the Domoticz side, and use commandArray['UpdateDevice'] to change IDX 31 state based on the four others mentioned.
https://www.domoticz.com/wiki/LUA_commands#Devices

Long way, but you are closer than ever. :)

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#31 Post by megamarco83 » 25 Sep 2018, 19:26

enesbcs wrote: 25 Sep 2018, 19:17 You are right that's pure LUA. You can watch IDX 35,36... as in the sample code is showed, at the Domoticz side in LUA.
Or you can try the "udevice" command which is the same: does not trigger itself, just refreshing the state of the Domoticz value.

Code: Select all

OFF
/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=0 
ON
/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=1
megamarco83 wrote: 25 Sep 2018, 18:57 with this code i create in domoticz the idx45 and idx46
now i have reported into domoticz the pressure of the wall switch
but now in what was i can use for my scope that i write in the beninnig this last point?
You can try the above udevice json commands to the original IDX:31 for first. (you have to replace necessary publish statements at the rules) but as i see the selector switch may not honor udevice command.
Or the second way is to hold the current Publish values and watch the new 35,36,45,46 "devicechanged" event in LUA scripts at the Domoticz side, and use commandArray['UpdateDevice'] to change IDX 31 state based on the four others mentioned.
https://www.domoticz.com/wiki/LUA_commands#Devices

Long way, but you are closer than ever. :)
i'll start in a couple of hours to try first to use the ndevice command...that's the simple way, but also the "economic way" because this is only for one windows, and i need:
1) dummy device to control the blind
4) dummy device just to record the show
1) code lua to drive from the dummy status the dummy device to control the blind

i have 8 windows ...it means 40decive in domoticz...!!!!! i'll be creazy!!! (more than in this days :))
plus i have to use lua (never use!)

i cross finger that you could support on this "trip" because i'm (from my point of view) very far from the ever....and i'm here only thanks to you and the forum!!!

p.s.
i also find this other method of domoticz to use the blind...it's a function dummy in domoticz named: "blinds with percentage"
but i do not understand how use the percentage....with lua again?
http://www.domoticz.com/forum/viewtopic.php?t=22735

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#32 Post by enesbcs » 25 Sep 2018, 19:49

megamarco83 wrote: 25 Sep 2018, 19:26 i'll start in a couple of hours to try first to use the ndevice command...that's the simple way, but also the "economic way" because this is only for one windows, and i need:
1) dummy device to control the blind
4) dummy device just to record the show
1) code lua to drive from the dummy status the dummy device to control the blind

i have 8 windows ...it means 40decive in domoticz...!!!!! i'll be creazy!!! (more than in this days :))
plus i have to use lua (never use!)
Currently I have 140 virtual devices in Domoticz, and it is not ready yet...
LUA scripting is not so complicated, for example:

Code: Select all

commandArray = {}
for deviceName,deviceValue in pairs(devicechanged) do
    if (deviceName=='myDummyDeviceNameToWatch') then
     if deviceValue == "On" then        
      commandArray['UpdateDevice'] = '31|0|0' -- idx:31,nvalue:0,svalue:0
     else
      commandArray['UpdateDevice'] = '31|10|10' -- idx:31,nvalue:0,svalue:10
     end
    end
end
return commandArray
But we moved away from ESPEasy.. :)

For sure, if you can use "udevice" with json, you can save the 4 dummy devices than it will be more "economic".
Just a hint: "nvalue" mainly used by simple switches, new Domoticz versions uses "svalue" and lately "svalue1" parameters for selector switches. So you have to try several possible commands, that can be used in browser and see what Domoticz reacts to it:

Code: Select all

/json.htm?type=command&param=udevice&idx=31&nvalue=0 
/json.htm?type=command&param=udevice&idx=31&nvalue=0&svalue=10
/json.htm?type=command&param=udevice&idx=31&nvalue=0&svalue1=10
/json.htm?type=command&param=udevice&idx=31&nvalue=10&svalue=10
/json.htm?type=command&param=udevice&idx=31&nvalue=10&svalue1=10
...
megamarco83 wrote: 25 Sep 2018, 19:26 i also find this other method of domoticz to use the blind...it's a function dummy in domoticz named: "blinds with percentage"
but i do not understand how use the percentage....with lua again?
http://www.domoticz.com/forum/viewtopic.php?t=22735
I do not know this blinder specific device, but if you can make it work with a simple selector switch, than it will work with this also.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#33 Post by megamarco83 » 26 Sep 2018, 01:45

enesbcs wrote: 25 Sep 2018, 19:49 For sure, if you can use "udevice" with json, you can save the 4 dummy devices than it will be more "economic".
Just a hint: "nvalue" mainly used by simple switches, new Domoticz versions uses "svalue" and lately "svalue1" parameters for selector switches. So you have to try several possible commands, that can be used in browser and see what Domoticz reacts to it:
ok..."udevice" is amazing!!!
it update the device in domoticz without triggering the device.
also today, after hours of testing and learning....

i summarize here the progress, what i need:

if i longpress up wall switch -> domoticz will update the status of idx31 "Tapparelle Generale" as UP OK
if i shortpress up wall swhitch -> domoticz will update the status of idx31 "Tapparelle Generale" as UP OK
if logpress DOWN the wall switch -> domoticz will update the status of idx31 "Tapparelle Generale" as DOWN OK
if i shortpress up wall swhitch -> domoticz will update status of idx31 "Tapparelle Generale" as DOWN OK

if i press on domoticz: OPEN it will be send to ESP a command that activate the ralay UP for 6seconds OK
If i press on domoticz: CLOSE it will be to ESP a command that active the relay DOWN for 6 seconds OK

in both condition (pressing wall switch, or pressing domoticz button CLOSE/OPEN) only one relay must be active due to not burn the motor. for example:
if i press on domoticz CLOSE, and immediately after OPEN the relay gpio15 deactivate and relay GPIO12 activate OK

this is what i would like to implement...and i'm trying to do this, without success, after minimun 5 hours per day spending on it :( and what i do till now is just ONLY due to your help and support (i really apreciate and sorry for stress) ....very far from

what i learned from you, googoling and testing so much is:

/json.htm?type=command&param=udevice&idx=31&nvalue=0 => CHIUSO (led inside icon OFF)
/json.htm?type=command&param=udevice&idx=31&nvalue=0&svalue1=10 => CHIUSO (led inside icon OFF)
/json.htm?type=command&param=udevice&idx=31&nvalue=10&svalue1=10 => CHIUSO (led inside icon ON)
/json.htm?type=command&param=udevice&idx=31&nvalue=10&svalue=10 => 75% (led inside icon ON)
/json.htm?type=command&param=udevice&idx=31&nvalue=0&svalue=10 => 75% (led inside icon OFF)
i understand that nvalue=0 => icon led off - nvalue=1 => icon led ON
i do not undertand the difference between svalue and svalue1...

anyway the code in espeasy that allow to me to have all the green "OK" above is:

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&param=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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=udevice&idx=31&nvalue=1&svalue=40
 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&param=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
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=udevice&idx=31&nvalue=0&svalue=0
 endif 
endon


on Rules#Timer=1 do
 output,relayp,0,0
endon

on Rules#Timer=2 do
 output,relayp,1,0
endon 
now, to implement the last part (have the possibility to know the position of the blind: 25% 50% 75% all open or all closed) i think to act in this way:
Image1.jpg
Image1.jpg (126.96 KiB) Viewed 27723 times
this is my IDX31 with the steps of: all closed 25% 50% 75% all open
Image2.jpg
Image2.jpg (20.46 KiB) Viewed 27723 times
now to take the position of the blind and let domoticz share the positioning, the only way is to count the seconds to open the blind.
make some examples:
total close require 46seconds, so:
(46/100)*25 = 11.5seconds for 25%
(46/100)*50=23seconds for 50%
(40/100)*75=34seconds for 75%
and of course 46seconds for total open

how i can now use the espeasy to recognize longpress, or shortpress to track the moviment of the blind?
i try to use the event but with no success....could you help me?
thanks again....

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#34 Post by enesbcs » 26 Sep 2018, 07:13

megamarco83 wrote: 26 Sep 2018, 01:45 now, to implement the last part (have the possibility to know the position of the blind: 25% 50% 75% all open or all closed) i think to act in this way:
Image1.jpg

this is my IDX31 with the steps of: all closed 25% 50% 75% all open
Image2.jpg

now to take the position of the blind and let domoticz share the positioning, the only way is to count the seconds to open the blind.
make some examples:
total close require 46seconds, so:
(46/100)*25 = 11.5seconds for 25%
(46/100)*50=23seconds for 50%
(40/100)*75=34seconds for 75%
and of course 46seconds for total open

how i can now use the espeasy to recognize longpress, or shortpress to track the moviment of the blind?
i try to use the event but with no success....could you help me?
thanks again....
I'm happy that you have made some positive progress.
I am think about it, but only have some ideas now, and i have to go to work. :)
As i remember ESPEasy has 4 timers, and this script uses 2 of them, so we have 2 other. 11,5 sec will be problematic, try with 11sec first. (if not, you have to round up to 12)
You do not need "global" named dummy (task 3), so reuse it, name its first value as "blindstate".

changes1 (at longpress up event block):
taskvalueset,3,1,0
timerset,1,6 -> timerset,3,11

changes2 (at longpress down event block):
taskvalueset,3,1,40
timerset,2,6 -> timerset,4,11

code append to the end:

Code: Select all

on Rules#Timer=3 do
 if [global#blindstate]<31 // there are steps to go (40 is endpos)
  taskvalueset,3,1,([global#blindstate]+10)  // step the dummy variable
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=[global#blindstate]  // send to domoticz
  timerset,3,11   // retrigger timer if not finished
 else
  output,relayp,0,0
 end
endon

on Rules#Timer=4 do
 if [global#blindstate]>9 // one cycle left (0 is startpos)
  taskvalueset,3,1,([global#blindstate]-10)  // step the dummy variable
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=[global#blindstate]  // send to domoticz
  timerset,4,11   // retrigger timer if not finished
 else
  output,relayp,1,0
 end
endon 
This may be OK for tracking, but not for issuing for ex the 25% command from Domoticz.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#35 Post by megamarco83 » 27 Sep 2018, 00:00

enesbcs wrote: 26 Sep 2018, 07:13
You do not need "global" named dummy (task 3), so reuse it, name its first value as "blindstate".

changes1 (at longpress up event block):
taskvalueset,3,1,0
timerset,1,6 -> timerset,3,11

changes2 (at longpress down event block):
taskvalueset,3,1,40
timerset,2,6 -> timerset,4,11

code append to the end:

Code: Select all

on Rules#Timer=3 do
 if [global#blindstate]<31 // there are steps to go (40 is endpos)
  taskvalueset,3,1,([global#blindstate]+10)  // step the dummy variable
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=[global#blindstate]  // send to domoticz
  timerset,3,11   // retrigger timer if not finished
 else
  output,relayp,0,0
 end
endon

on Rules#Timer=4 do
 if [global#blindstate]>9 // one cycle left (0 is startpos)
  taskvalueset,3,1,([global#blindstate]-10)  // step the dummy variable
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=[global#blindstate]  // send to domoticz
  timerset,4,11   // retrigger timer if not finished
 else
  output,relayp,1,0
 end
endon 
This may be OK for tracking, but not for issuing for ex the 25% command from Domoticz.
maybe i'm wrong but i create the dummy devide:
Image3.jpg
Image3.jpg (104.28 KiB) Viewed 27677 times
Image4.jpg
Image4.jpg (51.13 KiB) Viewed 27677 times
Image5.jpg
Image5.jpg (59.2 KiB) Viewed 27677 times
now with this rules that i have modify:

Code: Select all

on Rules#Timer=3 do
 if [global#blindstate]<31 // there are steps to go (40 is endpos)
  taskvalueset,3,1,([global#blindstate]+10)  // step the dummy variable
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=[global#blindstate]  // send to domoticz
  timerset,3,11   // retrigger timer if not finished
 else
  output,relayp,0,0
 end
endon

on Rules#Timer=4 do
 if [global#blindstate]>9 // one cycle left (0 is startpos)
  taskvalueset,3,1,([global#blindstate]-10)  // step the dummy variable
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=switchlight&idx=31&switchcmd=Set%20Level&level=[global#blindstate]  // send to domoticz
  timerset,4,11   // retrigger timer if not finished
 else
  output,relayp,1,0
 end
endon 

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&param=switchlight&idx=31&switchcmd=Set%20Level&level=40
  timerset,1,2
 endif 
endon

on B_UP#Longpress do
event,event_UP_domoticz
taskvalueset,3,1,0
timerset,3,11
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,46   // 46 sec as test to simulate completly UP
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=udevice&idx=31&nvalue=1&svalue=40
 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&param=switchlight&idx=31&switchcmd=Set%20Level&level=0
 endif 
endon

on B_DOWN#Longpress do
taskvalueset,3,1,40
timerset,4,11
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,46   // 46 sec as test to simulate completly DOWN
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=udevice&idx=31&nvalue=0&svalue=0
 endif 
endon


on Rules#Timer=1 do
 output,relayp,0,0
endon

on Rules#Timer=2 do
 output,relayp,1,0
endon 

if i test i see this:

if i short press UP -> domoticz put to ALL OPEN (40) -> relè active for 1sec -> dummy variable 0

if i short press DOWN -> domoticz put to ALL CLOSE(0) -> relè active for 1sec dummy variable 0

if i press domoticz down -> domotictz put to all close (0) -> relè acrive for 46sec -> dummy variable 40

now that (domoticz show all close) if i long press UP -> domoticz put to 25% (30) (but i see that during the 46sec domoticz change the status of "tapparelle generale to close, than show 75% then 50% and finally stop to 25%) -> relè active for 11sec UP, then down for 46sec -> after that cycle real position should be all close (because 11sec up and 46sec down) -> dummy variable 40 -> domoticz show 25% (that means level 30)

if i start from domoticz show all open, if i long press DOWN -> domoticz put to 75% (10) (but i see that during the 46sec domoticz change the status of "tapparelle generale to open than show 25% then 50% and finally stop to 75%) -> relè active for 11sec down , then up for 46sec -> after that cycle real position should be all open (because 11sec down and 46sec up -> dummy variable 0 -> domoticz show 75% (that means level 10)

now i'm a little confused....

and another question is: whty i need to menage the postion using longpress!? for me is wrong doing in this way...
the only "fix" position: 25% - 50% -75% should be menaged only from domoticz
with the wall button, i could not set a precise percentage, i mean: if i longpress UP -> relay should be acrivated for 46sec (all opening), and i want to stop my blind i simply press when i want the shortpress UP, and my blind stop in that time in that position. ESP rules shuld track the amount of sec that are passed and send this valute to domoticz, a script convert the seconds in a percentage. for example, starting for all close i longress UP (relay start to UP with a time of 46sec) after 15sec i want to stop my blind i press DOWN shortpress on the wall e the blind stop in that position that i choose. ESP rules should have counting this 15sec passed and give to domoticz that calcolate: (15sec / 46sec ) * 100= 36% and show on the blind with percentage open 36%

if i use a shortpress esp rules activate the relay for 1sec -> send to domoticz the value 1sec -> domoticz calcolate (1sec / 46 sec) * 100 = 2% open
if i use again a shorpress from wall swith ->esp rules activate the relay for 1sec -> send to domoticz the value 1sec -> domoticz calcolate (1sec / 46 sec) * 100 = 2% open + 2% of previous position = 4%open or esp rules should send n° of seconds and n° of shortpress did

from the opposite side (starting control from domoticz) if i set 50% position in domoticz, domoticz (with lua?!?) should count: (46sec / 100 ) * 50 = 23 sec -> domoticz will activate the relay down for 23sec to have 50%

i think that above shold be the logic of the programming...i do not know how to implement, but i do not think that is possible in EspEasy Rules, right?

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#36 Post by enesbcs » 27 Sep 2018, 20:01

megamarco83 wrote: 27 Sep 2018, 00:00 and another question is: whty i need to menage the postion using longpress!? for me is wrong doing in this way...
Then manage another way. It is only a sample code.
Trial and error is a scientific method. I am using it always.
megamarco83 wrote: 27 Sep 2018, 00:00 i think that above shold be the logic of the programming...i do not know how to implement, but i do not think that is possible in EspEasy Rules, right?
Network delay is a real phenomenon. You can accept it or you can handle timing at both side. With ESPEasy rules parallel with Domoticz LUA. Or wait someone who implements your requirements inside an ESPEasy plugin which may be more quicker than a complex ruleset.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#37 Post by megamarco83 » 28 Sep 2018, 16:24

enesbcs wrote: 27 Sep 2018, 20:01
megamarco83 wrote: 27 Sep 2018, 00:00 and another question is: whty i need to menage the postion using longpress!? for me is wrong doing in this way...
Then manage another way. It is only a sample code.
Trial and error is a scientific method. I am using it always.
megamarco83 wrote: 27 Sep 2018, 00:00 i think that above shold be the logic of the programming...i do not know how to implement, but i do not think that is possible in EspEasy Rules, right?
Network delay is a real phenomenon. You can accept it or you can handle timing at both side. With ESPEasy rules parallel with Domoticz LUA. Or wait someone who implements your requirements inside an ESPEasy plugin which may be more quicker than a complex ruleset.
mmm ok, so i can only wait for someone that implement a plugin to menage the open/close with postion about the blinds ?
but it's strange that during this years no one had an application about ESP with blinds + wall switched and monitoring the position :)
do you think that there is a possibility in future to have a plugin specific for blind? maybe in playground?
thanks !!
i learned so much during this trip with blinds, thanks expecially to you and your patience :) but i do not have any idea how to proceed

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#38 Post by grovkillen » 28 Sep 2018, 17:07

For position of my garage door I use a pulse encoder.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#39 Post by megamarco83 » 28 Sep 2018, 17:18

can you explain to me better? maybe with your example more detailed?
thanks so much for that!

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: rules for roller shutter on nodemcu+relays 2ch

#40 Post by grovkillen » 28 Sep 2018, 17:20

ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: rules for roller shutter on nodemcu+relays 2ch

#41 Post by megamarco83 » 19 Oct 2018, 15:43

enesbcs wrote: 27 Sep 2018, 20:01
megamarco83 wrote: 27 Sep 2018, 00:00 and another question is: whty i need to menage the postion using longpress!? for me is wrong doing in this way...
Then manage another way. It is only a sample code.
Trial and error is a scientific method. I am using it always.
megamarco83 wrote: 27 Sep 2018, 00:00 i think that above shold be the logic of the programming...i do not know how to implement, but i do not think that is possible in EspEasy Rules, right?
Network delay is a real phenomenon. You can accept it or you can handle timing at both side. With ESPEasy rules parallel with Domoticz LUA. Or wait someone who implements your requirements inside an ESPEasy plugin which may be more quicker than a complex ruleset.
...i'm back with a request.
i'm able now to control the percentage in domoticz, and to not interfer with rules on espeay, when i use the command inside domoticz to move the blind, i do send the command to espeasy but directly to relay.
example: if i uso domoticz to go UP -> i trigger directly the relay UP and not the event inside ESPeasy

now i want to prevent that if someone is using the domoticz command, someone else could simmultaneusly use the wall switch.
to prevent that i think that when someone is using domoticz to control the blind, should sent to espeasy a variable to lock the wall switch, example:
http://192.168.0.154/control?cmd=event,blind_1_BLOCK
http://192.168.0.154/control?cmd=event,blind_1_UNBLOCK

now how i can create an event called: "blind_1_BLOCK" where i can not allow the wall switch?
and when domoticz send the "blind_1_UNBLOCK" the wall switch became usable?

this is my update rules:

Code: Select all

on B_UP#Shortpress do
event,event_UP_SHORT_blind_test
endon

on event_UP_SHORT_blind_test do
 if [relayp#R_UP]>0
  output,relayp,0,0
 else
  output,relayp,1,0
  output,relayp,0,1
 timerset,1,2 // to trigger relay UP direction for 2seconds
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=updateuservariable&vname=blindControl&vtype=2&vvalue={"n":"blind_test","d":"UP","s":"2"}
  endif 
endon

on B_UP#Longpress do
event,event_UP_LONG_blind_test
endon

on event_UP_LONG_blind_test do
 if [relayp#R_UP]>0
  output,relayp,0,0
 else
  output,relayp,1,0
  output,relayp,0,1
  timerset,1,42   //  to trigger relay UP direction for 42seconds
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=updateuservariable&vname=blindControl&vtype=2&vvalue={"n":"blind_test","d":"UP","s":"42"}
 endif 
endon

on B_DOWN#Shortpress do
event,event_DOWN_SHORT_blind_test
endon

on event_DOWN_SHORT_blind_test do
 if [relayp#R_DOWN]>0
  output,relayp,1,0
 else
  output,relayp,0,0
  output,relayp,1,1
 timerset,2,2 // to trigger relay DOWN direction for 2seconds
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=updateuservariable&vname=blindControl&vtype=2&vvalue={"n":"blind_test","d":"DOWN","s":"2"}
 endif 
endon

on B_DOWN#Longpress do
event,event_DOWN_LONG_blind_test
endon

on event_DOWN_LONG_blind_test do
 if [relayp#R_DOWN]>0
  output,relayp,1,0
 else
  output,relayp,0,0
  output,relayp,1,1
  timerset,2,36   // to trigger relay DOWN direction for 36seconds
SendToHTTP 192.168.0.105,8085,/json.htm?type=command&param=updateuservariable&vname=blindControl&vtype=2&vvalue={"n":"blind_test","d":"DOWN","s":"46"}
 endif 
endon

on Rules#Timer=1 do
 output,relayp,0,0
endon

on Rules#Timer=2 do
 output,relayp,1,0
endon

jannnfe
Normal user
Posts: 16
Joined: 19 Jan 2018, 13:16

Re: rules for roller shutter on nodemcu+relays 2ch

#42 Post by jannnfe » 01 Feb 2019, 23:55

Hey @megamarco83,
Im looking for a Solution as discribed, too.
Do you have a final result thats working?
Maybe you want to share your current stat?
Thanks Jan

bojan
Normal user
Posts: 11
Joined: 29 Aug 2018, 07:55
Location: Ljubljana, Slovenia

Re: rules for roller shutter on nodemcu+relays 2ch

#43 Post by bojan » 12 Feb 2019, 20:17

I'm a big fan of the ESPEasy, but for the shutters I would recommend the Stefan Bode's fork of the Tasmota.
https://github.com/stefanbode/Sonoff-Ta ... two-relays

Also, don't forget to protect the relay contacts (add snubber RC circuit)

pmalvino
Normal user
Posts: 15
Joined: 03 Aug 2016, 22:34

Re: rules for roller shutter on nodemcu+relays 2ch

#44 Post by pmalvino » 11 Apr 2020, 13:27

Code: Select all

//EVENTOS VIA DOMOTICZ

On abrir do
  gpio,16,0
  gpio,14,1
  timerSet,1,25
endon  

On Rules#Timer=1 do  //When Timer1 expires, do
  gpio,14,0
endon

On fechar do
  gpio,14,0
  gpio,16,1
  timerSet,2,25
endon

On Rules#Timer=2 do  //When Timer2 expires, do
  gpio,16,0
endon


//TECLAS ESP8266

On Tabrir#Tabrir do
    gpio,16,0
    gpio,14,[Tabrir#Tabrir]
    timerSet,3,25
endon

On Rules#Timer=3 do  //When Timer3 expires, do
     gpio,14,0 
    inputswitchstate 0,0
endon

On Tfechar#Tfechar do
    gpio,14,0
    gpio,16,[Tfechar#Tfechar]
    timerSet,4,25
endon

On Rules#Timer=4 do  //When Timer4 expires, do
  gpio,16,0
  inputswitchstate 0,0
endon


devices.PNG
devices.PNG (24.04 KiB) Viewed 19673 times
switch.PNG
switch.PNG (24.47 KiB) Viewed 19673 times
This is my code for blinds control.
i dont know if it helps.
Pedro
Portugal

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests