letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.26k stars 2.21k forks source link

Check task/value names for "unwanted" characters + adding brackets in rules #1379

Closed Grovkillen closed 2 years ago

Grovkillen commented 6 years ago

Today we have little to no lookup on names of tasks and those tasks value names. This makes a rule like this a bit hard to parse for the rules engine:

on DHT11 Outside#Temperature>20 do
GPIO,2,1
endon

For formulas in rules we enclose these with square brackets, my opinion is that we should always use this for events as well. The above example would then look like this:

on [DHT11 Outside#Temperature]>20 do
GPIO,2,1
endon

That way we could allow for spaces in names (which I think is cool because you might want to inject those value names into a homepage for example). But we should also make sure that we never have a hashtag inside a name. What else should not be allowed?

Open discussion

TD-er commented 6 years ago

Quotes should also be left out. I guess also multi-byte UTF-8 characters may be causing issues when parsing.

giig1967g commented 6 years ago

What about backwards compatibility? Wouldn't this change break all setups?

Grovkillen commented 6 years ago

Yes it probably will but should instead trigger a warning. We need to take care of this ahead of time I think.

workgroupengineering commented 6 years ago

In a private or I'm working. I used a similar syntax but only on the name.

on [DHT11 Outside]#Temperature>20 do
GPIO,2,1
endon

in this way there are no backward compatibility problems, because if in the name of task there is space, i adding square bracket at name.