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
org.apache.karaf.shell.support │ 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
StringLocation.postUpdate(LocationItem.state.toString())
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 |
+---------------------+--------------------------------------+
No, i had a look into the sources and found getters/setters for PointType and LocationItem
It should be
org.openhab.persistence.influxdb
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)
The issue might be a difference in the two existing influxDB persistence services
conversions for org.openhab.persistence.influxdb
/**
* Converts {@link State} to objects fitting into influxdb values.
*
* @param state to be converted
* @return integer or double value for DecimalType, 0 or 1 for OnOffType and OpenClosedType,
* integer for DateTimeType, String for all others
*/
private Object stateToObject(State state) {
Object value;
if (state instanceof HSBType) {
value = ((HSBType) state).toString();
logger.debug("got HSBType value {}", value);
} else if (state instanceof PointType) {
value = point2String((PointType) state);
logger.debug("got PointType value {}", value);
} else if (state instanceof DecimalType) {
value = convertBigDecimalToNum(((DecimalType) state).toBigDecimal());
logger.debug("got DecimalType value {}", value);
} else if (state instanceof OnOffType) {
value = (OnOffType) state == OnOffType.ON ? 1 : 0;
logger.debug("got OnOffType value {}", value);
} else if (state instanceof OpenClosedType) {
value = (OpenClosedType) state == OpenClosedType.OPEN ? 1 : 0;
logger.debug("got OpenClosedType value {}", value);
} else if (state instanceof DateTimeType) {
value = ((DateTimeType) state).getCalendar().getTime().getTime();
logger.debug("got DateTimeType value {}", value);
} else {
value = state.toString();
logger.debug("got String value {}", value);
}
return value;
}
and for org.openhab.persistence.influxdb08
/**
* Converts {@link State} to objects fitting into influxdb values.
*
* @param state to be converted
* @return integer or double value for DecimalType,
* 0 or 1 for OnOffType and OpenClosedType,
* integer for DateTimeType,
* String for all others
*/
private Object stateToObject(State state) {
Object value;
if (state instanceof DecimalType) {
value = convertBigDecimalToNum(((DecimalType) state).toBigDecimal());
} else if (state instanceof OnOffType) {
value = (OnOffType) state == OnOffType.ON ? 1 : 0;
} else if (state instanceof OpenClosedType) {
value = (OpenClosedType) state == OpenClosedType.OPEN ? 1 : 0;
} else if (state instanceof HSBType) {
value = ((HSBType) state).toString();
} else if (state instanceof DateTimeType) {
value = ((DateTimeType) state).getCalendar().getTime().getTime();
} else {
value = state.toString();
}
return value;
}
Thanks very much @MartinKo !, but didn’t work either after trying it out now. One question in this line of code:
StringLocation.postUpdate(LocationItem.state.toString())
Is LocationItem a method or a typo and should it be StringLocation?
Is there something I could do to get it to work or should I wait for an update/fix?
Sorry for being unclear in the example… LocationItem is just a name of a Location item. Your LocationItem was IPhone7Plus_L ?
Then for you it will be
StringLocation.postUpdate(IPhone7Plus_L.state.toString())
StringLocation is just an item of type String with the name StringLocation
Oh! I see now. Thanks again @MartinKo for clarifying. The item name is IPhone7Plus_Location
I tried it now, but no luck I paste below the code converted to my system.
ITEM
String IPhone7Plus_LocString "iPhone Location String"
RULES
rule "iPhone"
when
Item IPhone7Plus_LocString changed
then
IPhone7Plus_LocString.postUpdate(IPhone7Plus_Location.state.toString())
end
PERSIST
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_LocString : strategy = everyChange, everyHour
ZWaveNode3FGWP102MeteredWallPlugSwitch_Switch : strategy = everyChange
}
Your RULES file never fires right… I think it should be
rule "iPhone"
when
Item IPhone7Plus_L changed
then
IPhone7Plus_LocString.postUpdate(IPhone7Plus_L.state.toString())
end
This way the item IPhone7Plus_LocString gets updated when the item IPhone7Plus_L gets updated
Thanks @MartinKo and that made the trick! At least now I can get this to persist. I learned a lot with this too.
I believe that you’re right, and given this I think that something should be fixed, but at least the workaround posted by @MartinKo seems to push to influxDB the location.
As I understand it, LocationItem is new in OH2/ESH. The persistence service, being an OH1 service, only supports OH1 items/types.
Hi, I got the following error on Mqsql, how can I solve it.
2020-11-21 14:36:04.052 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not create table for item ‘iPhone5_LocString’ with statement ‘CREATE TABLE Item4875 (Time DATETIME, Value VARCHAR(20000), PRIMARY KEY(Time));’: Column length too big for column ‘Value’ (max = 16383); use BLOB or TEXT instead
2020-11-21 14:36:04.054 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Item ‘iPhone5_LocString’ was not added to the table - removing index
2020-11-21 14:36:04.113 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item ‘iPhone5_LocString’ in database with statement ‘INSERT INTO Item4875 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;’: Table ‘OpenHAB.Item4875’ doesn’t exist
I’m sorry I don’t have a solution as it seems to be the way OpenHAB tries to create the table. It’s trying to make a column with the length on 20000 characters but MySQL is limited to 16383.
I don’t think there’s much you can do. Unless of course you create the table yourself.
You’d need to run ‘ CREATE TABLE Item4875 (Time DATETIME, Value VARCHAR(16383), PRIMARY KEY(Time));’ into MySQL.
I tried but it didn’t work