Get the timer value

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Get the timer value

#1 Post by Gilles » 04 Mar 2019, 15:05

I am using a sonoff/espeasy to power on a a lamp during 2 hours via a rule and a timer :

Code: Select all

On Relai#Relai do
 if [Relai#Relai]=1
    timerSet,1,7200 //timer 1 set for 2 heures
 else
    timerSet,1,0
 endif
 endon 
Is there a way to get the value of the timer to know how much time is left in the same way as I can get the status of a gpio using : http://x.x.x.x/control?cmd=status,gpio,12

I have read something about the dummy devices where I could store a second timer, but I have not really understood how does it work and how to get its value.

What should I do ?

version : Build: 20000 - Mega
GIT version: (custom)

Thanks

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

Re: Get the timer value

#2 Post by grovkillen » 04 Mar 2019, 18:15

Code: Select all


On Relai#Relai do
 if [Relai#Relai]=1
    timerSet,1,7200 //timer 1 set for 2 heures
    TimerSet,8,1
    Let,1,7200
 else
    timerSet,1,0
    TimerSet,8,0
 endif
 endon 
 
 On Rules#Timer=1 Do
  //Do your thing
  Let,1,0
  EndOn
  
  On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
   //You can push the value of variable 1 to either an event, a dummy value or whatever
   TimerSet,8,1
  EndOn

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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#3 Post by Gilles » 05 Mar 2019, 09:14

Thanks,
I will give it a try.

Is the "Let" command explained somewhere? I went through the wiki and have not found it.
Thanks
Gilles

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

Re: Get the timer value

#4 Post by grovkillen » 05 Mar 2019, 12:08

No I haven't had the time to document that yet.
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:

Patou
Normal user
Posts: 43
Joined: 21 May 2018, 10:33

Re: Get the timer value

#5 Post by Patou » 06 Mar 2019, 22:29

Pleas find enclosed a document explaining the let fucntion
Found on several forum discussions
Good reading
Patou

Esp Easy internal variables

There are 16 definable internal variables :
Let,<value number 1...16>,<float>

Example

Let,1,10
Let,2,20
Publish,Answer/%v1%+%v2%,(%v1%+%v2%)
or
Publish,Answer/[var#1]%+[var#2],([var#1]%+[var#2])

This would render in this being published
Topic
Answer/10+20
Message 30
New way :

On System#Boot Do
Let,1,123456789
EndOn

On esp004#tag Do
Let,2,[esp004#tag] //Setting dummy value 1 to the tag code
TimerSet,1,3
EndOn

On Rules#Timer=1 Do
If [esp004#tag] = %v2%
taskValueSet,1,1,%v1%
EndIf

Old way :
On System#Boot Do
taskValueSet,12,2,123456789
EndOn

On esp004#tag Do
taskValueSet,12,1,[esp004#tag] //Setting dummy value 1 to the tag code
TimerSet,1,3
EndOn

On Rules#Timer=1 Do
If [esp004#tag] = [Dummy#CurrentTag] //If the tag code is still the same after 3 seconds clear it
taskValueSet,1,1,[Dummy#ZeroTag]
EndIf
EndOn



Is it possible to create a feature so you can do some elementary basic signal processing on
• the sensor signals? searched the issue tracker or the forum for a similar issue. (include links when applicable) But i did not find any info on this

• There is a rather elaborate filter option which you can already use now.
You can store values in a variable when using rules. Something similar can also be done using the dummy plugin.
These values can then be used in a computation (in the rules).
For example new value = (3* last_value + new sample) / 4
And then store that new value in the variable to be used in the next run as "last_value".
• But I agree that some statistics module would be very useful.
On the other hand, if the values jump 4 degree between samples, then you can ask yourself how useful these are.
So maybe better to look into why these values are so unstable.
Ah, what you describe is what i meant, but didn't realize it was there. maybe close the request than.
But i'm very new to this, so not sure how to do that precisely. I found the rule tab now.
I copied the new value = (3* last_value + new sample) / 4 there but do not know how to put the And then store that new value in the variable to be used in the next run as "last_value". to work.....
Could you give an example, or a headsup where to look? (as i mentioned, really new here)

I will summon the rules guru by mentioning him ;)
@Grovkillen may be able to help here.
Or if it will end up in a discussion on how to do stuff instead of things that are buggy or need to change, then it may be best to move it to the forum.
This is what I would try first. I store the last 9 values and add the newest value to that making it 10 values all in all. The average of those ten is then added to a dummy variable (task 12 in this example) which is then later used as the publishing task.
On Temp#Value Do
Let,10,[VAR#9]
Let,9,[VAR#8]
Let,8,[VAR#7]
Let,7,[VAR#6]
Let,6,[VAR#5]
Let,5,[VAR#4]
Let,4,[VAR#3]
Let,3,[VAR#2]
Let,2,[VAR#1]
Let,1,[Temp#Value]
TaskValueSet,12,1,([VAR#1]+[VAR#2]+[VAR#3]+[VAR#4]+[VAR#5]+[VAR#6]+[VAR#7]+[VAR#8]+[VAR#9]+[VAR#10])/10
EndOn
Right at boot all the internal variables will be 0 making this rule not working great for the first ten loops.
PS. TaskValueSet could be accompanied by TaskRun in order to have the value being published in the same intervals as the actual sensor is set to (in this example named Temp#Value). I close this one now.
Why use 10 samples? If you only use the a weighted average of the last reported value (not measured) combined with the last measured value, you will achieve similar filtering but a lot easier to implement in rules.
Only drawback is that you will still have some residue left of old values when the measured values suddenly change a lot. Taking the average of a fixed amount of samples will have no "memory" after N samples.
So it depends on the use case which is better.
For example on a scale you want a fast response (using average filtering), but when keeping track of air pressure you don't want to see someone slamming the door.

On Temp#Value Do
Let,2,[VAR#1]*3
Let,1,[Temp#Value]
TaskValueSet,12,1,([VAR#1]+[VAR#2])/4
EndOn

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#6 Post by Gilles » 07 Mar 2019, 07:27

Thanks Patou,
I have also find a command reference which talks about the "let" statement : https://espeasy.readthedocs.io/en/lates ... mmand.html

I have spent some time yesterday based on grovkillen's solution to try to make it work, but not yet succeeded.
I don't understand how I can get the value of the time left to get it with a http command.
I am confused with the "dummy device" and the "dummy variable".I have found some complex posts, but nothing simple and clear to me.

I think that I need to create a rule "abcd", to run it ( http://xxx.xxx.x.x/control?cmd=event,abcd), It should trigger the calculation of the time left in the [VAR#1] variable. In // I create a dummy device with a variable to which I will assign the [VAR#1], something like that.
I don't understand the statement : Let,1,[VAR#1]-1 in:

Code: Select all

On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
   //You can push the value of variable 1 to either an event, a dummy value or whatever
   TimerSet,8,1
  EndOn
I have also created a dummy device (nb 2) with 4 variables.I think that I should see something with : http://x.x.x.x/json?tasknb=2:

Code: Select all

{"System":{
"Build": 20000,
"Unit": 0,
"Uptime": 4177,
"Free RAM": 21904
},
"Sensors":[
{
"TaskName": "Relai",
"Relai": 0.00
},
{
"TaskName": "countdown",
"%v1%": 0.00,
"[var#1]": 0.00,
"tt": 0.00,
"var#1": 0.00
}
]}
I will continue exploring the forum again this weekend.
As you can see, I am a little bit lost :)

Gilles

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

Re: Get the timer value

#7 Post by grovkillen » 07 Mar 2019, 10:35

I need to fully understand exactly what you want. Do you want the timer value (remaining time) to be used in a dummy variable/task/value (just call it "dummy" :) ) or do you just want to show it on a display or whatever?

To explain this part:

Code: Select all

On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
   //You can push the value of variable 1 to either an event, a dummy value or whatever
 TimerSet,8,1
EndOn
Let,1,[VAR#1]-1 means that you assign internal variable number 1 with its own value minus 1 (since it's now one second since last time we ran the timer number 8).
After we set the variable to this new value we reset the timer for another second.

Why we use square brackets? To process float and integers formulas in rules (digits/numbers) we need to specify it using those [..]. If we on the other hand want to use it elsewhere (like in plugin formulas etc.) we need to use percentage signs %..% instead. This is legacy coding, we know it's not super clear at first glance.

So if I understand you correctly you want to post the remaining time to your dummy device you have on task number 2, and since the dummy have 4 values to post to I pick the first one in this example:

Code: Select all

On Relai#State Do
 If [Relai#State]=1
    TimerSet,1,7200
    TimerSet,8,1
    Let,1,7200
  Else
    TimerSet,1,0
    TimerSet,8,0
    Let,1,0
  EndIf
 EndOn

On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
  TimerSet,8,1
EndOn
PS in this example I renamed your value name from Relai to State, I find it not logical to have the same task name as the value name. I understand you have a switch plugin which is monitoring the relay state. When this state changes you look and see if this new state is 1, if so you start a timer (7200 seconds). We then set a second timer (I picked timer number 8 for this, I always do that for those "keeping track of" timers) and set that to 1 second. Right after that we set the internal variable number 1 to the same amount of seconds as the count down timer (7200).

When the timer number 8 reaches zero it'll update the internal variable number 1 to a new value which is it's previous value ([VAR#1] which is 7200) and subtract 1 from that. This means that the value of [VAR#1] now is 7199. And after that we reset the timer number 8 to 1 second. After a second this repeats and the new value of [VAR#1] is 7198.

If the Relay#State changes during this time the rule will set the timer 1 and timer 8 to zero meaning that they are disabled, after that the also set the [VAR#1] to zero using the Let,1,0 command.

IF you want to post your value of [VAR#1] to the dummy on task number 2 and it's value number 1 you add this to the code:

Code: Select all

On Relai#State Do
 If [Relai#State]=1
    TimerSet,1,7200
    TimerSet,8,1
    Let,1,7200
    TaskValueSet,2,1,[VAR#1]
  Else
    TimerSet,1,0
    TimerSet,8,0
    Let,1,0
    TaskValueSet,2,1,[VAR#1]
  EndIf
 EndOn

On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
    TaskValueSet,2,1,[VAR#1]
  TimerSet,8,1
EndOn
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#8 Post by Gilles » 07 Mar 2019, 12:07

Thanks for the detailled info.

What I want : I use a sonoff with espeasy to switch on a light in the garden with a timer = 2 hours . I trigger this with a rule. And 2 hours later, when the timer equals 0 , I switch off the light with another rule. This works fine.

Now, I just would like to know if it is possible to get the time left (the value of the timer) with a http command like http://x.x.x.x/control?cmd=status,"time_left" or anything.

I don't use (yet) openhab, domotiz or any other domotic software.

I just would like to create a brower shortcut to query the timer value.

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

Re: Get the timer value

#9 Post by grovkillen » 07 Mar 2019, 14:12

You can get the time left using a dummy variable like you tried to but how do you want it presented? Do you log in to check this value or do you want it displayed some other way? Do you want it automatically?

You could simply create a html file with this code inside. Change ip number and change the sensor + task number to match your setup, and it'll fetch the values for you.

The "magic" happens here...

Code: Select all

<script>
let ip = 'XX.XX.XX.XX';

setInterval(function() {
let ud = 'id_' + +new Date;
let url = 'http://' + ip + '/json?callback=' + ud;
fetch(url)
    .then(res => res.json())
    .then((jsonData) => {
        console.log('Output: ', jsonData);
		document.getElementById("timerValue").innerHTML = jsonData.Sensors[0].TaskValues[0].Value + ' sec';
}).catch(err => console.error(err));
}, 1000);
</script>
Attachments
example.zip
(3.51 KiB) Downloaded 48 times
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#10 Post by Gilles » 07 Mar 2019, 17:05

wow, I am really impressed with what you can do with espeasy. Thanks for your great explanation.
Unfortunately, it doesn't work for me. the dummy device values remain empty.

Here is the device section:
dummy_device.PNG
dummy_device.PNG (14.22 KiB) Viewed 3119 times
here is the rule section (with relay#relay ,not yet changed):

Code: Select all

on toto do
 if [Relai#Relai]=1
 gpio,12,0
 else
 gpio,12,1
 endif
 endon 

On Relai#Relay Do
 If [Relai#Relay]=1
    TimerSet,1,7200
    TimerSet,8,1
    Let,1,7200
    TaskValueSet,2,1,[VAR#1]
  Else
    TimerSet,1,0
    TimerSet,8,0
    Let,1,0
    TaskValueSet,2,1,[VAR#1]
  EndIf
 EndOn
On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
    TaskValueSet,2,1,[VAR#1]
  TimerSet,8,1
EndOn
I trigger the rule with : http://192.168.1.6/control?cmd=event,toto
The light switches on and will switch off 2 hours later.
Let's say that I don't remember at what time I have run the command : http://192.168.1.6/control?cmd=event,toto
I would like to be able, on demand , to know how much time is left by typing something like : http://192.168.1.6/control?cmd=status,xxx ?? in the same way as I can get the gpio status with : http://192.168.1.6/control?cmd=status,gpio,12

I could also use something like : http://192.168.1.6/json?tasknb=2 and split the json to get the value I am interested in.

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

Re: Get the timer value

#11 Post by grovkillen » 07 Mar 2019, 17:14

Study your names and you'll see what's going on. (That's why I never use same names for tasks and their values).
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#12 Post by Gilles » 07 Mar 2019, 17:29

got it : relai(french) and relay(English)
The eye of the tiger :)

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#13 Post by Gilles » 08 Mar 2019, 10:24

Sorry but It doesn't work yet. the dummy device value remains 0.The four value names are : dummy, tv2, tv3, tv4)
Any idea ?

here is the rule: ( I trigger it with : http://192.168.1.6/control?cmd=event,toto )

Code: Select all

on toto do
 if [Relai#Relai]=1
 gpio,12,0
 else
 gpio,12,1
 endif
 endon //http://192.168.1.6/control?cmd=event,toto=30

On Relai#Relai Do
 If [Relai#Relai]=1
    TimerSet,1,7200
    TimerSet,8,1
    Let,1,7200
    TaskValueSet,2,1,[VAR#1]
  Else
    TimerSet,1,0
    TimerSet,8,0
    Let,1,0
    TaskValueSet,2,1,[VAR#1]
  EndIf
 EndOn

On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
    TaskValueSet,2,1,[VAR#1]
  TimerSet,8,1
EndOn
Here is the log: I am wondering if there is an issue with [VAR#1].
60180103 : EVENT: countdown#dummy=0.00
60181005 : EVENT: countdown#tv2=0.00
60181907 : EVENT: countdown#tv3=0.00
60182819 : EVENT: countdown#tv4=0.00
60183727 : EVENT: Clock#Time=Fri,10:16
60184632 : EVENT: Rules#Timer=8
60185330 : ACT : Let,1,-1
60185536 : ACT : TaskValueSet,2,1,
60185542 : ACT : TimerSet,8,1

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

Re: Get the timer value

#14 Post by grovkillen » 08 Mar 2019, 11:47

Setting the GPIO to something will never trigger the relay task.

GPIO is changing the value internally, only externally will invoke the event Relai#Relai (ps you should really not name them the same).

Try this to trigger an event:

Code: Select all

on toto do
 if [Relai#Relai]=1
 gpio,12,0
 else
 gpio,12,1
 endif
 Event,Relai#Relai
 endon

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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#15 Post by Gilles » 08 Mar 2019, 13:43

it doesn't work either.
I have renamed the status and rewritten the rule to make it simpler.

Code: Select all

On toto Do
 If [Relai#Status]=0
    gpio,12,1
    TimerSet,1,7200
    TimerSet,8,1
    Let,1,7200
    TaskValueSet,2,1,[VAR#1]
  Else
    gpio,12,0
    TimerSet,1,0
    TimerSet,8,0
    Let,1,0
    TaskValueSet,2,1,[VAR#1]
  EndIf
 EndOn

On Rules#Timer=8 Do
   Let,1,[VAR#1]-1
    TaskValueSet,2,1,[VAR#1]
  TimerSet,8,1
EndOn
The logs says :

Code: Select all

72281227 : ACT : TaskValueSet,2,1,
72281233 : ACT : TimerSet,8,1
72285192 : EVENT: Rules#Timer=8
72285853 : ACT : Let,1,-1
72286061 : ACT : TaskValueSet,2,1,
72286068 : ACT : TimerSet,8,1
72287194 : EVENT: Rules#Timer=8
72287860 : ACT : Let,1,-1
72288064 : ACT : TaskValueSet,2,1,
72288071 : ACT : TimerSet,8,1
The device section shows:
dummy_device.PNG
dummy_device.PNG (22.58 KiB) Viewed 3072 times
When i trigger the rule, then Relay device value becomes = 1 , the light is switched on.
There should be something wrong, that I don't see...
What do you think about the value of [VAR#1] not shown in the log. Is it normal?

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#16 Post by Gilles » 08 Mar 2019, 13:49

I have just added a line in the rule to assign the value 300 to the variable number 2 (tv2) and I can see it in the device section.
On toto Do
If [Relai#Status]=0
gpio,12,1
TimerSet,1,7200
TimerSet,8,1
Let,1,7200
TaskValueSet,2,1,[VAR#1]
TaskValueSet,2,2,300
Else
gpio,12,0
TimerSet,1,0
TimerSet,8,0
Let,1,0
TaskValueSet,2,1,[VAR#1]
EndIf
EndOn

On Rules#Timer=8 Do
Let,1,[VAR#1]-1
TaskValueSet,2,1,[VAR#1]
TimerSet,8,1
EndOn
dummy_device2.PNG
dummy_device2.PNG (21.46 KiB) Viewed 3071 times

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

Re: Get the timer value

#17 Post by grovkillen » 08 Mar 2019, 13:56

Sounds like a bug!
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#18 Post by Gilles » 08 Mar 2019, 13:59

I may need to upgrade to a more recent version.
I may do it this weekend. I will add a post when done.
Thanks for your help and time.
Much appreciated
Gilles

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#19 Post by Gilles » 08 Mar 2019, 14:27

BTW,
what would be the http command to get the value of tv2 (second value of the second device)
Is it : http://192.168.1.6/json
or is there a query which return directly the value of tv2
ex something like : http://192.168.1.6/control?cmd=status,countdown,2,2

Thanks

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

Re: Get the timer value

#20 Post by grovkillen » 08 Mar 2019, 14:41

You want the value in in what system? Everything is possible to do, but how you do it are different depending on your case.
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#21 Post by Gilles » 08 Mar 2019, 14:51

I was thinking to something(url) that I could type in a browser on my smartphone or laptop. I already have a shortcut to trigger the rule (http://192.168.1.6/control?cmd=event,toto).
Another browser shortcut to have the timer value displayed should be great :)

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

Re: Get the timer value

#22 Post by grovkillen » 08 Mar 2019, 14:58

Download the zip I attached in the message some lines above... There you have the JavaScript to do it inside a browser.
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#23 Post by Gilles » 08 Mar 2019, 15:22

I had tested it , but i only get a blue background.
I have edited the example.html file changed the blue lines.
<script>
let ip = '192.168.1.6';

setInterval(function() {
let ud = 'id_' + +new Date;
let url = 'http://' + ip + '/json?callback=' + ud;
fetch(url)
.then(res => res.json())
.then((jsonData) => {
console.log('Output: ', jsonData);
document.getElementById("timerValue").innerHTML = jsonData.Sensors[2].TaskValues[2].Value + ' sec';

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

Re: Get the timer value

#24 Post by grovkillen » 08 Mar 2019, 15:35

Change those 2 to 1... In programming we start counting at zero.
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#25 Post by Gilles » 08 Mar 2019, 15:43

It doesn't work for me with Chrome.
The inspect console shows some errors
dummy_device3.PNG
dummy_device3.PNG (86.38 KiB) Viewed 3049 times
Really sorry,
Gilles

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

Re: Get the timer value

#26 Post by grovkillen » 08 Mar 2019, 16:18

If the task is on the first value then it should be:

jsonData.Sensors[1].TaskValues[0].Value + ' sec';

And people, please experiment...
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:

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#27 Post by Gilles » 08 Mar 2019, 16:36

you are right, In my case, it is the second sensor and the second value so it should be jsonData.Sensors[1].TaskValues[1].Value + ' sec'; I have even tried several combinations.
Maybe there is something wrong with the espeay version that I run.

Don't worry, I will write a python script to get the json and extract the value of the sensor.

Gilles
Normal user
Posts: 62
Joined: 21 Dec 2017, 11:09

Re: Get the timer value

#28 Post by Gilles » 09 Mar 2019, 08:44

I have upgraded the sonoff esp to: ESPEasy_mega-20190225
Everything works as it has to.
I can get the dummy variable
dummy_device.PNG
dummy_device.PNG (26.38 KiB) Viewed 2997 times
and your java script is fantastic:)
dummy_device2.PNG
dummy_device2.PNG (5.64 KiB) Viewed 2997 times
NB: the json display shows a lot of detailed info with this espeasy version.

Thanks a lot
Gilles

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

Re: Get the timer value

#29 Post by grovkillen » 09 Mar 2019, 09:25

Thanks for getting back with the feedback! :D
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:

manjh
Normal user
Posts: 441
Joined: 08 Feb 2016, 11:22

Re: Get the timer value

#30 Post by manjh » 22 Jun 2019, 12:24

If I understand correctly, in the examples you use a variable to run in parallel to a timer. This value in the variable can then be used.
But there must be a way to directly copy the remaining value of the timer into a variable?
I tried, but no success... am I missing something?

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

Re: Get the timer value

#31 Post by grovkillen » 22 Jun 2019, 20:09

Currently there's no way of getting the value directly.
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:

manjh
Normal user
Posts: 441
Joined: 08 Feb 2016, 11:22

Re: Get the timer value

#32 Post by manjh » 22 Jun 2019, 22:56

grovkillen wrote:
22 Jun 2019, 20:09
Currently there's no way of getting the value directly.
Jimmy, sounds like an item on the development list. Being a professional IT person, the solution with a var running in parallel with the timer seems like a less beautiful workaround..
😣

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

Re: Get the timer value

#33 Post by grovkillen » 22 Jun 2019, 22:57

Yep, agree. Will you open a feature request on GitHub?
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:

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests