Page 1 of 1

solved: Need help in publishing a Dummy value

Posted: 04 Sep 2019, 21:32
by werner_g
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!

Re: Need help in publishing a Dummy value

Posted: 05 Sep 2019, 05:31
by ThomasB
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

Re: Need help in publishing a Dummy value

Posted: 06 Sep 2019, 20:59
by werner_g
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

Re: Need help in publishing a Dummy value

Posted: 06 Sep 2019, 21:34
by ThomasB
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

Re: Need help in publishing a Dummy value

Posted: 06 Sep 2019, 22:15
by werner_g
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.

Re: Need help in publishing a Dummy value

Posted: 06 Sep 2019, 22:35
by werner_g
forgot the screenshot

Re: Need help in publishing a Dummy value

Posted: 07 Sep 2019, 00:12
by ThomasB
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

Re: Need help in publishing a Dummy value

Posted: 07 Sep 2019, 13:10
by werner_g
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!

Re: solved: Need help in publishing a Dummy value

Posted: 07 Sep 2019, 18:09
by ThomasB
You're welcome. Glad to know you solved the problem.

- Thomas