Influxdb - store item value by rule without row in influxdb.persist file

Is it possible with Influxdb persistence to write in a triggered archive (database) please ?

From automation jobs in Scada software they are three types of archives:

  1. Time periodically storage =openhab influxdb persistence with cron
  2. On value change = openhab on change
  3. Triggered write to database ( no equivalent ???)

So my idea is to write some python3 script with from influxdb python module and InfluxDBClient.
Maybe a question to Influxdb forum ?
Or wish to developer from Influxdb persistence ?

Thanks for ideas.

Openhab2-last version, Rpi4

I don’t know what that means.
If it’s something like “persist on demand”, yes.

In a rule, run under whatever conditions you like,

None is needed at all. An Item persisted on demand need not have any other routine strategy or be mentioned in any xxx.persist file.

As you note, the default strategy exists and will operate if you don’t stop it.
There is no way to configure exceptions to the default.
So you have to throw the default out altogether, and instead have a manual xxx.persist configuration.

This is a good opportunity to review what you really want to persist, and when, and what to restore The default is generally persisting rubbish that you don’t need at the cost of system performance, while restore makes for lazy rule writing that does not handle exceptions.

But you said you’re on OH2 where is there is no service default, so you are already using xxx.persist files.

There is no service default in OH2, except as you might have defined it by use of *

There are two parts to a xxx.persist file

Strategies {
  <strategyName1> : "cronexpression1"
  <strategyName2> : "cronexpression2"
  default = everyChange
Items {
    <itemlist1> [-> "<alias1>"] : [strategy = <strategy1>, <strategy2>, ...]
    <itemlist2> [-> "<alias2>"] : [strategy = <strategyX>, <strategyY>, ...]


So this -

does not fit in that structure.

default = ...
belongs in Stategies { } , and would define “what to do”

Sonoff_POW2_Power : strategy = everyMinute, everyUpdate
belongs in Items { } and defines “who to do it with”

Sonoff_POW2_Energy :
is not valid if you have commented out your default strategy.
I think if you actually wanted default here, the syntax requires you to omit the : as well.

But I thought you wanted to persist your Item (Sonoff_POW2_Energy ?) only by rule ?
To do that, do not include it in your xxx.persist file at all.
(and make sure it is not a member of any groups that you persist, or that you are not using * for 'everything")

Hi Rossko,
all clean, deleted Energy item from influxdb.persist.
Item is written to database only with rule.
This is the solution, thanks for your time.

But Pow2 sets energy to zero after primary power failure.
My approach to summarize energy is unusable :0)

Technical clean solution is using a energy meter with Modbus TCP or RTU communication and pooling it by modbus binding or python script.

1 Like