Rules and persistence error

Hello everyone, since my conversion from 2.5 to 3.0, some of my rules no longer work at all. I use these rules to enter the last date that an event occurred and to display it. For 3 days I have been looking in the community and elsewhere to find changes to make since the rules now use JavaTime instead of JODAtime. I stumble all over the place, I tried with the example which illustrates the 12 ways to convert dates but nothing helps. It seems that there is more than one problem because when I succeed in transforming the date I also get messages from INFLUX to tell me that it cannot save this date in an item. I am attaching one of the rules in question in the hope that someone can help me continue.
Rule =

```php
       rule "Member of gPir changed"
when
    Member of gPir changed
then
	var pir = (triggeringItem.label)
	if(previousState == NULL) return;
	postUpdate(triggeringItem.name+"Dtt", now.toString)
end


and log

2021-02-14 15:29:55.801 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘presence.rules’
2021-02-14 15:30:07.519 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘0’ of rule ‘tempHumi-1’ is triggered.
2021-02-14 15:30:07.522 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert ‘2021-02-14T15:30:07.522156-05:00[America/Montreal]’ to a state type which item ‘TempExtCarDtt’ accepts: [DateTimeType, UnDefType].
2021-02-14 15:30:07.523 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘tempHumi-1’ is executed.
2021-02-14 15:30:17.241 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘0’ of rule ‘lumie-14’ is triggered.
2021-02-14 15:30:17.241 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘2’ of rule ‘Dodo_enleve’ is triggered.
2021-02-14 15:30:17.241 [DEBUG] [le.handler.ItemStateConditionHandler] - ItemStateCondition '4’checking if Jour (State=ON) = ON
2021-02-14 15:30:17.241 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘0’ of rule ‘presence-6’ is triggered.
2021-02-14 15:30:17.241 [DEBUG] [le.handler.ItemStateConditionHandler] - ConditionSatisfied → true
2021-02-14 15:30:17.241 [DEBUG] [handler.ItemStateUpdateActionHandler] - Executing ItemStateEvent on Item ScenePres with State 2
2021-02-14 15:30:17.242 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘Dodo_enleve’ is executed.
2021-02-14 15:30:17.242 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language ‘application/vnd.openhab.dsl.rule’ with identifier: 655ea5e7-5a2e-4a63-9a86-aa3a371beed1
2021-02-14 15:30:17.242 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘lumie-14’ is executed.
2021-02-14 15:30:17.243 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert ‘2021-02-14T15:30:17.242922-05:00[America/Montreal]’ to a state type which item ‘dpbMOTfuaCavBurMurDtt’ accepts: [DateTimeType, UnDefType].
2021-02-14 15:30:17.244 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘presence-6’ is executed.
2021-02-14 15:30:17.409 [ERROR] [org.influxdb.impl.BatchProcessor ] - Batch could not be sent. Data will be lost
org.influxdb.InfluxDBException$FieldTypeConflictException: partial write: field type conflict: input field “value” on measurement “dpbMOTfuaCavBurMur” is type integer, already exists as type float dropped=1
at org.influxdb.InfluxDBException.buildExceptionFromErrorMessage(InfluxDBException.java:144) ~[bundleFile:?]
at org.influxdb.InfluxDBException.buildExceptionForErrorState(InfluxDBException.java:173) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:827) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:460) ~[bundleFile:?]
at org.influxdb.impl.OneShotBatchWriter.write(OneShotBatchWriter.java:22) ~[bundleFile:?]
at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:340) [bundleFile:?]
at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:287) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
2021-02-14 15:30:19.740 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘0’ of rule ‘presence-6’ is triggered.
2021-02-14 15:30:19.741 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert ‘2021-02-14T15:30:19.741199-05:00[America/Montreal]’ to a state type which item ‘dpbMOTfuaCavBurMurDtt’ accepts: [DateTimeType, UnDefType].
2021-02-14 15:30:19.744 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘presence-6’ is executed.
2021-02-14 15:30:19.888 [ERROR] [org.influxdb.impl.BatchProcessor ] - Batch could not be sent. Data will be lost
org.influxdb.InfluxDBException$FieldTypeConflictException: partial write: field type conflict: input field “value” on measurement “dpbMOTfuaCavBurMur” is type integer, already exists as type float dropped=1
at org.influxdb.InfluxDBException.buildExceptionFromErrorMessage(InfluxDBException.java:144) ~[bundleFile:?]
at org.influxdb.InfluxDBException.buildExceptionForErrorState(InfluxDBException.java:173) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:827) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:460) ~[bundleFile:?]
at org.influxdb.impl.OneShotBatchWriter.write(OneShotBatchWriter.java:22) ~[bundleFile:?]
at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:340) [bundleFile:?]
at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:287) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]


Many thanks at all, and congratulation for the hard work of everyone

[quote=“ax8814, post:1, topic:117060”]
2021-02-14 15:29:55.801 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘presence.rules’
2021-02-14 15:30:17.241 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘0’ of rule ‘presence-6’ is triggered.
2021-02-14 15:30:17.241 [DEBUG] [le.handler.ItemStateConditionHandler] - ConditionSatisfied → true
2021-02-14 15:30:17.242 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language ‘application/vnd.openhab.dsl.rule’ with identifier: 655ea5e7-5a2e-4a63-9a86-aa3a371beed1
2021-02-14 15:30:17.243 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert ‘2021-02-14T15:30:17.242922-05:00[America/Montreal]’ to a state type which item ‘dpbMOTfuaCavBurMurDtt’ accepts: [DateTimeType, UnDefType].
2021-02-14 15:30:17.244 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘presence-6’ is executed.
2021-02-14 15:30:17.409 [ERROR] [org.influxdb.impl.BatchProcessor ] - Batch could not be sent. Data will be lost
org.influxdb.InfluxDBException$FieldTypeConflictException: partial write: field type conflict: input field “value” on measurement “dpbMOTfuaCavBurMur” is type integer, already exists as type float dropped=1
at org.influxdb.InfluxDBException.buildExceptionFromErrorMessage(InfluxDBException.java:144) ~[bundleFile:?]
at org.influxdb.InfluxDBException.buildExceptionForErrorState(InfluxDBException.java:173) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:827) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:460) ~[bundleFile:?]
at org.influxdb.impl.OneShotBatchWriter.write(OneShotBatchWriter.java:22) ~[bundleFile:?]
at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:340) [bundleFile:?]
at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:287) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
2021-02-14 15:30:19.740 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘0’ of rule ‘presence-6’ is triggered.
2021-02-14 15:30:19.741 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert ‘2021-02-14T15:30:19.741199-05:00[America/Montreal]’ to a state type which item ‘dpbMOTfuaCavBurMurDtt’ accepts: [DateTimeType, UnDefType].
2021-02-14 15:30:19.744 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘presence-6’ is executed.
2021-02-14 15:30:19.888 [ERROR] [org.influxdb.impl.BatchProcessor ] - Batch could not be sent. Data will be lost
org.influxdb.InfluxDBException$FieldTypeConflictException: partial write: field type conflict: input field “value” on measurement “dpbMOTfuaCavBurMur” is type integer, already exists as type float dropped=1
at org.influxdb.InfluxDBException.buildExceptionFromErrorMessage(InfluxDBException.java:144) ~[bundleFile:?]
at org.influxdb.InfluxDBException.buildExceptionForErrorState(InfluxDBException.java:173) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:827) ~[bundleFile:?]
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:460) ~[bundleFile:?]
at org.influxdb.impl.OneShotBatchWriter.write(OneShotBatchWriter.java:22) ~[bundleFile:?]
at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:340) [bundleFile:?]
at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:287) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]

Use the 2 log it is clearer I removed everything that did not concern the rule - Presence-6

This WARN has nothing to do with influxdb, it’s the now.toString in the rule postUpdate that is not suitable for your (presumably DateTime type) Item.
now is a ZonedDateTime object in OH3, so we need to make that suitable for an Item.
I think this should do it

postUpdate(triggeringItem.name+"Dtt", DateTimeType.valueOf(now.toLocalDateTime().toString()) )

This seems to be about imported influxdb data from OH2 having changed type in OH3. See -

Thank you very much @rossko57 for your quick response, it seems to get me going a bit but the result is not yet conclusive since other error messages remain. I still attach a copy of my modified rule and a copy of the clean log.

```php
rule "Member of gPir changed"

when

    Member of gPir changed

then

//  var pir = (triggeringItem.label)

    var pir = ScriptServiceUtil.getItemRegistry.getItems(triggeringItem.label)

    if(previousState == NULL) return;

//  postUpdate(triggeringItem.name+"Dtt", now.toString)

    postUpdate(triggeringItem.name+"Dtt", DateTimeType.valueOf(now.toLocalDateTime().toString()) )

end
and the LOG
2021-02-14 20:12:05.008 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'presence-6' is executed.
2021-02-14 20:12:07.505 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger '0' of rule 'presence-6' is triggered.
2021-02-14 20:12:07.506 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'presence-6' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.postUpdate(java.lang.String,java.lang.String) on instance: null in presence
javax.script.ScriptException: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.postUpdate(java.lang.String,java.lang.String) on instance: null in presence
	at org.openhab.core.model.script.runtime.internal.engine.DSLScriptEngine.eval(DSLScriptEngine.java:127) ~[?:?]
	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:62) [bundleFile:?]
	at java.util.Optional.ifPresent(Optional.java:183) [?:?]
	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) [bundleFile:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1179) [bundleFile:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:987) [bundleFile:?]
	at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:89) [bundleFile:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2021-02-14 20:12:07.508 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'presence-6' is executed.

Good morning all. This morning I tried using the same logic however instead of dealing with a group member I made the same rule but for each member and it works. So it seems to me that the problem occurs when I try to get the rule executed for a group. At first I thought that this could be due because there was no date in the database and that was why I got the message ‘’ ‘Script execution of rule with UID’ tempHumi-1 'failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.postUpdate (java.lang.String, java.lang.String) on ​​instance: null in tempHumi ‘’ ’ . But after populating all the Dtt items in the database, I stopped the individual processing and resumed the group rule, the same error messages come back. So I am once again attaching a copy of the individual and group rules and also attaching the LOGs that relate to the individual rules and the LOGs for group processing. Since I am French speaking the texts in the rules are in French, but that shouldn’t be a problem. Thanks again for helping me.

Individual rules

rule "temp du bureau a change"
when 
	Item TempCavBur changed 
then 
	postUpdate(TempCavBurDtt, DateTimeType.valueOf(now.toLocalDateTime().toString()) )
end 

rule "temp du vestiaire a change"
when 
	Item TempCavVes changed 
then 
	postUpdate(TempCavVesDtt, DateTimeType.valueOf(now.toLocalDateTime().toString()) )
end 

rule "temp du carport a change"
when 
	Item TempExtCar changed 
then 
	postUpdate(TempExtCarDtt, DateTimeType.valueOf(now.toLocalDateTime().toString()) )
end 

And the LOG that goes with them when they are executed

2021-02-15 11:21:35.990 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger '0' of rule 'tempHumi-1' is triggered.
2021-02-15 11:21:35.991 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'application/vnd.openhab.dsl.rule' with identifier: 02d7c12e-ae04-4d11-a5a5-c784485ea43d
2021-02-15 11:21:35.992 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'tempHumi-1' is executed.

And the rule with group members

rule "Membres du groupe gTemp recoit changement"
when
    Member of gTemp changed
then
	var dht = (triggeringItem.label)
DateTimeType.valueOf(now.toLocalDateTime().toString()))
	postUpdate(triggeringItem.name+"Dtt", DateTimeType.valueOf(now.toLocalDateTime().toString()) )
end

And the LOG at execution time

2021-02-15 09:55:58.767 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger '0' of rule 'tempHumi-1' is triggered.
2021-02-15 09:55:58.767 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'application/vnd.openhab.dsl.rule' with identifier: e1003f4f-ed52-4ad8-9cea-ce1a042eb926
2021-02-15 09:55:58.768 [INFO ] [org.openhab.core.model.script.Test  ] - La valeur de trigeringitem.label est Dans le carport
2021-02-15 09:55:58.769 [INFO ] [org.openhab.core.model.script.Test  ] - triggeringItem.name'+''Dtt' est TempExtCarDtt
2021-02-15 09:55:58.770 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'tempHumi-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.postUpdate(java.lang.String,java.lang.String) on instance: null in tempHumi
javax.script.ScriptException: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.postUpdate(java.lang.String,java.lang.String) on instance: null in tempHumi
	at org.openhab.core.model.script.runtime.internal.engine.DSLScriptEngine.eval(DSLScriptEngine.java:127) ~[?:?]
	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:62) [bundleFile:?]
	at java.util.Optional.ifPresent(Optional.java:183) [?:?]
	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) [bundleFile:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1179) [bundleFile:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:987) [bundleFile:?]
	at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:89) [bundleFile:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2021-02-15 09:55:58.770 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'tempHumi-1' is executed.

In your individual rules, you give postUpdate an Item and a DateTime. Format
postUpdate(object,object)

In the group version, you give a name string and a DateTime. Format
postUpdate(string,object)
It doesn’t like that, which is what it is trying to tell you.

You’ll need to get the toString of your DateTime so as to have
postUpdate(string,string)

Thanks @rossko57 7, I’m having a hard time understanding the meaning of your answer. In the logic of the group rule, I look for the label of the item which triggered the rule and I ask to save the “MOMENT now.toString” in an item which has the same name with in addition “Dtt”. So my TempCavBur item contains the temperature in my office in the basement, and TempCavBurDtt contains the MOMENT or date and time of the last trigger. How could I do otherwise. In version 2.5x it worked very well for several years, but with version 3 I encountered several problems. Your solution of replacing now.toString with DateTimeType.valueOf (now.toLocalDateTime (). ToString ())) succeeded in removing several error messages and made individual rules work whereas before they did not work . However I have to say that I don’t know how to change the offending line in your second suggestion. Thank you for your precious support.

postUpdate() allows you to use it in two ways.
postUpdate(object, oblect)
or
postUpdate(string, string)

But you cannot use it like -
postUpdate(string, object)
and it will generate an error.

This is an object. It reduces to
DateTimeType.valueOf(xxx)

This is an object, an Item.

This fits the template
postUpdate(object, oblect)
and it works for you.

This is a string

This fits the template
postUpdate(string, object)
which is not allowed and it generates an error.

You can make your DateTime object into a string
postUpdate(triggeringItem.name+"Dtt", DateTimeType.valueOf(now.toLocalDateTime().toString()).toString )

Many thanks to @rossko57 , it is finaly working well.
I’m learning and for sure I will tried to understand why it is like that.
Do I have to do something to close that question… or the system will closed it if have no more REPLY

You can mark a post as a Solution.

I’m sure there must be a less long-winded way of writing “now” for a DateTime state, but what works will do.

I’m pretty sure that DateTimeType will accept a ZonedDateTime in its constructor.

postUpdate(triggeringItem.name+"Dtt", new DateTimeType(now).toString)

But even simpler, since we are using postUpdate and doing toString anyway

postUpdate(triggeringItem.name+"Dtt", now.toLocalDateTime.toString)