set the timer value variable

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
edstobi
Normal user
Posts: 41
Joined: 28 May 2020, 20:33

set the timer value variable

#1 Post by edstobi » 27 Dec 2021, 23:22

Hello
I get from the mqtt server a number sent to the espeasy. This number should be used in the rules as a parameter for a timer.
e.g. I send to mqtt a 100 then the timer should execute an action for 100 minutes. After completion the esp waits until the next action, before the action it looks if there is a new value in the Generic - MQTT Import. if yes this value is taken.

My problem is how do I tell the timer to take this variable?
TimerSet,1,[mqtt_in#nr] does not work.
is there another way to set the timer value variable?

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

Re: set the timer value variable

#2 Post by TD-er » 27 Dec 2021, 23:25

How do you receive the value from the MQTT broker?
Is it via MQTT import, or do you send a command (topic ending with /cmd) ?

If MQTT import receives a value, then it should send out an event.
You can act on this event by setting the timer.

Code: Select all

on mqtt_in#nr do
  TimerSet,1,%eventvalue1%
endon

edstobi
Normal user
Posts: 41
Joined: 28 May 2020, 20:33

Re: set the timer value variable

#3 Post by edstobi » 28 Dec 2021, 09:42

Thank you very much.
I have tried to work with [ xx#yy]. Your hint worked right away :D


:oops: edit
And my variant works also if you correct the spelling mistakes.
timerSet,2,[NodeRED#nr]]
:cry:

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

Re: set the timer value variable

#4 Post by TD-er » 28 Dec 2021, 13:20

Glad it is solved :)

Just another tip for debugging and writing rules.
We do have a syntax highlighter for ESPEasy rules for Notepad++
See: https://github.com/letscontrolit/ESPEas ... epad%2B%2B

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests