I want to send a value from a bash into openhab to assign to value into a variable. I do not want to pull the value via a repeated poll of the variable.
I thought MQTT might be a possible way - or is there a more easy / simple way ???
In other words: What is the right binding ?
Maybe I misunderstood your question…
So you would like to run something within a bash “script” I assume…
and the result of it you would like to set some item to certain status?
I would suspect this could be done using a local (scripted) ssh connection to OH console.
In the way of:
"ssh parameters " <<EOF
smarthome:send ITEM ITEM_STATE
But frankly spoken I don’t know if this approach would work.
For sure you could use MQTT (not speaking) about the binding itself, just using mosquito_pub to update the item residing in the OH structure.
Using the rest API of openHAB2 and a HTTP post command in your script would be the easiest.
You can also use a PUT command, but you’ll have to load the classicui for it to work.
THANKS!! restAPI is the winner …
But… (maybe a different topic).
I can use the restapi to switch - but when I send a value, I see in the log file:
…Item ‘wetter_esp1_humid’ received command 20.0
…wetter_esp1_humid predicted to become 38.34
So the value arrives - is interpreted as an command - and not used ??
Any (helpful) thoughts ??
… I found out, that the item must be defined with: , autoupdate=“true”
If you sent it as a command using REST API - yes.
As this seems to be more of a “sensor” type value, humidity? it might make more sense to use REST API to send it as a state update.
That would have it act more like conventional bindings to real devices.
It’s up to you to choose how to use REST API
That comes from the autoupdate feature. It listens for commands to an Item, guesses the effect on the state.
It is enabled/disabled per Item, and is active by default.
Note it does not act (is not needed) when you update rather than command.
If your Item happens to have UoM specified, you may also need to specify units in your command/update, or automatic scaling could kick in.
Don’t you mean GET? You can command or update an Item using HTTP GET with classicui installed. With the REST API, POST results in a command to the Item and PUT results in an update to the Item.