Hey Togetrher,
I tried to solve this by searching the community for one day now but didnt made it.
I want to store a Number value in rrd4j to get the previous state in my rules.
My rrd4j.persist
Strategies {
everyMinute : "0 * * * * ?"
}
Items {
Media_Aktion: strategy = everyChange, everyMinute
}
My Item:
Number Media_Aktion
My Rule:
rule "Medienauswahl"
when Item Media_Aktion received command
then switch Media_Aktion.state {
case 1: {//gVm.allMembers.forEach [ item | item.sendCommand(OFF)]
logInfo("TEST ", "Mediaaktionprev "+Media_Aktion.previousState(false,"rrd4j").state)
logInfo("TEST ", "Mediaaktion "+Media_Aktion.state)
}
case 2: {//Fernsehen.sendCommand(ON)
//Musik.postUpdate(OFF)
//Dvd.postUpdate(OFF)
logInfo("TEST ", "Mediaaktionprev "+Media_Aktion.previousState(false,"rrd4j").state)
logInfo("TEST ", "Mediaaktion "+Media_Aktion.state)
}
case 3: {//Musik.sendCommand(ON)
//Fernsehen.postUpdate(OFF)
//Dvd.postUpdate(OFF)
logInfo("TEST ", "Mediaaktionprev "+Media_Aktion.previousState(false,"rrd4j").state)
logInfo("TEST ", "Mediaaktion "+Media_Aktion.state)
}
case 4: {//Dvd.sendCommand(ON)
//Musik.postUpdate(OFF)
//Fernsehen.postUpdate(OFF)
logInfo("TEST ", "Mediaaktionprev "+Media_Aktion.previousState(false,"rrd4j").state)
logInfo("TEST ", "Mediaaktion "+Media_Aktion.state)
}
}
end
all the commands are // cause of testing.
The Value is set through an Selection in my Sitemap:
Selection item=Media_Aktion
mappings=[1="Aus", 2="Fernsehen", 3="Musik", 4="DVD"]
When I get the presistence values through RestApi:
{
"name": "Media_Aktion",
"datapoints": "1",
"data": [
{
"time": 1572604184212,
"state": "2"
}
]
}
there is only one Datapoint…I already deleted everything regarding to rrd4j and reinstalled it but dosn´t change everything.
Here the Log:
2019-11-01 11:29:36.732 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'Media_Aktion' with state '1' in rrd4j database
==> /var/log/openhab2/events.log <==
2019-11-01 11:29:36.737 [vent.ItemStateChangedEvent] - Media_Aktion changed from 3 to 1
==> /var/log/openhab2/openhab.log <==
2019-11-01 11:29:40.776 [INFO ] [eclipse.smarthome.model.script.TEST ] - Mediaaktionprev 1.0
2019-11-01 11:29:40.782 [INFO ] [eclipse.smarthome.model.script.TEST ] - Mediaaktion 1
The Value is also stored every minute, so this is working but only one Datapoint…
As you can see, the .state and .previousstate is the same,
I also tried it with my SQL and MapDb by the way with the same config…same result…
Here the Log from MapDB:
2019-11-01 11:49:41.725 [ome.event.ItemCommandEvent] - Item 'Media_Aktion' received command 3
==> /var/log/openhab2/openhab.log <==
2019-11-01 11:49:41.746 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for Media_Aktion
==> /var/log/openhab2/events.log <==
2019-11-01 11:49:41.756 [vent.ItemStateChangedEvent] - Media_Aktion changed from 1 to 3
==> /var/log/openhab2/openhab.log <==
2019-11-01 11:49:41.766 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'Media_Aktion' with state '3' in mapdb database
2019-11-01 11:49:41.773 [INFO ] [eclipse.smarthome.model.script.TEST ] - Mediaaktionprev 3
2019-11-01 11:49:41.784 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for Media_Aktion
2019-11-01 11:49:41.791 [INFO ] [eclipse.smarthome.model.script.TEST ] - Mediaaktion 3
2019-11-01 11:49:41.792 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'Media_Aktion' with state '3' in mapdb database
Anybody any Idea, i want to prevent setting u a new setup cause of some stupid error i made.
As mentioned, always only one datapoint is created
Greetings and many thanks in advantage
Andy