on Openhab 4.2.2 I’m trying to extract current weather data from an HTTP request, I’ve written the follow for the thing and channels, then linked items, but last succes is fine all the reply can be readed as json from risultato but all of the others items got NULL, UNDEF.
Can you please tell me if this is completely wrong? I cannot understand where the reply should go or how can I extract single values.
HTTP Channels have two transformations, and I don’t think either of them is “transformationPattern”. There’s “commandTransformation” and “stateTransformation”. HTTP - Bindings | openHAB
Always check your syntax against the docs if you use .things files. Another thing you can do is configure it in the UI and then click on the code tab to see the names of the parameters.
Beyond that :shrugging. I don’t support .things files. I’d rather solve home automation problems than syntax errors.
if the result is literally "82" you need to remove the quotes. The HTTP transform supports chaining transformations so you can run the JSONPATH and then chaing that to an inline script transformation to strip off the quotes.
Don’t guess at the syntax. It says right there in the description for the field how to chain two transformations.
Transformation pattern used when receiving values. Multiple transformations can be chained by listing each transformation on a separate line, or by concatenating them with “∩”.
Also always look at the logs when something goes wrong. It will usually tell you exactly what’s wrong and sometimes how to fix it
Thank you, if I’ve understood, the correct syntax should be: stateTransformation: JSONPATH:$.current_condition[0].pressure ∩ REGEX:"\"(.*)\"":$1
In logs only those rows are shown so I suppose data are managed correctly:
6:06:30.912 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'http:url:weatherservice' changed from INITIALIZING to UNKNOWN
16:06:32.481 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'weather_meteo_Thing_URL_HTTP_Last_Success' changed from 2025-03-15T16:04:03.442712746+0100 to 2025-03-15T16:06:32.478219543+0100
16:06:32.485 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'http:url:weatherservice' changed from UNKNOWN to ONLINE
Anyway I’ve tried replacing the pressure transformation with the one from temp_c expecting to see the same data both in pressure and temperature. But temperature is shown, pressure is NULL
That’s events.log. openhab.log is where the errors will appear.
All those logs show is that the Thing came online and was successfully able to pull down the JSON data. But the success in parsing that data and updating the Items is failing and those errors will be in in openhab.log.