I need some help. An external script is producing a file with some values in it. For example:
308
2
(* So 2 numbers with line break after it.)
I want to create an commandline sensor that reads that file and value_template it. But how to do this?. Couldn’t find an example. I read the value_template docs, but still nog able to figure out. Does have anyone an example to point me in the right direction?
The value for NR is the line you want to read, so the first line in my example.
The unit_of_measurement can be anything you want, or you can leave it out if not needed.
I tested it and using curl results in a error: “malformed url”. So i used tail instead. And that works. Are there any drawbacks using tail instead of curl?
Many thanks, for pointing me in the right direction!
tail, by default, will output the last 10 lines of a file, so I guess that would depend on how many lines are in your file. You could also specify how many lines you want to output with tail. Or you could use cat instead.
Anyway, I don’t think there’s any drawbacks to using tail so I’m glad to hear you got it to work!