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"] {
Channels:
State String : temperature [transform="REGEX(.*temperature=([\\d.]*).*)"]
State String : humidity [transform="REGEX(.*humidity=([\\d.]*).*)"]
State String : pressure [transform="REGEX(.*pressure=([\\d.]*).*)"]
}
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"
when
Item ExecOutput changed
then
tempItem.postUpdate(transform("REGEX", ExecOutput.state.toString, ".*temperature=([\\d.]*).*")
....
....
end
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.
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.