I 've a problem with a String-Item. The item get the values via curl from a txt-file.
curl -s -X PUT --header “Content-Type: text/plain” --header “Accept: application/json” -d “$i” "http://openhabianpi:8080/rest/items/VibSys_ETS10_
I need only a part of this value “[Vib-Sys_ETS-10]”.
How can I remove the square bracket? Do you have any ideas?
thanks for your answer.
Because I don’t have any experience with the http-binding.
I’m not a programmer and I don’t come from IT. I usually find the right scripts and try to adapt them and that was easy with curl Very much is try and error.
What could the call look like? The file is in the directory /home/pi/.
My script goes through the file line by line and pushed the content to the Openhab Rest interface.
Hi Rich,
Thanks for the tip. I have now installed the HTML binding. Does the file to be read have to be in a certain directory? Do I need my script or does the binding do everything? I really don’t have a plan.
The binding does what curl does. It fetches a url periodically (use the http cached config as described in the docs), or on demand (use an Item config as described in the docs).
now I’m one step further. But I get this error message. It works in the Online-Regex-Tester. Can you help me?
Thank you in advance
Dirk
Item :String Sascha_Test “Sascha test [%.1f ]” (gKabine) { http="<[http://192.168.10.122:8080/static/M1.txt:30000:REGEX(.*|\n)]" }
[ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type ‘http’ of item ‘Sascha_Test’ could not be parsed correctly.
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]
at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:143) ~[?:?]
at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119) ~[?:?]
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:49) ~[?:?]
... 16 more
The error states that your binding config on the item is malformed. The problem has nothing to do with the regex per se. Compare what you have with the examples in the docs and those you can find in this forum. You are missing something or have a steady character that needs to be escaped or something.
The first and the last one contain the correct values, but the others contain the correct value + the complete rest of the text file.
I tested the Regex definition at https://regex101.com/ and it works there.
REGEX in openHAB have to match the full text and you use parens to express which part you want to return.
So your (.*) in OH means everything after “Aktualisiert=” which includes the whole rest of the text. You need to tell it to only get the text up to the end of the line. Something like:
many thanks for your fast answer, but I get an error.
I have to do something wrong because as soon as I use a \ the color in the editor becomes bright yellow and the characters are ignored.
2019-03-05 17:08:57.523 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type ‘http’ of item ‘Sascha_Test’ could not be parsed correctly.
.*)]’ doesn’t contain a valid binding configuration
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]
at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]
at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]
at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
.*)]’ doesn’t contain a valid binding configuration
at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:143) ~[?:?]
at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119) ~[?:?]
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:49) ~[?:?]