Persistence not working for GPS location formatted XX.XXX75788937955,-X.XXXX170208076405

Hell all,

My setup:
Openhabian running on a Raspberry PI with OpenHab 2.2
ZWave binding, working without issues and logging all that I put in the persist file
icloud binding that receives data properly too. Looks like this:

2017-12-28 14:15:24.360 [vent.ItemStateChangedEvent] - IPhone7Plus_Location changed from XX.XXX728819336835,-X.XXX418103077689 to XX.XXX75788937955,-X.XXXX170208076405
2017-12-28 14:20:26.117 [vent.ItemStateChangedEvent] - IPhone7Plus_BatteryLevel changed from 83.99999737739563 to 81.00000023841858

I have properly working a InfluxDB + Grafana setup that logs and plots whatever I put in my ./persistence/influxdb.persist file. This looks like this:

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"

Items {
    ZWaveNode4FGMS001MotionSensor_SensorTemperature                     : strategy = everyChange, everyHour
    ZWaveNode2FGKF601Keyfob_SceneNumber                     : strategy = everyChange
    ZWaveNode3FGWP102MeteredWallPlugSwitch_ElectricMeterWatts           : strategy = everyChange
    IPhone7Plus_Location                     : strategy = everyChange, everyHour
    ZWaveNode3FGWP102MeteredWallPlugSwitch_Switch       : strategy = everyChange

Logs look clean and even when enabling from the cli the DEBUG for the icloud or openhab, I get nothing related to an error with Influx/Grafana posting/persistance.

I am tring to persist specifically the GPS position of my iPhone to influxdb so later I can plot it to a map. But nothing gets logged or attempted to be logged.

Can anyone help or point to the right direction on how to get that done?

Seems I am not alone in this, as here you can see someone else with the same issue: InfluxDB+Grafana persistence and graphing

What kind of item type is IPhone7Plus_Location defined as ?

First of all, this is definitely not realted to the iCloud Binding, nor to iCloud. Please change your topic title.

I don’t know InfluxDB, but it yould be related to the point that location is based on two comma separated values.
Please see the documentation, how values are stored:

What do you suggest this to be?

As a Location. It plots correctly in OH2.2 Paper UI to a OpenStreet’s map

A location type contains a bit more information then just the coordinates as (lat,lon). if you log the following in a rule

logInfo("Content of location item", Phone7Plus_Location.toString())

you will get more than just (lat,lon) information. But if you try

logInfo("Content of location.state item",Phone7Plus_Location.state.toString())

you will only see the lat,lon values.

Perhaps what you are trying to save don´t match the database structure?

Am I right assuming that what I see in the logs is what’s been tried to be persisted?

2017-12-28 14:15:24.360 [vent.ItemStateChangedEvent] - IPhone7Plus_Location changed from XX.XXX728819336835,-X.XXX418103077689 to XX.XXX75788937955,-X.XXXX170208076405

If so that’s just a GPS location in DD (Decimal Degrees) separated by a comma.

I thought that the persist file as specified above, if the format was just like that, would take care of storing it in influx pretty much as every other type I already sent without defining it. Seems I am wrong?

Could be. But do check the openhab.log file for difference between locationItem.toString() and locationItem.state.toString()

Remove iCloud Binding from the topic

So I tried what you suggested and when executing:

logInfo("Content two",IPhone7Plus_L.state.toString())

I get.

IPhone7Plus_L (Type=LocationItem, State=XX.XX174587203608,-X.XXXX80932258682, Label=iPhone Location, Category=null)

How could I push that to InfluxDB? --> The documentation is still to be written:

One more thought (while I struggle to make this work):

  • Shouldn’t openHab handle the GPS DD Coordinate the same way it handles the posting of decimals, integers and signed numbers?

If this is not the case, could anyone help on how could I convert the string and .persist it?

Thanks in advance

You could enable DEBUG logging for influxDB persistence and see if it logs pointTypes.

Would that enabling org.openhab ? I don’t see any influxDB persistence toggle to enable.

l~                                                                                                                                                    openhab> log:list
Logger                                             │ Level
ROOT                                               │ WARN
javax.jmdns                                        │ ERROR
org.apache.karaf.jaas.modules.audit                │ INFO
org.apache.karaf.kar.internal.KarServiceImpl       │ ERROR                     │ OFF
org.eclipse.smarthome                              │ INFO
org.jupnp                                          │ ERROR
org.openhab                                        │ INFO
org.openhab.binding.icloud                         │ INFO
org.ops4j.pax.url.mvn.internal.AetherBasedResolver │ ERROR
org.ops4j.pax.web.pax-web-runtime                  │ OFF
smarthome.event                                    │ INFO
smarthome.event.InboxUpdatedEvent                  │ ERROR
smarthome.event.ItemAddedEvent                     │ ERROR
smarthome.event.ItemRemovedEvent                   │ ERROR
smarthome.event.ItemStateEvent                     │ ERROR
smarthome.event.ThingAddedEvent                    │ ERROR
smarthome.event.ThingRemovedEvent                  │ ERROR
smarthome.event.ThingStatusInfoEvent               │ ERROR

The persistence service does not seem to accept the Location datatype. I guess the reason being that this is a complex type.
One solution could be to create a new item

String StringLocation "This is a string representation of Lat,Lon"

create a rule to trigger whenever the Location item is changes and update the StringLocation


Then you of cause have to add persistence to the StringLocation item like

Items {

	StringLocation :  strategy = everyChange

The result will look like this… (not quite the same because this is MySQL)

mysql> select * from Item2;
| Time                | Value                                |
| 2017-12-28 19:50:50 | XX.92478418169536, XX.94092578628188  |
| 2017-12-28 19:52:55 | XX.92460820363827, XX.940852612267193 |
| 2017-12-28 19:55:04 | XX.92429610347368, XX.941108847047147 |
| 2017-12-28 19:57:09 | XX.9244721653498, XX.940767787407097  |

1 Like

No, i had a look into the sources and found getters/setters for PointType and LocationItem

It should be


Anyone know of any persistence that stores pointTypes? I have not been able to find one.

Interesting… ! did you see the same for MySQL?

I had the same issue (locations not persisted) with MySQL and thus changed to InfluxDB, to no avail. I also thought of the workaround with an additional string, but according to the sources I understand InfluxDB should be able to store locations, thus this might be a bug of the InfluxDB persistence addon ?

No, thats what the sources say

 * Item-Type Data-Type MySQL-Type
 * ========= ========= ==========
 * ColorItem HSBType CHAR(25)
 * ContactItem OnOffType CHAR(6)
 * DateTimeItem DateTimeType DATETIME
 * DimmerItem PercentType TINYINT
 * NumberItem DecimalType DOUBLE
 * RollershutterItem PercentType TINYINT
 * StringItem StringType VARCHAR(20000)
 * SwitchItem OnOffType CHAR(3)