simulate button pressing of remote control

Moderators: grovkillen, Stuntteam, TD-er

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

simulate button pressing of remote control

#1 Post by megamarco83 » 04 Oct 2019, 11:57

hi, my pellet heater is controlled by a remote control with 4keys:
1) increase flame level
2) increase fan level
3) temperatue set point up
4) temperature set point down

i want to control it with domoticz, so i open the remote control and i connect every key to 4 relays.

now with domoticz, i control the relay send a mqtt command to espeasy that close the relay to simulate the key pressing on remote control.

now i would like to implement that if i press the key on remote control, espeasy send to domoticz the message.
i think a rule like:

Code: Select all

on button_flame#switch do 
   Publish domoticz/in,{"command":"setuservariable","idx":xxxx,"value":"xxxx"}
endon
and with domoticz i read the uservar and convert to proper action.

the problem, where i need some helps is that my remote control after 40seconds go in "sleep mode"
if the remote control is in sleep mode, the first pression of a key will do nothing, it just wake up the remote control
The next key pressing will change the conresponding status. ( this is the same for all four keys)
how i can menage this???
thanks

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: simulate button pressing of remote control

#2 Post by TD-er » 04 Oct 2019, 12:18

You could store the value in a variable.
See "let" command in the documentation: https://espeasy.readthedocs.io/en/lates ... mmand.html
Then you can set 2 timers, one for "starting" the remote and one for sending the command.
These timers can then be executing the command based on the stored value.

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

Re: simulate button pressing of remote control

#3 Post by megamarco83 » 04 Oct 2019, 12:28

TD-er wrote: 04 Oct 2019, 12:18 You could store the value in a variable.
See "let" command in the documentation: https://espeasy.readthedocs.io/en/lates ... mmand.html
sorry for asking stupid question, but can you explain a bit more in what way i can store in a variable?
you mean to insert a task as" generic - dummy device" and store here the variable?

"let" command is also implemented in the old version of espeasy?
TD-er wrote: 04 Oct 2019, 12:18 Then you can set 2 timers, one for "starting" the remote and one for sending the command.
These timers can then be executing the command based on the stored value.
also here can you provide an example?
i'm not a software programmer, so i find difficulties with this help, sorry again to make stupid question, and tanks for help
Last edited by megamarco83 on 04 Oct 2019, 12:31, edited 1 time in total.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: simulate button pressing of remote control

#4 Post by TD-er » 04 Oct 2019, 12:35

Let has been introduced recently, so if you're using an older version then you should use the Dummy plugin and taskvalueset.
About setting a timer, please have a look here: https://espeasy.readthedocs.io/en/lates ... Rules.html
Look for "timerSet" to see some examples.

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

Re: simulate button pressing of remote control

#5 Post by megamarco83 » 04 Oct 2019, 12:42

hi, thanks for explanation.
i used timer and i quite understand how to use.
for example i use timer1 to update a string in domoticz when i reboot and timer2 for reboot my unit at special time.

Code: Select all

On System#Boot do    //When the ESP boots, do relay to OFF just to be sure
  PCFgpio,65,1
  PCFgpio,66,1
  PCFgpio,67,1
timerSet,1,8
endon

On Rules#Timer=1 do
// MQTT
Publish domoticz/in,{"command":"setuservariable","idx":21,"value":"ESP204_rebootMQTT"}
endon

On Clock#Time=All,02:01 Do
 WifiDisconnect
 timerSet 2,4
 EndOn

on Rules#Timer=2 do
 Reboot
endon
but i do not understand your suggestion to use dummy device (prefer to have compatibility with sonoff installed in march that is difficult to rech to flash new FW)
and two timers to send "sleep comand" or "alive comand"
if you can explain better just for my understanding
thanks
Last edited by megamarco83 on 04 Oct 2019, 14:02, edited 1 time in total.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: simulate button pressing of remote control

#6 Post by TD-er » 04 Oct 2019, 12:58

Jimmy (Grovkillen) is much better at writing rules, so I will just describe my ideas. (if he dislikes it, he will post here, I'm sure)

The idea is in your initial trigger, you can set 2 timers.

on <your received event> do
taskvalueset,<task>,<value> // Value is probably the relais nr you want to trigger.
timerset,1,1 // set timer 1 in 1 second
timerset,2,2 // set timer 2 in 2 seconds, just one second after the first.
endon // (you have "enddo" in the rules you posted, not sure if that will work)

on rules#timer=1 do // process timer 1
// Just do your thing with triggering the right relais
// Use the stored value to indicate which relais to toggle
endon

on rules#timer=2 do // process timer 2
// Same code as in rules timer 1
endon


Hope this does make it more clear and not more confusing :)

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

Re: simulate button pressing of remote control

#7 Post by megamarco83 » 04 Oct 2019, 14:01

hi, thanks for explanation

but, if i'm not wrong, with this rules, every time that i press a key on my remote control, the rules in first time in rules#timer=1 and then rules#timer=2
in this case, when my remote control is sleeping, it's ok, because first timer wake up teh remote contro, and second timer perform the key pressing, but if i press a second time the remote control key, the remote control is now wake up, an so, with only a single press (the second one) the esp send two times the command (timer1 + timer2)
correct?
thanks

p.s. inside my code of rules i write "endo" it's an error of copy/paste, it's endon, sorry, i will correct now

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: simulate button pressing of remote control

#8 Post by TD-er » 04 Oct 2019, 15:16

Yes you're right, if the keys are pressed in quick succession, then it will probably not work like it should.
You could keep track of it with an extra timer check, or maybe press another button to wake it, which will not change the operation of the device.

For example the remote is sleeping after 30 seconds of inactivity.
Each time you set the timer 1, it will re-set its internal counter.
So then you can set a 3rd timer each time you send out a value.
This 3rd timer is then set to like 30 seconds and will store a value indicating the remote is asleep again.

So in the wake call you can check if this dummy value is set to "0" (asleep) and then wake it up.
After wake up, you store the "1" (awake) in the dummy.
Remember, after each key press you set the timer3 again.

In your 3rd timer call you just set the dummy value back to 0 again.

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

Re: simulate button pressing of remote control

#9 Post by megamarco83 » 04 Oct 2019, 15:58

i think that it could now work...but very hard to me to setup a rule...
i think that we need the help of Grovkillen.
hope that he can write the correct rule :-)

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

Re: simulate button pressing of remote control

#10 Post by grovkillen » 06 Oct 2019, 04:05

I would seriously consider updating the unit to get more functionality = easier rules. But here's my take with older syntax:

Code: Select all

On System#Boot Do    //When the ESP boots, do relay to OFF just to be sure
  PCFgpio,65,1
  PCFgpio,66,1
  PCFgpio,67,1
EndOn

On WakeUpRemote Do
 If [Dummy#Value]=0
  TaskValueSet,12,1,1
  TimerSet,1,40
  PCFgpio,65,0 //simulate button press
  PCFgpio,65,1
 EndIf
EndOn

On FlameLevelUp Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  PCFgpio,XX,0
  PCFgpio,XX,1
EndOn

On FanLevelUp Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  PCFgpio,XX,0
  PCFgpio,XX,1
EndOn

On TempSetPointUp Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  PCFgpio,XX,0
  PCFgpio,XX,1
EndOn

On TempSetPointDown Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  PCFgpio,XX,0
  PCFgpio,XX,1
EndOn

On Rules#Timer=1 Do
  TaskValueSet,12,1,0
EndOn
But please come back here if you decide to update. There's more delicate ways of doing it with latest versions.
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: simulate button pressing of remote control

#11 Post by megamarco83 » 07 Oct 2019, 09:15

grovkillen wrote: 06 Oct 2019, 04:05 I would seriously consider updating the unit to get more functionality = easier rules. But here's my take with older syntax:

But please come back here if you decide to update. There's more delicate ways of doing it with latest versions.

Hi Griovkillen thanks for help and fast reply.
i look your rules and i understand the logic behind and it looks very promising!
i just adapt it and make some comments:

Code: Select all

On System#Boot Do    //When the ESP boots, do relay to OFF just to be sure
  gpio,13,1 //fan
  gpio,14,1 //flame
  gpio,4,1 //temp up
  gpio,5,1 //temp down
EndOn

On WakeUpRemote Do
 If [Dummy#Value]=0
  TaskValueSet,12,1,1  //task 12 set as dummy variable, if 0=>asleep if 1=>system wakeup
  TimerSet,1,40
  gpio,13,0 //simulate button press using fan pusch button
  gpio,13,1
 EndIf
EndOn

On FlameLevelUp Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  gpio,14,0
  gpio,14,1
EndOn

On FanLevelUP Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  gpio,13,0
  gpio,13,1
EndOn

On TempSetPointUp Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  gpio,4,0
  gpio,4,1
EndOn

On TempSetPointDown Do
 If [Dummy#Value]=0
  Event,WakeUpRemote
 EndIf
  TimerSet,1,40
  gpio,5,0
  gpio,5,1
EndOn

On Rules#Timer=1 Do
  TaskValueSet,12,1,0
EndOn
if you would like to change it with new function inside espeasy i will try to update manually the firmware.
Unfortunatly it has 1Mb so i have to flash manually and not using OTA and they are very difficult to reach, but it's a very old fw so i would like to try :-)
thanks again!

p.s. to call the event the command will be for example:
http://<espeasyip>/control?cmd=event,FlameLevelUp
or
http://<espeasyip>/control?cmd=event,TempSetPointDown
that's correct?

but if i would like to use mqtt?
now to control directly a gpio i use:
sudo mosquitto_pub -t /wemos_205/cmd -m gpio,4,0
where wemos_205 is the ESP name, and in this example i set gpio 4 to 0

if i need to control the event with mqtt is it possible?

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

Re: simulate button pressing of remote control

#12 Post by grovkillen » 07 Oct 2019, 10:20

Use the same command "event" as you do with the http command. Try to never use GPIO directly, always try to use events.
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: simulate button pressing of remote control

#13 Post by megamarco83 » 07 Oct 2019, 11:03

ok, thanks.
so can you confirm that one example for http command of event should be:
http://<espeasyip>/control?cmd=event,TempSetPointDown
that's correct?

and if i will use mqtt:

sudo mosquitto_pub -t /wemos_205/cmd -m TempSetPointDown
or
sudo mosquitto_pub -t /wemos_205/cmd -m event,TempSetPointDown
what's the right comand?

where <wemos_205> -> is the ESP name
<TempSetPointDown> -> is the event that i want to control
thanks

p.s. if you want to share the modifiaction of rules with new commands :-)

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

Re: simulate button pressing of remote control

#14 Post by grovkillen » 07 Oct 2019, 12:32

event,TempSetPointDown is the command you should send over MQTT.
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:

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: simulate button pressing of remote control

#15 Post by kimot » 09 Oct 2019, 21:39

And tried you capture and then using IRTX plugin retransmit the IR signal?
It would solve your problem with the awakening of the IR remote.
And it is more elegant solution.
viewtopic.php?f=2&t=2761&p=14045&hilit=IRTX#p14045

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

Re: simulate button pressing of remote control

#16 Post by megamarco83 » 09 Oct 2019, 21:48

Hi,thanks for reply, but i think that it is not an IR transmitter but a RF transmitter
I see that there is a 2mhz component...

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 36 guests