Blocky: Issue when string contains "TS_Electricity"

Hi all,

I just started to play with Blocky and do like it.

I stumbled over a strange behavior. It seems if I try to use a string which contains “TS_Electricity” it will be ignored. If I change “TS_Electricity” slightly, everything works like a charm. Can anyone reproduce the same? Or can someone give me hint what I’m doing wrong?

“TS_Electricity” is part of my item-naming scheme for my smartmeter. Therefore I stumbled over it. I tried with “TS_Watermeter” which items are quite similar Here are no issues.

See here a simple example to reproduce:

image

Cheers Steffen

  • Platform information:
    • Hardware: Pi4
    • OS: Openhabian Stable 3.4.2
    • openHAB version: 3.4.2

Go to the “code” tab and post the full rule. Use code fences.

```
code goes here
```

Argh … wanted to do so but missed it. Here you go. Whole code was generated by Blocky.

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);


logger.info('Any String');
logger.info('TS_Electricit');
logger.info('TS_Electricity');
logger.info('Any String');

//Any string  -> appears in log
//not exact TS_Electricity -> appears in log
//IMPORTANT: string contains "TS_Electricity" -> NO log entry

Not reproducible (openHAB 3.4.0-SNAPSHOT - Build #3224).

Don’t redact it. I want to see the full rule. Everything, the trigger, the blockly XML, and the JavaScript it compiles into.

From the Rule’s page click the “Code” tab and paste everything you find there.

Hi, for this example I just created the blocky script direct in the settings->script->Blocky. Not coming from a rule.

I’m starting the script via the play function from Blocky.

So, I tried to strip everything what is not causing the issue. And I hope it is easy to reproduce. If it is reproducible.

@anon71759204 Thank you for testing. It seems for your version the issue does not exist.

@rlkoshak If you can see more and if it’s helpful, I can create a rule with trigger when I’m m back at PC tomorrow. Or is there anything like a trace level which I shall switch on?

Thank you for taking care.

It might help to see the Blockly XML in addition to the JS and the screen shot of the blocks. There’s nothing special about this code, it should work.

Edit: To see the XML though you’ll have to implement this as a Rule, not a Script.

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

logger.info('Any String');
logger.info('TS_Electricit');
logger.info('TS_Electricity');
logger.info('Any String');
2023-02-28 23:41:18.386 [INFO ] [org.openhab.rule.02ee016c35         ] - Any String
2023-02-28 23:41:18.389 [INFO ] [org.openhab.rule.02ee016c35         ] - TS_Electricit
2023-02-28 23:41:18.391 [INFO ] [org.openhab.rule.02ee016c35         ] - TS_Electricity
2023-02-28 23:41:18.394 [INFO ] [org.openhab.rule.02ee016c35         ] - Any String

The OP says it is specifically the string TS_Electricity which is causing issues.

Good catch - but it doesn’t make a difference for me. Post updated.

Dear all,

it did not understand why the for me specific string but for all other random string seems to make issues. Today in the morning under the shower, the root cause jumped in my mind. I have to admit, as in most cases the main problem was in front of the screen. Me!

Before I explain, what I did, I’d like to thank for your help and time spent. Much appreciated.

What did I do? A couple of weeks ago, to have a much cleaner log and not beeing flodded by some item updates, I added filter for my logs. “TS_Electricity” was one of the filter criteria, as the smartmeter updates consumption every few minutes. :man_facepalming:t2:

nano /var/lib/openhab/etc/log4j2.xml

See both regex filter criteria …

 <Appenders>
                <!-- Console appender not used by default (see Root logger AppenderRefs) -->
                <Console name="STDOUT">
                        <PatternLayout pattern="%d{HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
                </Console>

                <!-- Rolling file appender -->
                <RollingFile fileName="${sys:openhab.logdir}/openhab.log" filePattern="${sys:openhab.logdir}/openhab.log.%i.gz" name="LOGFILE">
                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
                        <RegexFilter onMatch="DENY" onMismatch="ACCEPT" regex=".*(vOS_tram|TS_Electricity|vOS_Weather_|FFmpeg Input URL|_Temperature|_LastHeartbeat|coap Exchange|_Power|_Humidity|tried updating the thing status although >

                        <Policies>
                                <OnStartupTriggeringPolicy/>
                                <SizeBasedTriggeringPolicy size="16 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="7"/>
                </RollingFile>

                <!-- Event log appender -->
                <RollingRandomAccessFile fileName="${sys:openhab.logdir}/events.log" filePattern="${sys:openhab.logdir}/events.log.%i.gz" name="EVENT">
                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
                        <RegexFilter onMatch="DENY" onMismatch="ACCEPT" regex=".*(vOS_tram|TS_Electricity|vOS_Weather_|FFmpeg Input URL|_Temperature|_LastHeartbeat|coap Exchange|_Power|_Humidity|tried updating the thing status although >
                        <Policies>
                                <OnStartupTriggeringPolicy/>
                                <SizeBasedTriggeringPolicy size="16 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="7"/>
                </RollingRandomAccessFile>