arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.3k stars 4.82k forks source link

SML / counter scripting: Bug when excess # is present - plus remedy #21012

Closed hagenbuch closed 8 months ago

hagenbuch commented 8 months ago

PROBLEM DESCRIPTION

I am using Tasmota 13.2. on a device connected to an electricity counter via infrared communication. For documentation, I am using "Hichis" hardware and his precompiled binaries from

https://www.youtube.com/watch?v=RbyXqJiBC8Q

When I had version 11.1, this script ran flawlessly:

>D
lief=0
bez=0
zz=""
#
>B
=>sensor53 r
tper=60
>T
bez=WUA#bezug
lief=WUA#liefer
zz=WUA#zaehlerid
>S
if upsecs%tper==0
then
print zz: %zz% lief:: %lief% bez: %bez% atime: %tstamp% up: %uptime%

=> WebSend [example.com] /?id=myid&atime=%tstamp%&uptime=%uptime%&bezug=%bez%&lieferung=%lief%
endif
>M 1
+1,3,s,0,9600,WUA
1,77070100600100ff@#,Zählernummer,,zaehlerid,0
1,77070100010800ff@1,Bezug,Wh,bezug,0
1,77070100020800ff@1,Lieferung,Wh,liefer,0
#

Watch out for the "#" in the >D section! A time ago it took me several days to find out that at that moment in time, the # had been necessary, just as the last # is today!

However, when updating to 13.2. , the update went great but there was no more script functionality, the console showed weird input commands like "bRY" that naturally could not be understood by Tasmota.

Also, the command "sensor53" was not understood anymore!

Solution:

As soon as I deleted the first # in the >D section, everything works again.

It would be great if we could add either an error message (# not understood or the like) or make the software more resilient to those syntax problems.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

11:10:32.063 CMD: Backlog Template; Module; GPIO 255 11:10:32.081 RSL: RESULT = {"NAME":"WuA Main","GPIO":[1,1,1,1,1,1,1,1,1,1,1,1,1,1],"FLAG":0,"BASE":18} 11:10:32.282 RSL: RESULT = {"Module":{"1":"Sonoff Basic"}} 11:10:32.488 RSL: RESULT = {"GPIO0":{"32":"Button1"},"GPIO1":{"0":"None"},"GPIO2":{"0":"None"},"GPIO3":{"0":"None"},"GPIO4":{"0":"None"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"224":"Relay1"},"GPIO13":{"320":"Led_i1"},"GPIO14":{"0":"None"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}

- [x] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua

11:11:48.452 CMD: Backlog Rule1; Rule2; Rule3;
11:11:48.474 RSL: RESULT = {"Command":"Unknown"}
11:11:48.713 RSL: RESULT = {"Command":"Unknown"}
11:11:48.962 RSL: RESULT = {"Command":"Unknown"}
- [ ] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:

TO REPRODUCE

Include an additional # to the end of the >D section is a script.

EXPECTED BEHAVIOUR

Either Tasmota should ignore the now obsolete # or it should complain in an error message

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

gemu2015 commented 8 months ago

this # in >D was never required ! it is not intended to add more checks for syntax errors since on such a small machine (especially esp8266) it would add too much code. you are free to add remarks to the docs what may cause such weird behavior

hagenbuch commented 8 months ago

Thank you! I know that the # in >D had not been required but I could not get the script to run in 11.1 before I added the #!

I'll take a look into adding a remark in the docs as you suggested.

Sometimes removing code can improve code :)