Get output in one channel from another

Hi, I have weather station which writes output to file, smth like that:


I am using exec binding, which simply do “cat myfile”.
I want to define three custom channels (for temp, humidity, pressure).
How I can redirect exec output channel to my custom channels, then I can perform different regex for same output and print responsible values?

my Thing configuration:

Thing exec:command:ws01 [command="cat myfile"] {
                State String : temperature [transform="REGEX(.*temperature=([\\d.]*).*)"]
                State String : humidity [transform="REGEX(.*humidity=([\\d.]*).*)"]
                State String : pressure [transform="REGEX(.*pressure=([\\d.]*).*)"]

And this configuration doesn’t work

Accorsing to the docs, the binding only allows the following channels:

Create an output channel and assgin the channel to a string item

String ExecOutput { channel="......" }

You will need to do this is a rule:

rule "my trasform exec"
    Item ExecOutput changed
    tempItem.postUpdate(transform("REGEX", ExecOutput.state.toString, ".*temperature=([\\d.]*).*")

seen this.
i hoped that exists cleaner solution.
anyway thanks

You can link the one output channel to several Items, each with a different transform profile to apply your REGEX.
But I don’t think that would help you, as the transform profile is limited to String type Items.

could you please write an example, how I can apply different transformation for different items?


String myString1 { channel="blah:bleh" [profile="transform:REGEX", function=".*temperature=([\\d.]*).*"}
String myString2 { channel="blah:bleh" [profile="transform:REGEX", function=".*humidity=([\\d.]*).*"}

but note that this profile limits you to String type Items.
By using postUpdate in a rule, you can instead target Number type Items, or even Number:Temperature types etc.