[SOLVED] Do not write in a MySQL database

Hello,

I want to install a mysql database and write all value from the sensors in this database.
So I have running step-by-step this instructions: openHAB2 & MySQL persistence setup

But no values are stored in the database.
The mysql.persist is:

Strategies {
        JedeMinute: "0 * * * * ?"
}
Items {
        eg_bz_temperatur: strategy = JedeMinute, restoreOnStartup
}

The mysql.cfg

url=jdbc:mysql://localhost:3306/OpenHAB
user=openhab
password=openhab
waitTimeout=100
localtime=true

MySQL DB is running. I can connect and I see a table named “Items”, but this table is empty.

Does anyone have an idea of what the mistake is?
Thanky you!
Michael

Can you show your items definition file?
There should be a group definition
And an Item definition using that group like

Group eg_bz_temperatur

Number EG_Temperatur "Erdgeschosstemperatur [%.1f °C]"  <temperature>  (eg_bz_temperatur)

All item which are members of the group will then be stored in the database.

Hello,

here my items file:

Group gEG
Group gOG
Group gGarten
Group gAllg

Number allg_temperatur “Karin Temperatur” <temperature> (gAllg) [“Karin Temperatur”] {channel=“yahooweather:weather:2293e072:temperature”}

//Badezimmer
Number eg_bz_temperatur “Temperatur” <temperature> (gEG) [“EG Badezimmer Temperatur”] {channel=“mihome:sensor_weather_v1:158d0002374d63:temperature”}
Number eg_bz_relfeuchtigkeit “rel. Luftfeuchtigkeit” <humidity> (gEG) [“EG Badezimmer rel. Luftfeuchtigkeit”] {channel=“mihome:sensor_weather_v1:158d0002374d63:humidity”}
Contact eg_bz_tuer “Tür[%s]” <door-open> (gEG) [“EG Badezimmer Tür”] {channel=“mihome:sensor_magnet_aq2:158d000208e206:isOpen”}

//Vorzimmer
Number eg_vz_temperatur “Temperatur” <temperature> {channel=“zway:zwayDevice:192_168_178_23:4:sensorTemperature-ZWayVDev_zway_4-0-49-1”}
Number eg_vz_relfeuchtigkeit “rel. Luftfeuchtigkeit” <humidity> (gEG) [“EG Vorzimmer rel. Luftfeuchtigkeit”] {channel=“zway:zwayDevice:192_168_178_23:4:sensorHumidity-ZWayVDev_zway_4-0-49-5”}
Number eg_vz_lichtstaerke “Lichtstärke [%.2f Lux]” <light> (gEG) [“EG Vorzimmer rel. Luftfeuchtigkeit”] {channel=“zway:zwayDevice:192_168_178_23:4:sensorLuminosity-ZWayVDev_zway_4-0-49-3”}
Number eg_vz_uvindex “UV Index” <sun> (gEG) [“EG Vorzimmer UV Index”] {channel=“zway:zwayDevice:192_168_178_23:4:sensorUltraviolet-ZWayVDev_zway_4-0-49-27”}
Switch eg_vz_bewegung “Bewegung” <motion> (gEG) [“EG Vorzimmer Bewegung”] {channel=“zway:zwayDevice:192_168_178_23:4:sensorMotion-ZWayVDev_zway_4-0-48-1”}

Thank you!

I seem to recall something about having a default strategy defined in xxx.persist, even if you don’t use it?

1 Like

Did you specify in paperUI the service you will use by default?

I have the following definitions:

Itemfile:

//General groups
Group Temperature
Group gHeizung

Number HzgAussenTemp "Aussentemperatur Heizung [%.1f °C]" <temperature>  (Temperature, gHeizung)

Persistence File

Strategies {
    everyMinute   : "0 * * * * ?"
    every5Minutes : "*/5 * * * * ?"
    everyHour     : "0 0 * * * ?"
    everyDay      : "0 0 0 * * ?"
}

Items {
    Temperature*    : strategy = everyChange, every5Minutes
}

I am not sure if the persistence works with an item directly, so you should try it using a group.

I am using influxdb as database, which seems to me a better choice.

Hello,

now I have added the “default strategy” and now it works with MySQL!

Thank you!