timer remaining time
Moderators: grovkillen, Stuntteam, TD-er
timer remaining time
Hi,
I have some long time (20 min or more) running timers started with rules via http.
Is it possible to ask via http the remaining time of each?
I have some long time (20 min or more) running timers started with rules via http.
Is it possible to ask via http the remaining time of each?
Re: timer remaining time
Not directly, but you could store the number of seconds of the current day in a variable when setting the timer.
Then you can subtract the stored value from the current value of %syssec_d% in an event handler block.
By triggering such an event you can output the difference (or store it somewhere like in a dummy)
Then you can subtract the stored value from the current value of %syssec_d% in an event handler block.
By triggering such an event you can output the difference (or store it somewhere like in a dummy)
Re: timer remaining time
Thanks for your answer. But its not clear for me:
I have in Rules (from the examples):
On startwatering do
gpio,12,1 //start watering (open valve)
timerSet,1,600 //timer 1 set for 10 minutes
Let,1,%syssec_d%
endon
1) %syssec_d% is not listed in https://www.letscontrolit.com/wiki/inde ... _Variables , is this usable ?
2) How can I ask via a http call the Variable ? I didnt find anything ...
I have in Rules (from the examples):
On startwatering do
gpio,12,1 //start watering (open valve)
timerSet,1,600 //timer 1 set for 10 minutes
Let,1,%syssec_d%
endon
1) %syssec_d% is not listed in https://www.letscontrolit.com/wiki/inde ... _Variables , is this usable ?
2) How can I ask via a http call the Variable ? I didnt find anything ...
Re: timer remaining time
See on the web interface the list of System Variables.
There all variables are shown and their current values. (at the moment the page is loaded)
It depends a bit on how you would like to retrieve the value.
For example if you want to send it to a logentry:
After calling: event,timerleft
But you can use the computed value in just about anything.
For example publish it to a MQTT broker, use it in an URL for a HTTP GET call, show it on a display, etc.
There all variables are shown and their current values. (at the moment the page is loaded)
It depends a bit on how you would like to retrieve the value.
For example if you want to send it to a logentry:
Code: Select all
on timerleft do
let,2,%syssec_d%-[int#1]
LogEntry,'Timer seconds left: [int#2]'
endon
Code: Select all
137038 : Info : HTTP: event,timerleft
137128 : Info : EVENT: timerleft
137165 : Info : ACT : let,2,32299-32249
137172 : Info : ACT : LogEntry,'Timer seconds left: 50'
137178 : Info : Timer seconds left: 50
For example publish it to a MQTT broker, use it in an URL for a HTTP GET call, show it on a display, etc.
Re: timer remaining time
Sorry, I don't underdstand.
I call from the Browser http://easy_ip/control?cmd=event,timerleft and the whole respond is OK. How I get the Var content ?
I call from the Browser http://easy_ip/control?cmd=event,timerleft and the whole respond is OK. How I get the Var content ?
Re: timer remaining time
That is not (yet) implemented, to query a variable via a HTTP GET command.
You can trigger an event to collect a value, which then can be used to send it somewhere, but for now it is not possible to return it to the originator.
It is however a nice idea, so I'm thinking of how to do this.
Problem is the events will be scheduled, so you can't give a reply immediately back to the sender of the event.
So I guess the only way to achieve this is to create a new command which supports some basic computation and returns the result of it immediately.
It really isn't as simple as it sounds as we have a very good reason to schedule the events and not execute them immediately.
This reason has to do with stack usage.
If you handle an event, you may use quite a bit of stack, so you must make sure it is always called from the same point or else handling the event from different sources may work fine when called from source A and no longer when called from source B.
When we allow for parsing values and compations, you essentially are executing a single line of a rule.
To summarize; I like the idea (a lot) but I'm not entirely sure yet how to implement it.
You can trigger an event to collect a value, which then can be used to send it somewhere, but for now it is not possible to return it to the originator.
It is however a nice idea, so I'm thinking of how to do this.
Problem is the events will be scheduled, so you can't give a reply immediately back to the sender of the event.
So I guess the only way to achieve this is to create a new command which supports some basic computation and returns the result of it immediately.
It really isn't as simple as it sounds as we have a very good reason to schedule the events and not execute them immediately.
This reason has to do with stack usage.
If you handle an event, you may use quite a bit of stack, so you must make sure it is always called from the same point or else handling the event from different sources may work fine when called from source A and no longer when called from source B.
When we allow for parsing values and compations, you essentially are executing a single line of a rule.
To summarize; I like the idea (a lot) but I'm not entirely sure yet how to implement it.
Re: timer remaining time
maybe its easier to implement the var-values in the json respond ?
Re: timer remaining time
That's a good suggestion.
We already have something similar for accessing specific plugin data, so if you store it in a dummy via rules, then you can already access it like that.
See: https://espeasy.readthedocs.io/en/lates ... ht=csv#csv
And to set the value in a Dummy task, see the command "taskvalueset"
We already have something similar for accessing specific plugin data, so if you store it in a dummy via rules, then you can already access it like that.
See: https://espeasy.readthedocs.io/en/lates ... ht=csv#csv
And to set the value in a Dummy task, see the command "taskvalueset"
Who is online
Users browsing this forum: No registered users and 135 guests