Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Processing of things file hits problem, possibly with REGEX, and stops parsing .things file #2863

Closed
jackdewinter opened this issue Jan 19, 2017 · 5 comments

Comments

@jackdewinter
Copy link

  • Problem 1: the specified line for exec:command:office_desk_backlight_ping raises an error condition that causes the exec:command:office_desk_backlight_check line and others after it to be ignored
  • Problem 1a: something in the content of the .thing line for the ping causes an error condition to occur. That issue is not logged in the log file at general log levels, hence it is difficult to determine any error and debug it.
  • Problem 1b: the REGEX for the ping does not seem to be working, regardless of its position.

Upgraded to a new version of OpenHab on 14 Jan's nightly build, included eclipse.smarthome.

At the time, I added the following lines to my .things file:

exec:command:office_desk_backlight "TP-PlugSwitch"	[command="/bin/tplink.exe %2$s", interval=0, timeout=5, autorun=false]
exec:command:office_desk_backlight_ping	"TP-PlugPing" [command="/bin/cping.exe --ip 192.168.2.3", interval=30, timeout=30", transform="REGEX(.*sent(.*)replies.*)", autorun=true]
exec:command:office_desk_backlight_check "TP-PlugStatus" [command="/bin/tplink.exe check", interval=15, timeout=5, transform="REGEX(.*stateX\":\"(.*)\".*)", autorun=true]

when added in this order, the following lines are output as part of the logs:

20:45:14.520 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'jack.things'
20:45:14.542 [DEBUG] [er.antlr.AbstractInternalAntlrParser] - Parsing took: 16 ms
20:45:14.544 [DEBUG] [.linking.impl.AbstractCleaningLinker] - beforeModelLinked took: 0ms
20:45:14.545 [DEBUG] [.linking.impl.AbstractCleaningLinker] - doLinkModel took:1ms
20:45:14.546 [DEBUG] [.linking.impl.AbstractCleaningLinker] - afterModelLinked took: 1ms
20:45:14.604 [WARN ] [.thing.internal.GenericThingProvider] - Thing exe does not have a bridge so it needs to be defined in full notation like :exe:check
20:45:14.639 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'exec:command:office_desk_backlight_check' changed from ONLINE to UNINITIALIZED (HANDLER_MISSING_ERROR)
20:45:14.661 [INFO ] [smarthome.event.ThingRemovedEvent ] - Thing 'exec:command:office_desk_backlight_check' has been removed.
20:45:14.662 [WARN ] [.thing.internal.GenericThingProvider] - Thing exe does not have a bridge so it needs to be defined in full notation like :exe:check
20:45:14.670 [WARN ] [.thing.internal.GenericThingProvider] - Thing exe does not have a bridge so it needs to be defined in full notation like :exe:check
20:45:14.685 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing 'exec:command:office_desk_backlight' has been updated.
20:45:14.692 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing 'exec:command:office_desk_backlight_ping' has been updated.
20:45:14.691 [WARN ] [.thing.internal.GenericThingProvider] - Thing exe does not have a bridge so it needs to be defined in full notation like :exe:check

At this point, the REGEX from the ping will not work, and the check will not be scheduled and not produce any output.

However, if I put the TP-PlugPing line at the end, both lines will load, the check will be active and it's REGEX will work, and the ping will still be scheduled, but not apply the REGEX to the input.

20:55:13.002 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing 'exec:command:office_desk_backlight' has been updated.
20:55:13.010 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing 'exec:command:office_desk_backlight_check' has been updated.
20:55:13.012 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing 'exec:command:office_desk_backlight_ping' has been updated.

@jackdewinter
Copy link
Author

note: the rule seems to stop because of a " after the timeout value. But I would expect a warning about the one line, and not stopping the entire file from loading.

@sjsf
Copy link
Contributor

sjsf commented Jan 19, 2017

No, tis has nothing to do with the regex. The problem in your case is the timeout=30". So everything afterwards becomes a string, and you basically inverted strings and non-strings. The parser has no chance to figure out what you intended to do, unless we would limit what you are allowed to express within strings.

Please fix the syntax of your file. Apart from that, I don't see any bugs here.

@jackdewinter
Copy link
Author

After I found the issue that you mentioned, I was partially okay. My current issue is that it happened silently, instead of issuing some kind of warning. I can see people making a mistake like that and not being able to notice it.

Why would the parsing need to deal with any strings that go beyond one line without some kind of concatenation?

@kaikreuzer
Copy link
Contributor

Afaik, the problem of having no warnings on parsing errors exists for all model files, i.e. items, rules, things, scripts and persistence.
I agree that this is a trap, but afair, there wasn't an easy solution. I have entered #2870 for further action.

@sjsf
Copy link
Contributor

sjsf commented Jan 20, 2017

Thanks @kaikreuzer. Apart from that I can really recommend using the Eclipse Smarthome/openHAB Designer to edit your files. There, you won't miss syntactical errors like this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants