Platform information:
Hardware: CPUArchitecture/RAM/storage
OS: raspian
Java Runtime Environment: 1.8.0_191
openHAB version: 2.3.0
Issue of the topic:
I use the icloud binding to populate location data of my iphone to OH (coordinates, accurancy, last update, etc).
Now I would like to add the location item SimonsIPhoneICloud_Location to the rrd4j DB I am running since ever to persist my item states.
Unfortunately it doesn´t persist them.
Strategies {
everyMinute : "0 * * * * ?"
every5Mins : "0 0/5 * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
default = everyChange
}
Items {
...
SimonsIPhoneICloud_Location : strategy = everyMinute, restoreOnStartup
}
I can easily visualize the position on a map :
sitemap map {
Frame label="Location" {
Text item=SimonsIPhoneICloud_LastLocationUpdate label="letztes update:[%1$ta %1$tR]"
Mapview item=SimonsIPhoneICloud_Location label="Da ist er!" height=8
}
}
Checking the REST API tells me that there are no datasets available:
http://192.168.1.10:8080/rest/persistence/items/SimonsIPhoneICloud_Location
response body:
{
"name": "SimonsIPhoneICloud_Location",
"datapoints": "0",
"data": []
}
For other items persistency works well - can it be related to the items type location?
Thanks.
rkrisi
(Kristof Rado)
January 8, 2019, 10:07pm
2
Yes it wont work with Location. You can persist it manually, by persisting altitude latitude and longitude
Thanks - that was quick! I evetually split it up and persist them separately.
vzorglub
(Vincent Regaud)
January 9, 2019, 10:37am
4
The reason behing that is that rrd4j only store Numbers !!
As explained in the documentation here:
Introduction NOTE:
NOTE: rrd4j is for storing numerical data only. Attempting to use rrd4j to store complex datatypes (e.g. for restore-on-startup) will not work.
rkrisi
(Kristof Rado)
January 9, 2019, 11:29am
5
However Location is only a set of float Numbers as well, right?
I know that is because the DB doesn’t know that and it just tries to store it as a whole ‘data’, but maybe some hack could be introduced in OH, where if you want to store a Location data it stores automatically in 3 value:
ItemName_Latitude, ItemName_Longitude, etc…
Also this could work vice-versa, if you want to get a persisted Location element, OH should look for this 3 db value and it could build a Location item from it.
I know you can do it simply via rules, but it can be good…
vzorglub
(Vincent Regaud)
January 9, 2019, 11:30am
6
rkrisi:
set of float Numbers
a set of numbers, not a number
1 Like
vzorglub
(Vincent Regaud)
January 9, 2019, 11:32am
7
For restoreOnStartup, it is recommended to use madDB:
First line of the intro paragraph
viktor_Sc
(Viktor Schopf)
January 9, 2019, 8:15pm
8
Hey there,
how can I persist the altitude, latitude and longtitude separately if I have one Location item?
Thanks,
Viktor
vzorglub
(Vincent Regaud)
January 9, 2019, 8:26pm
9
Split it up into three items
viktor_Sc
(Viktor Schopf)
January 9, 2019, 8:39pm
10
Right.
Simply by accessing myLocationItem.latitude?
rossko57
(Rossko57)
January 9, 2019, 8:52pm
11
The other thread incudes a rule extracting lat long values.
Like @ThomDietrich suggested, I tried the way of separating the Location coordinates and it was actually much simpler than I expected:
Items:
Location Location_Home
Number Location_Home_Lat (G_Numbers)
Number Location_Home_Lon (G_Numbers)
Initialization (startup.rules)
// set home location coordinates
Location_Home_Lat.postUpdate(38.897676)
Location_Home_Lon.postUpdate(-77.036626)
and calculation in geofencing.rules:
rule "Calc Distance of from Home"
when
Item mqttLatitude changed…
viktor_Sc
(Viktor Schopf)
January 9, 2019, 9:04pm
12
Hi,
seems I’m not getting it. In the other thread for me it looks like they get two separate values for mqtt and do not extract anything from a single Location item.
rossko57
(Rossko57)
January 9, 2019, 9:57pm
13
You’re right, that was a rubbish reference from me
I think you can do
var lat = (myLocationItem.state as PointType).latitude
var lon = (myLocationItem.state as PointType).longitude
Bredmich
(Michael)
January 9, 2019, 10:14pm
14
Have a look at my post here .
viktor_Sc
(Viktor Schopf)
January 9, 2019, 10:15pm
15
Thanks, guys. I’m gonna have a look. I think it helps
Cheers