HeishaMon icon indicating copy to clipboard operation
HeishaMon copied to clipboard

Feature request: Comment in rules (v5 Hardware)

Open blb4github opened this issue 1 year ago • 4 comments

With the new Hardware (v5, based on ESP12), the space for rules is increased and rules do require less space (if I'm correct). It would be convenient to have the possibility to add comment to the rules to document the rules in the rules set itself.

blb4github avatar May 25 '24 21:05 blb4github

This is already partly possible with beta version 3.5. In order to be able to implement the command @SetCurves in Rules, (needs JSON string) the internal handling of strings was integrated. For example, up to 255 characters can be assigned to a local or global variable. (#Test1 = 'Good morning together';) This is then displayed in the list of supplied variables in the lfd console.

Additionally, the "Print" command was introduced which displays the text in the console. This command can also be used as a note for documentation in the lfd rules code. (print('### Standby overflow ###');) The disadvantage is that this text is output in the console during runtime which would not be necessary here.

Out of the box: I have already made the suggestion (#121) to implement a Rem command as a modified print command without any output. As a further idea, I also suggested implementing a command such as SendUrl = 'Text', which can send the attached string to the web server. This could be used, for example, to control the relay on a Shelly. I could also have disruptions or daily statistics sent to my cell phone via string to a WhatsApp Bot. The text can be up to 255 characters long. Maybe it can be implemented after all because it would fit well with the introduction of strings.

McMagellan avatar May 29 '24 15:05 McMagellan

Thanks, looks useful! I have tried to implement in my rules a command print('#Time: ', #Time); but this one triggers a crash. I have experimented with the string variable (add in a lot of lines with #com1 = 'xxxxxxxx xxxxx xxxxx xxx'; this seems to work but if you put this in an on end rule these lines are all always executed which seems not right to me. A real comment function (everything behind a comment symbol is comment) should be great (if possible :)).

blb4github avatar May 29 '24 23:05 blb4github

@blb4github: I have your command "print('#Time: ', #Time);" installed in my SetCurves test rule and it runs without any problems. I'm using version Alpha-baddb94, build #531 on Heishamon V4

In this example you have used a numeric value in addition to the text. This application makes no sense for the Rem application you requested.

For the sake of completeness, in such a case the command "concat( )" is used to insert a number into a text. The print command is a variant of the concat command and therefore already includes the number-text conversion.

Example for concat: @SetCurves = concat('{zone1:{heat:{target:{high:',#HKTempUp,',low:',#HKTempDown,'}}}}');

""A real comment function (everything behind a comment symbol is comment) should be great (if possible :))."" I think if it were easy to implement it would definitely already exist.

McMagellan avatar May 30 '24 10:05 McMagellan

I think if it were easy to implement it would definitely already exist.

It is relatively easy. Altough it's not a feature for the rules library. As in, the rules library is not going to support it. It is possible to implement a feature that filters all comments before the rules are provided to the rules library.

CurlyMoo avatar Jun 10 '24 14:06 CurlyMoo

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 09 '24 02:10 github-actions[bot]