[SOLVED] Using multiple persistence services

persistance
Tags: #<Tag:0x00007f0146b39400>

(Mark) #1

Hi, I am using multiple persitance services and wanted to know if I am using them correctly in rules

The persistance services I have set up:

  • influxdb… for Grafana charts
  • mapdb… for restore on startup of important switches
  • rrd4j… for computing average values of some items eg pressure sensor

In PaperUI System>Persistance default service I have mapdb set.

They all seem to be working except for an error in a rule where I have specified the service to use. I did it like this

AveragePressureChange.postUpdate(PressureChange.averageSince(now.minusMinutes(30),"rrd4j"))

Visual Studio code shows an error:

Ambiguous feature call.
The extension methods
postUpdate(Item, State) in BusEvent and
postUpdate(Item, Number) in BusEvent
both match.

Is the above line of code the correct way to specify the persistance service to be used?

Also, the default service is set to be mapdb. In what situations is this setting used? It seems I needed it for mapdb and rrd4j in order for one of them to work. The one not set there then has to be specified in the code as above. Influx seems quite happy without being specified anywhere.

Thanks Mark.


(Vincent Regaud) #2

I would set it to influx or rrd4j, not that it matters very much but mapdb is VERY limited as it only stores the last value.

It’s a warning from VS code telling you that there are several ways to call that method.
You can try to “force” it by doing:

AveragePressureChange.postUpdate(PressureChange.averageSince(now.minusMinutes(30),"rrd4j") as Number)


(Mark) #3

Thanks for the fast responce.

That indeed fixed it. The OCD voice in my head is now satisfied.:slight_smile:

I mainly use influx and it seems to work without being set as default.


(Vincent Regaud) #4

Good, please mark the thread as solved. Thanks