Openhab-cli output

Is the output from openhab-cli console commands formatted in some different way than standard output? I’m trying to run a command to get the temperature from a sensor and I’m getting suspicious that the output has some hidden non-printable characters or odd encoding that’s messing up my script.

There are a mix of terms here that do not make much sense.

When you run openhab-cli console it logs you into the Karaf Console. This lets you interact with the internals to openHAB. If you are getting a temperature from the Karaf Console, then it is a value that openHAB already knows in a Thing or an Item. So why are you trying to get a value that OH already knows through the Karaf Console?

Or do you need the value in some other script? If that’s the case, then if your temperature sensor is defined as Number:Temperature then the state of that Item will include the degree symbol and the units (C or F).

Finally, a more flexible approach that would work should you move this external script to another machine would be to use the REST API to retrieve the value from OH using curl.

Install the REST API docs and look in the Items section for the exact curl command you need.

I’m real new to OH so mixing up terms is likely. I’m gonna look into the REST API when I get home today. That may be a better solution all around for me.

Okay, now I got things working right. I knew I’d end up getting into the API sooner or later but had been distracted by other things.

The nice thing is the REST API is well documented and interactive. I use the REST Docs to actually test Rules and such a lot of the time. It’s really handy.

1 Like

Yes indeed. After fixing my initial issue it dawned on me that I have other opportunities. So I now have a service to track the internal temperature of my big freezer. Using a Fibaro door sensor and a DS18B20 sensor for that. The service is in check_mk so I’ll get a nice graph of the temperature over time (up to a year) and I can set up alerts separate from OH. After that I whipped up a script to track the battery percentage for all my sensors that report such.

Don’t actually “NEED” any of that but it is fun to futz around with this stuff and keeps me out of trouble.

And now when you do need to do something like that, you will know how. :slight_smile: