HTTP binding changing back issue

Hello All,

I’ve been search arround the forum, but I couldn’t find anything which help me to resolve the problem.

I have simple HTTP binding for retrieving setting of current temperature. I’m using slider to show and manipulute the value itself. For sending the settings back to heatpumg I’m using simple rule (not configured in .items file as I need to set up auth and send json data.)

Rule:

when

        Item SH_Tcomfort received command

then

        var String value = SH_Tcomfort.state.toString
        executeCommandLine('/etc/openhab2/scripts/set_temperature.sh '+value)
        logInfo("Updating SH_Tcomfort", "Setting up value " + SH_Tcomfort.state)

end

The rule itself is working fine (I can see the actual temperature has been set). Unfortunatelly after few seconds the slider changes its possition back to original one.

I can see it also in event.logs.


[ome.event.ItemCommandEvent] - Item 'SH_Tcomfort' received command 22 -> I changed the slider to 22
[vent.ItemStateChangedEvent] - SH_Tcomfort changed from 21 to 22 -> My change caused slider to change
[vent.ItemStateChangedEvent] - SH_Tcomfort changed from 22 to 21 -> who the hack sends this update?

The question is why the slider reverts back to previous state? Does it something to do with HTTP cache I set up in /etc/openhab2/services/http.conf ? If yes, how to solve the issue? If not, what am I missing.

Thank you.

Y

Nobody knows. What bindings do you have linked to your Item?

1 Like

Setting AND retrieving values on the same item will not work.
My guess is the item is setup to show the actual temperature. Changing that manually will show on the item for a short time and then revert to the actual temperature. Are you sure that the desired temperature is set the same way as the actual temperature is read on your device. I would guess another http message is needed!

Why setting and retrieving values on the same item will not work? I’m using it many times and it is also written in doc (just take a look on the http bindings example) where in one item definition you have config parts for “IN” > and “OUT” < direction.

And you’re kinda wrong with your assumption. I’m not reading actual temperature, but acctuall settings of the temperature.

obrázok

Because HTTP “incoming” status is served from a cache. Immediately after you send a command, that will still contain “old” data.

thank you for reply. I though that will be the case. So the question is, how can I clear the case or force to update the item in given rule?

Nobody knows. What bindings do you have linked to your Item?

Here is the item binding config

// Comfort temperature
Number SH_Tcomfort { http="<[smarthubCache:5000:JSONPATH($.T_comfort)]" }

What does your http.cfg look like?

Okay, so sometime in the next 5 seconds, your Item state will be refreshed from cache.

We don’t know how often the binding refreshes the cache, because that is in your still secret http.cfg

I do not think HTTP binding honours REFRESH commands to Items, so there is no way to provoke an immediate fetch.

2 Likes

@noppes123, @rossko57

here is my http.cfg (no magic over here).

smarthubCache.url=https://10.0.30.21/api/telemetry{Authorization=bearer TOKEN_HERE}
smarthubCache.updateInterval=300000

As you confirmed I understand the value is cached for 5min and checked based on granularity interval (left default). I can also confirm HTTP binding doesn’t support REFRESH command.

So the million dollar question remains the same, how to solve given issue?

PS: I tried also to play with expired settings “to somehow set the item as expired” and get update sooner - no luck over here as well.

Sorry for my misinterpretation concerning actual vs desired-temperature.
IMHO getting the update sooner could be obtained by decreasing the cache update time (60 seconds?).

If you want to manage your Item in ways that HTTP binding does not allow (refresh-on-demand) then you’ll have to manage that yourself, using rules and HTTP actions probably

1 Like

How short a expire interval did you try? The update and ‘revert’ is probably done within the granularity (defaults to 1 second). Since you only have an input channel, writing to the Item state will probably make OH revert the Item state back.

Anyway, you can completely do it without the HTTP binding and just use curl in rule or script to retrieve the data as well. That way there is no ‘interference’ from the HTTP binding’s cache or update mechanism.

EDIT: @rossko57 just beat me to it… ;o)

1 Like

@noppes123 and @rossko57: that actually looks like solution for me. I try as soon as I will be on my PC.
Thank you anyway. I will share the result for sure.

EDIT: how to send HTTP request with authorization header without using .items file? As far as I can see on signature of sendHttpGetRequest() it doesn’t support adding hearders (even documentation says smth different than github code https://github.com/openhab/openhab1-addons/wiki/Actions#http-actions)

Y.