solved: Need help in publishing a Dummy value

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

solved: Need help in publishing a Dummy value

#1 Post by werner_g » 04 Sep 2019, 21:32

Folks, please help me! I want to find the average of three values and want to publish this value. What I am doing wrong?

Code: Select all

On Light#Lux Do
 Let,4,[VAR#3]
 Let,3,[VAR#2]
 Let,2,[VAR#1]
 Let,1,[Light#Lux]
 TaskValueSet,1,1,([VAR#1]+[VAR#2]+[VAR#3])/3
 Let,5,[Dummy#Value]
 publish,any/state/Umweltsensor/[Dummy#Value]
 if [Dummy#Value]>300 do
 publish,any/state/Umweltsensor/Beschattung,1
 else
 publish,any/state/Umweltsensor/Beschattung,0
 endif
EndOn
Many thanks!
Last edited by werner_g on 07 Sep 2019, 13:12, edited 1 time in total.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Need help in publishing a Dummy value

#2 Post by ThomasB » 05 Sep 2019, 05:31

What I am doing wrong?
You should explain what is not working. For example: Dummy assignments not working? Averaged value wrong? MQTT not working? Something else?
And include a screenshot of the devices page so the helper's eyes can see important details.

Given the posted info, it seems to me that:

Code: Select all

publish,any/state/Umweltsensor/[Dummy#Value]
is a topic that is missing the message payload. In other words, it should be more like this:

Code: Select all

publish,any/state/Umweltsensor,[Dummy#Value]
Overall, I recommend using ESPEasy's debug log to see if it provides insight to what is happening during rule execution.

Thomas

werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

Re: Need help in publishing a Dummy value

#3 Post by werner_g » 06 Sep 2019, 20:59

You are right. I just followed the 'working examples' out of https://espeasy.readthedocs.io/en/lates ... Rules.html. I changed the rule according to your suggestion, but still I get not the result of the average calculation to be published. No probs with calculation and MQTT. Screenshot of Device page is attatched. Thanks for any help.

Code: Select all

On Light#Lux Do
 Let,4,[VAR#3]
 Let,3,[VAR#2]
 Let,2,[VAR#1]
 Let,1,[Light#Lux]
 TaskValueSet,1,1,([VAR#1]+[VAR#2]+[VAR#3])/3
 Let,5,[Dummy#Value]
 publish,any/state/Umweltsensor,[Dummy#Value]
 if [Let,5]>300 do
 publish,any/state/Umweltsensor/Beschattung,1
 else
 publish,any/state/Umweltsensor/Beschattung,0
 endif
EndOn

Code: Select all

244812212: ACT : Let,3,3.00
244812219: Command: let
244812226: ACT : Let,2,1.00
244812234: Command: let
244812257: ACT : Let,1,0
244812265: Command: let
244812272: ACT : TaskValueSet,1,1,(0.00+1.00+3.00)/3
244812282: Command: taskvalueset
244812318: ACT : Let,5,
244812327: Command: let
244812361: ACT : publish,any/state/Umweltsensor,
244812369: Command: publish
244812382: ACT : publish,any/state/Umweltsensor/Beschattung,0
244812391: Command: publish
Attachments
Screenshot_2019-09-06 Umweltsensor.png
Screenshot_2019-09-06 Umweltsensor.png (67.93 KiB) Viewed 7106 times

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Need help in publishing a Dummy value

#4 Post by ThomasB » 06 Sep 2019, 21:34

Please post a screenshot of the Devices page.

Also, your publish address is suspicious. Is your MQTT broker configured with a subscription that begins with "any/state/"? That seems to be the text from a random MQTT example rather than for your installation.

- Thomas

werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

Re: Need help in publishing a Dummy value

#5 Post by werner_g » 06 Sep 2019, 22:15

just

Code: Select all

publish,any/state/Umweltsensor/Beschattung,0
is being published. "any/state/xxx" is my standard for MQTT-messages in my network.

werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

Re: Need help in publishing a Dummy value

#6 Post by werner_g » 06 Sep 2019, 22:35

forgot the screenshot
Attachments
Screenshot_2019-09-06 Umweltsensor(1).png
Screenshot_2019-09-06 Umweltsensor(1).png (119.5 KiB) Viewed 7092 times

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Need help in publishing a Dummy value

#7 Post by ThomasB » 07 Sep 2019, 00:12

publish,any/state/Umweltsensor/Beschattung,0 is being published. "any/state/xxx" is my standard for MQTT-messages in my network.
That is helpful information; Confirms MQTT is configured OK.
but still I get not the result of the average calculation to be published.
See your rule statement at this line:

Code: Select all

 publish,any/state/Umweltsensor,[Dummy#Value]
The [Dummy#Value] is suspect here. I expected to see the Generic Dummy plugin, or some device named Dummy in your device list, but none have that name. That seems to explain the missing MQTT.

See your rule statement at this line:

Code: Select all

TaskValueSet,1,1,([VAR#1]+[VAR#2]+[VAR#3])/3
This seems to be an attempt to write the Average result to the reboot var, which isn't allowed. Taskvalueset is for writing a value to a Dummy device, which requires the Generic Dummy Device plugin.

So here's what I suggest. Add the Dummy Device Plugin to task position #9 (which is currently empty/available). Name the device Dummy, with the Value #1 named Value.
Change the TaskValueSet code to:

Code: Select all

TaskValueSet,9,1,([VAR#1]+[VAR#2]+[VAR#3])/3
No other edits needed at this point. Try it, and if still not working then check the system log for debugging details.

- Thomas

werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

Re: Need help in publishing a Dummy value

#8 Post by werner_g » 07 Sep 2019, 13:10

Hi Thomas, I wasn't aware of the usage of a dummy device. Now I understand - now it works! And again I learnt a little bit more. Thanks for your help & patience!

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: solved: Need help in publishing a Dummy value

#9 Post by ThomasB » 07 Sep 2019, 18:09

You're welcome. Glad to know you solved the problem.

- Thomas

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests