Dummy Device - help

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Dummy Device - help

#1 Post by jenicek » 19 Nov 2022, 11:55

Hi. I don't know how to work with Dummy Device, I tried different rules but I'm making some mistake.
I need to combine data from several sensors and send them via Dummy Device at a set interval.

For example: Dummy Device-Task 5 takes over data from BME280-Task 1 (screen is attached).

Or combine some data from several sensors (Task 2,3,4 but only winddir, winspeed, rainfall)
I've tried e.g. this, but it doesn't load any values.
How to work with time? e.g. load every 20 sec, ideally according to the physical sensor settings?

Code: Select all

On Clock#Time do // this event comes in every minute 
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[bme280#vlhkost]
  TaskValueSet 5,3,[bme280#tlak]
endon
Log

Code: Select all

3601152: Dummy: value 1: 0.00
3601153: Dummy: value 2: 0.00
3601155: Dummy: value 3: 0.00
3601165: EVENT: test#teplota=0.00
3601174: EVENT: test#vlhkost=0.00
3601184: EVENT: test#tlak=0.00
Thanks.
Jan
Attachments
Snímek obrazovky pořízený 2022-11-19 11-09-14.png
Snímek obrazovky pořízený 2022-11-19 11-09-14.png (139.88 KiB) Viewed 2138 times

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#2 Post by Ath » 19 Nov 2022, 13:00

The issue is in your rule:

Code: Select all

On Clock#Time=All,**:** do // this event comes in every minute 
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[bme280#vlhkost]
  TaskValueSet 5,3,[bme280#tlak]
endon
It was triggered maybe once a day, at 00:00, but maybe even not then (the 'All' doesn't have a default value).
Now it is triggered every minute.

A more useful way to gather the real data is to configure each device with a sensible Interval setting, and use the events to set the value to the Dummy task

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
endon
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#3 Post by Ath » 19 Nov 2022, 13:02

And I see that you already have the BME280 configured to send data via a controller, why would you want to do that again via a dummy device?
/Ton (PayPal.me)

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

Re: Dummy Device - help

#4 Post by TD-er » 19 Nov 2022, 13:03

To run something periodically, you can use a looptimer.
See the looptimerset command: https://espeasy.readthedocs.io/en/lates ... oop-timers

Some examples on system time: https://espeasy.readthedocs.io/en/lates ... clock#time

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#5 Post by jenicek » 19 Nov 2022, 15:54

Thanks, this works:

Code: Select all

On Clock#Time=All,**:** do // this event comes in every minute 
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[winddir#winddir]
  TaskValueSet 5,3,[windspeed#windspeed]
endon
Why do I want to send data via Dummy? Dummy can send 4 values ​​from different sensors and I don't always want all values ​​from one sensor. E.g. Thingspeak knows 8 values ​​and 2 messages will be enough for me (limited number of messages for free Thingspeak). Or is there a better solution?
This always fills in all 3 values ​​for me:

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
endon
How to do this?

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
  on winddir do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
  on windspeed do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
  endon

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#6 Post by Ath » 19 Nov 2022, 16:15

jenicek wrote: 19 Nov 2022, 15:54 This always fills in all 3 values ​​for me:

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
endon
The BME280 sends 3 events every Interval seconds, 1 for each value, so this rule will be called once for each value, and use the valuename (%eventpar%) to set the corresponding Dummy variable.
You can have a look at the log output for what actually happens, that will make things more visible.
jenicek wrote: 19 Nov 2022, 15:54 How to do this?

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
  on winddir do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
  on windspeed do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
  endon
This will set each value 3x every time it's run, that's not needed at all, reading my response above should explain why, if it's not clear why that works (as intended), just ask for more details, I'm happy to explain that.
/Ton (PayPal.me)

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#7 Post by jenicek » 19 Nov 2022, 16:23

Thank you. I'll try it as soon as I can. Another question - do I have to restart ESP after each rule change, or is it possible to restart only "some service"?

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#8 Post by Ath » 19 Nov 2022, 16:44

The changed rules will be used immediately after being saved.
Only if you change some settings in an event handler that will only be executed after booting, like "on system#boot do" you either reboot the ESP, or manually trigger the event by sending the command "event,<eventname>", so f.e.: "event,system#boot", and it will be executed immediately. (That's on the Tools page, but I expect you already found that ;))
/Ton (PayPal.me)

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

Re: Dummy Device - help

#9 Post by TD-er » 19 Nov 2022, 17:21

Each task also has a checkbox to send all values in a single event.
This will create an event with the taskname#All
The event values can be accessed via %eventvalue1% ... %eventvalue4% (or as many task values the task will have)

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#10 Post by jenicek » 19 Nov 2022, 17:50

I'm not doing well. I want to combine values from different sensors. Something works when I change the order of values - red, something shows zero - blue.
I didn't change the rule:

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
endon
//On Clock#Time=All,**:** do // this event comes in every minute 
//  TaskValueSet 5,1,[bme280#teplota]
 // TaskValueSet 5,2,[winddir#winddir]
 // TaskValueSet 5,3,[windspeed#windspeed]
//endon

log:

1151770: EVENT: rainfall#rainfall=5.00
1151779: EVENT: rainfall#Total=0.00
1151784: EVENT: rainfall#Time=0.00
1153065: WD : Uptime 19 ConnectFailures 0 FreeMem 14104 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
1155047: Dummy: value 1: -1.95
1155049: Dummy: value 2: 118.00
1155050: Dummy: value 3: 10.00
1155052: Dummy: value 4: 0.00
1155067: EVENT: test#Teplota=-1.95
1155072: EVENT: test#windspeed=118.00
1155084: EVENT: test#winddir=10.00
1155090: EVENT: test#rainfall=0.00
1161681: ADC : Analog value: 688 = 113.00
1161692: EVENT: winddir#winddir=118.00
Attachments
2022-11-19-173245_1920x1080_scrot.png
2022-11-19-173245_1920x1080_scrot.png (226.19 KiB) Viewed 2095 times

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#11 Post by Ath » 19 Nov 2022, 18:01

The windspeed and rainfall tasks use a pulse-counter on the same GPIO pin, that doesn't seem right to me.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#12 Post by Ath » 19 Nov 2022, 18:05

And for the windspeed and rainfall sensors you could also add similar eventhandlers like for the BME280:

Code: Select all

on windspeed do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on rainfall do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
As you commented out the Clock#Time code, the other values are no longer updated...
/Ton (PayPal.me)

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#13 Post by jenicek » 19 Nov 2022, 18:08

Fixed, it wasn't correct, but that's not the problem. Nothing is connected there yet except the internal resistance and the values are fixed ...(%value%+5) for testing purposes. It is about the individual values - the order and why rainfall shows 0.

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#14 Post by jenicek » 19 Nov 2022, 18:13

Thanks, I replied too soon.

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#15 Post by jenicek » 19 Nov 2022, 18:27

I don't know if I understood correctly, it still doesn't work.

Code: Select all

111530: ADC : Analog value: 688 = 113.00
111542: EVENT: winddir#winddir=118.00
111581: EVENT: windspeed#All=10.00,0.00,0.00
111622: EVENT: rainfall#rainfall=5.00
111633: EVENT: rainfall#Total=0.00
111642: EVENT: rainfall#Time=0.00
111651: Dummy: value 1: -1.95
111653: Dummy: value 2: 118.00
111654: Dummy: value 3: 10.00
111656: Dummy: value 4: 0.00
111671: EVENT: test#Teplota=-1.95
111679: EVENT: test#windspeed=118.00
111690: EVENT: test#winddir=10.00
111697: EVENT: test#rainfall=0.00
120339: HTTP : C004 api.thingspeak.com POST... HTTP code: 200
120348: EVENT: http#api.thingspeak.com=200
121530: ADC : Analog value: 688 = 113.00
121541: EVENT: winddir#winddir=118.00
121584: EVENT: windspeed#All=10.00,0.00,0.00
121624: EVENT: rainfall#rainfall=5.00
121631: EVENT: rainfall#Total=0.00
121642: EVENT: rainfall#Time=0.00
121650: Dummy: value 1: -1.95
121652: Dummy: value 2: 118.00
121654: Dummy: value 3: 10.00
121655: Dummy: value 4: 0.00
121670: EVENT: test#Teplota=-1.95
121684: EVENT: test#windspeed=118.00
121692: EVENT: test#winddir=10.00
121699: EVENT: test#rainfall=0.00
131530: ADC : Analog value: 688 = 113.00
131541: EVENT: winddir#winddir=118.00
131584: EVENT: windspeed#All=10.00,0.00,0.00
131627: EVENT: rainfall#rainfall=5.00
131637: EVENT: rainfall#Total=0.00
131642: EVENT: rainfall#Time=0.00
131650: Dummy: value 1: -1.95
131652: Dummy: value 2: 118.00
131653: Dummy: value 3: 10.00
131655: Dummy: value 4: 0.00
131670: EVENT: test#Teplota=-1.95
131684: EVENT: test#windspeed=118.00
131691: EVENT: test#winddir=10.00
131698: EVENT: test#rainfall=0.00
My rules set 1

Code: Select all

on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
  TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
endon
on windspeed do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on winddir do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on rainfall do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon

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

Re: Dummy Device - help

#16 Post by TD-er » 19 Nov 2022, 18:52

Code: Select all

on windspeed do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on winddir do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on rainfall do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
Not sure why you're using %eventpar% here?
An event is something like this:

Code: Select all

BME280#Teplota=-1.73
"%eventpar%" is then replaces by "Teplota" when processed
Thus "TaskValueSet test,%eventpar%,%eventvalue1%" is then replaces by this:

Code: Select all

  TaskValueSet test,Teplota,-1.73
However, if the "test" task doesn't have a taskvalue named "Teplota" it will not work.
See also the description of the parameters of the TaskValueSet command in the docs: https://espeasy.readthedocs.io/en/lates ... g-examples

test#Teplota does seem to exist in your screenshots, but some of the others don't.

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#17 Post by jenicek » 19 Nov 2022, 19:23

I am convinced that the "Teplota" role is there. I'm doing something completely wrong.
Attachments
2022-11-19-191555_1920x1080_scrot.png
2022-11-19-191555_1920x1080_scrot.png (145.19 KiB) Viewed 2074 times
2022-11-19-190929_1920x1080_scrot.png
2022-11-19-190929_1920x1080_scrot.png (122.11 KiB) Viewed 2074 times

User avatar
Ath
Normal user
Posts: 3419
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Dummy Device - help

#18 Post by Ath » 19 Nov 2022, 19:49

TD-er wrote: 19 Nov 2022, 18:52 Not sure why you're using %eventpar% here?
...
However, if the "test" task doesn't have a taskvalue named "Teplota" it will not work.
That was my suggestion, as back then all 3 taskvalues of the BME280 where also in the 'test' Dummy device. Later on that has been changed, but now value names of the other tasks are used, so only the ones matching the values in the test task are updated: Just what the doctor ordered :D
jenicek wrote: 19 Nov 2022, 18:27

Code: Select all

111581: EVENT: windspeed#All=10.00,0.00,0.00
You've enabled the Single event option on the windspeed task, then the rule won't work as expected, once that's unchecked, all 4 values in the 'test' Dummy device will be set as intended ;)
/Ton (PayPal.me)

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#19 Post by jenicek » 19 Nov 2022, 20:39

I canceled the possibility of one event. The values are not updated anyway. Am I using the rule correctly? Does it start as it should (or not, or not start at all)?
That's exactly what the rule says, and I have the commented lines there for possible use and understanding...

Code: Select all

//On Clock#Time=All,**:** do // this event comes in every minute 
//  TaskValueSet 5,1,[bme280#teplota]
 // TaskValueSet 5,2,[winddir#winddir]
 // TaskValueSet 5,3,[windspeed#windspeed]
//endon
on bme280 do // This requires the Dummy task to use the same value names as the sensor value name
 TaskValueSet test,%eventpar%,%eventvalue1% // Use the task name, and set the currently provided value
endon
on windspeed do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on winddir do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon
on rainfall do
  TaskValueSet test,%eventpar%,%eventvalue1%
endon




//On Clock#Time=All,**:** do // this event comes in every minute 
//  TaskValueSet 5,1,[bme280#teplota]
 // TaskValueSet 5,2,[winddir#winddir]
 // TaskValueSet 5,3,[windspeed#windspeed]
//endon

Code: Select all

1320709: EVENT: rainfall#rainfall=5.00
1320714: EVENT: rainfall#Total=0.00
1320721: EVENT: rainfall#Time=0.00
1322944: ADC : Analog value: 688 = 113.00
1322954: EVENT: winddir#winddir=118.00
1323372: HTTP : C004 api.thingspeak.com POST... HTTP code: 200
1323380: EVENT: http#api.thingspeak.com=200
1325489: EVENT: windspeed#windspeed=10.00
1325497: EVENT: windspeed#=0.00
1325503: EVENT: windspeed#=0.00
1330710: EVENT: rainfall#rainfall=5.00
1330721: EVENT: rainfall#Total=0.00
1330726: EVENT: rainfall#Time=0.00
1332944: ADC : Analog value: 688 = 113.00
1332954: EVENT: winddir#winddir=118.00
1333010: WD : Uptime 22 ConnectFailures 0 FreeMem 12672 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
1335489: EVENT: windspeed#windspeed=10.00
1335499: EVENT: windspeed#=0.00
1335506: EVENT: windspeed#=0.00
1336225: Dummy: value 1: -1.95
1336226: Dummy: value 2: 118.00
1336228: Dummy: value 3: 10.00
1336229: Dummy: value 4: 0.00
1336244: EVENT: test#Teplota=-1.95
1336254: EVENT: test#windspeed=118.00
1336258: EVENT: test#winddir=10.00
1336264: EVENT: test#rainfall=0.00
1340711: EVENT: rainfall#rainfall=5.00
1340720: EVENT: rainfall#Total=0.00
1340726: EVENT: rainfall#Time=0.00
1342943: ADC : Analog value: 688 = 113.00
1342954: EVENT: winddir#winddir=118.00
1345489: EVENT: windspeed#windspeed=10.00
1345501: EVENT: windspeed#=0.00
1345508: EVENT: windspeed#=0.00
1350710: EVENT: rainfall#rainfall=5.00
1350720: EVENT: rainfall#Total=0.00
1350727: EVENT: rainfall#Time=0.00
1352944: ADC : Analog value: 688 = 113.00
1352953: EVENT: winddir#winddir=118.00
1355489: EVENT: windspeed#windspeed=10.00
1355499: EVENT: windspeed#=0.00
1355508: EVENT: windspeed#=0.00
1360710: EVENT: rainfall#rainfall=5.00
1360716: EVENT: rainfall#Total=0.00
1360727: EVENT: rainfall#Time=0.00
1362943: ADC : Analog value: 688 = 113.00
1362954: EVENT: winddir#winddir=118.00
1363010: WD : Uptime 23 ConnectFailures 0 FreeMem 12768 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
1364686: EVENT: Clock#Time=Sat,19:34
1365494: EVENT: windspeed#windspeed=10.00
1365504: EVENT: windspeed#=0.00
1365510: EVENT: windspeed#=0.00
1366223: Dummy: value 1: -1.95
1366224: Dummy: value 2: 118.00
1366226: Dummy: value 3: 10.00
1366228: Dummy: value 4: 0.00
1366242: EVENT: test#Teplota=-1.95
1366249: EVENT: test#windspeed=118.00
1366259: EVENT: test#winddir=10.00
1366267: EVENT: test#rainfall=0.00
1370711: EVENT: rainfall#rainfall=5.00
1370721: EVENT: rainfall#Total=0.00
1370726: EVENT: rainfall#Time=0.00
1372943: ADC : Analog value: 688 = 113.00
1372956: EVENT: winddir#winddir=118.00
1375489: EVENT: windspeed#windspeed=10.00
1375501: EVENT: windspeed#=0.00
1375510: EVENT: windspeed#=0.00
1380710: EVENT: rainfall#rainfall=5.00
1380717: EVENT: rainfall#Total=0.00
1380728: EVENT: rainfall#Time=0.00
1382943: ADC : Analog value: 688 = 113.00
1382954: EVENT: winddir#winddir=118.00
1385489: EVENT: windspeed#windspeed=10.00
1385499: EVENT: windspeed#=0.00
1385505: EVENT: windspeed#=0.00
1390710: EVENT: rainfall#rainfall=5.00
1390718: EVENT: rainfall#Total=0.00
1390725: EVENT: rainfall#Time=0.00
1392943: ADC : Analog value: 688 = 113.00
1392954: EVENT: winddir#winddir=118.00
1393012: WD : Uptime 23 ConnectFailures 0 FreeMem 12768 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
1395489: EVENT: windspeed#windspeed=10.00
1395502: EVENT: windspeed#=0.00
1395509: EVENT: windspeed#=0.00
1396222: Dummy: value 1: -1.95
1396224: Dummy: value 2: 118.00
1396225: Dummy: value 3: 10.00
1396227: Dummy: value 4: 0.00
1396243: EVENT: test#Teplota=-1.95
1396253: EVENT: test#windspeed=118.00
1396264: EVENT: test#winddir=10.00
1396318: EVENT: test#rainfall=0.00
1400710: EVENT: rainfall#rainfall=5.00
1400715: EVENT: rainfall#Total=0.00
1400722: EVENT: rainfall#Time=0.00
1402944: ADC : Analog value: 688 = 113.00
1402954: EVENT: winddir#winddir=118.00
1405490: EVENT: windspeed#windspeed=10.00
1405501: EVENT: windspeed#=0.00
1405510: EVENT: windspeed#=0.00
1410712: EVENT: rainfall#rainfall=5.00
1410718: EVENT: rainfall#Total=0.00
1410729: EVENT: rainfall#Time=0.00
1412944: ADC : Analog value: 688 = 113.00
1412953: EVENT: winddir#winddir=118.00
1415488: EVENT: windspeed#windspeed=10.00
1415499: EVENT: windspeed#=0.00
1415508: EVENT: windspeed#=0.00
1420709: EVENT: rainfall#rainfall=5.00
1420714: EVENT: rainfall#Total=0.00
1420721: EVENT: rainfall#Time=0.00
1422944: ADC : Analog value: 688 = 113.00
1422952: EVENT: winddir#winddir=118.00
1423010: WD : Uptime 24 ConnectFailures 0 FreeMem 12720 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
1424686: EVENT: Clock#Time=Sat,19:35
1425489: EVENT: windspeed#windspeed=10.00
1425499: EVENT: windspeed#=0.00
1425509: EVENT: windspeed#=0.00
1426223: Dummy: value 1: -1.95
1426224: Dummy: value 2: 118.00
1426226: Dummy: value 3: 10.00
1426227: Dummy: value 4: 0.00
1426242: EVENT: test#Teplota=-1.95
1426252: EVENT: test#windspeed=118.00
1426259: EVENT: test#winddir=10.00
1426268: EVENT: test#rainfall=0.00
1430712: EVENT: rainfall#rainfall=5.00
1430719: EVENT: rainfall#Total=0.00
1430729: EVENT: rainfall#Time=0.00
1432943: ADC : Analog value: 688 = 113.00
1432954: EVENT: winddir#winddir=118.00
1435493: EVENT: windspeed#windspeed=10.00
1435503: EVENT: windspeed#=0.00
1435509: EVENT: windspeed#=0.00
Autoscroll:


Powered by Let's Control It community

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

Re: Dummy Device - help

#20 Post by TD-er » 19 Nov 2022, 21:38

OK, I think we're approaching this the wrong way...
What we now do is you post something, we react on some part of what we think is wrong, you try to use this answer to something else, repeat...

Let's first make clear what you want to achieve...
What I think you plan to do:
- On new sample values, copy them to a dummy task
- At specific time interval, send from the dummy task to some controller

But the same can be achieved by "collecting" all values instead of acting on an event.

Using elegant tricks are nice to have, like with the %eventpar%, but it doesn't help understanding what steps are needed.
So let's start with the basics, which are easy to understand.
Later we can make it more elegant.

You did start with the most basic approach (which is fine to begin with)

Code: Select all

On Clock#Time=All,**:** do // this event comes in every minute 
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[winddir#winddir]
  TaskValueSet 5,3,[windspeed#windspeed]
endon
But this one is occuring a bit too often, so better start using a (loop)timer: (Documentation)

Code: Select all

On System#Boot do    //When the ESP boots, do
  looptimerset,1,1200 // Start loop timer 1, 1200 sec (=20 mins) interval
endon

On Rules#Timer=1 do
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[winddir#winddir]
  TaskValueSet 5,3,[windspeed#windspeed]
endon

This does start a loop timer (= a timer which restarts itself) with interval of 1200 sec (= 20 mins).
We use timer 1 for this.

You can see the task values of the dummy task at task index #5 being filled.
For testing, you may want to reduce the looptimer interval to something like 60 sec.
N.B. you can simply give the looptimer command from the tools page in the command box.

Code: Select all

looptimerset,1,60
The dummy task values are being filled with the latest sample data from the referred sensors.
However it is not being "sent" to the connected controller(s).
For this we need to "run" the dummy task to "flush" the data to the connected controller(s).

Code: Select all

On System#Boot do    //When the ESP boots, do
  looptimerset,1,1200 // Start loop timer 1, 1200 sec (=20 mins) interval
endon

On Rules#Timer=1 do
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[winddir#winddir]
  TaskValueSet 5,3,[windspeed#windspeed]
  TaskRun,5  // Flush the data to the connected controller(s)
endon
Let me know if this part is clear before we continue.

jenicek
Normal user
Posts: 10
Joined: 19 Nov 2022, 11:13

Re: Dummy Device - help

#21 Post by jenicek » 20 Nov 2022, 09:47

Great, it works and I hope I understand. The task works without
The dummy task values are being filled with the latest sample data from the referred sensors.
However it is not being "sent" to the connected controller(s).
For this we need to "run" the dummy task to "flush" the data to the connected controller(s).

Code: Select all

On System#Boot do    //When the ESP boots, do
  looptimerset,1,20 // Start loop timer 1, 1200 sec (=20 mins) interval
endon

On Rules#Timer=1 do
  TaskValueSet 5,1,[bme280#teplota]
  TaskValueSet 5,2,[winddir#winddir]
  TaskValueSet 5,3,[windspeed#windspeed]*5
  TaskValueSet 5,4,[rainfall#rainfall]
  //TaskRun,5  // Flush the data to the connected controller(s)
endon
I test through the mqtt controller (to which it sends a dummy test) to node-red and everything seems to work. Is it ok to perform mathematical operations, for example:

Code: Select all

TaskValueSet 5,3,[windspeed#windspeed]*5
Tried, it works, but is it ok? And thank you very much for your help - it is excellent

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

Re: Dummy Device - help

#22 Post by TD-er » 20 Nov 2022, 10:01

And it appears there is a bug (just got reported) when using taskvalueset using a taskname/taskvaluename.
See: https://github.com/letscontrolit/ESPEas ... 1321073464
So that may explain why it wasn't working on your first attempts when using tasknames.

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

Re: Dummy Device - help

#23 Post by TD-er » 20 Nov 2022, 10:07

About the mathematical expressions.
Not all possible use cases to use them may be parsed correctly.
For example when comparing in an if statement, you have to store the result first in a variable.

Code: Select all

let,1,[foo#bar]*5 // store the result in [var#1]
if [var#1]>10
 ...
endif
Documentation about variables: https://espeasy.readthedocs.io/en/lates ... -variables
See the documentation on math functions: https://espeasy.readthedocs.io/en/lates ... -functions
N.B. you can also refer to the same variable as int. [int#1] is the same variable as [var#1]

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests