Setting latitude and longitude within a rule?

Hi guys,

Is there a way to set the latitude/longitude in the OH settings (used as input for astro binding for example) within a rule?

The usecase is for a motor home. I plan to build a smart camper van. I will have the latitude/longitude available in two number items.

Question is how to change the position within a rule (one every hour)

Is there a better way than using exec binding with a shell script to modify the config file?

Regards
Ralf

Good Idea - also applicable to boats.

I do not think there is any in-flight way to modify parameters loaded from xxx.config files.

If you use PaperUI to make settings however, it raises the possibility of using the REST API to modify Astro settings. I don’t know if that could work :crazy_face:

1 Like

Everything that can be changed through PaperUI is done through a REST API. So theoretically you should be able to update the lat/long using the HTTP binding and/or sendHttp*Request Actions (or a call out to curl using executeCommandLine or the Exec binding).

For Astro it should be pretty easy. You need to get the Thing ID for your Astro Things and then use a PUT to the /things/{thingID} end point. The required format of the JSON you need to pass is documented in the REST API (installed from the Misc tab in PaperUI).

Unfortunately, I do not know what the REST API end point is to change the Regional Settings under Configuration -> System in PaperUI. I imagine you will need to adjust these settings too to get the correct time zone. But all of the settings that are made there get reflected in config files.

Ultimately, those settings end up in the file $OH_USERDATA/config/org/eclipse/core/i18nprovider.config (one of the xxx.config files rossko57 mentions). But this is an automatically generated file and should not be edited directly (not to mention that I think your changes will be overwritten). But I think you can make the settings in $OH_CONF/services/runtime.cfg and they will be picked up by OH and the config settings changed. For example:

org.eclipse.core.i18nprovider.location="38.xxxxxx,-104.xxxxxx"
org.eclipse.core.i18nprovider.timezone="blah/blah"

I’m not 100% positive this will work but it’s a path to follow to get started. Of course, a challenge will be keeping your location and time zone in sync is going to be fun. You might need to find some script or call out to some other service to make that change work.

As Rick says, tweaking timezone would be a challenge for the complete solution.

My files comment was really about - if you create Things from xxx.things file, you will not be able to edit with REST API - they get marked uneditable. To edit Astro Things (the location) you’d need to start off with a PaperUI defined Thing.
I wonder if such an update triggers a recalculate, I would hope it gets picked up at next azimuths recalculation due in a minute or two.

1 Like

I can confirm that the triggers are recalculated.