Set system-parameter by rule?

Before my SD card crashed I had a rule that updated a system setting. But I can’t find how now.

I want to update the “location” under regional setting.

As written in my other post in the other thread:
have a look to the REST API ( /services/{serviceId}/config ).
As far as I understand the REST API you can update / set the configuration there.

Accessing by using GET request to http://pi:8080/rest/services/org.openhab.i18n/config ( as described in REST API ) returns:

{
  "timezone": "Europe/Berlin",
  "variant": "POSIX",
  "language": "en",
  "location": "5X.X1682772120481,X.XX63952398300173",
  "measurementSystem": "SI",
  "region": "DE"
}

There is also PUT request to set these items.

has anyone gotten this to work and can share his code ? Preferrably rules DSL.
Note API usage requires authentication, my first attempts ended up being told that.

Or you could write a script that writes to a config file in CONF/services/something.cfg. To make it easy just have this file contain one config so you can overwrite it instead of “editing” it.

The syntax is probably:

org.openhab.i18n:location=xxxx,yyyy
1 Like

I know you know how to use the API explorer.
I did a trial with the code created by API explorer like:

curl -X 'PUT' \
  'http://pi:8080/rest/services/org.openhab.i18n/config' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer eyJraWQiOm51bGwsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJvcGVuaGFiIiwiYXVkIjoib3BlbmhhYiIsImV4cCI6MTY3NzY5MzM4NCwianRpIjoiZXpGQ0d6ZUtmUWJsNVhFTWVJUHJFdyIsImlhdCI6MTY3NzY4OTc4NCwibmJmIjoxNjc3Njg5NjY0LCJzdWIiOiJhZG1pbiIsImNsaWVudF9pZCI6Imh0dHA6Ly9waTo4MDgwIiwic2NvcGUiOiJhZG1pbiIsInJvbGUiOlsiYWRtaW5pc3RyYXRvciJdfQ.UlGq7sx48qVieX7o6CFqHIqtJxYl_iodi5oWsNzbWrbFlkknWqGmVAE09F3DxsJDd3Bsvh_YNwSVwL95s3RHwCpzps-wHAKvw0pIa1yLq49wmjl7z-HH7XqtwFK1DHHPNmMztRVuO6Oule-ICvM3lwvKKo_P7Fesb3SZEGOBOyKbjbvaKRY_qd3jzEvHk41EDgLFAiW421Ea8zxQkVTEu4x1hiPjGymMZJIkFJIBuyAtnUdCflRZKeh2OA7Lu7wILZrrmO-6iNmlgkuCpHXM40g6Iw_zKtgSVEuO8fAnFYFiBewmxPrxY3TSsd3TyIoqtw3WMcBHT1Ldhoqi8A513A' \
  -d '{
  "timezone": "Europe/Berlin",
  "variant": "POSIX",
  "language": "de",
  "location": "50.31682772120481,8.863952398300173",
  "measurementSystem": "SI",
  "region": "DE"
}'

As this works you could but it into a script that needs to be called …
But I assume your question then is more about how to do it just using DSL code ?

Yes. But @JimT’s hint was even better, I have it working like that now.

1 Like