[SOLVED] Rule error field type conflict: input field \"value\" on measurement is type string, already exists as type float

Hello Community,

I switched from xiaomi binding to zigbee2mqtt.
Now there is a change of the value i get back from the xiaomi motion sensor, with the binding I get the value ON or OFF, and with the zigbee2mqtt i get the value true ore false.

Now i get an error by a rule i had before, but the rule is working.
i get the following error:

2018-06-28 06:56:16.707 [vent.ItemStateChangedEvent] - Motion_FF_Bed changed from false to true
java.lang.RuntimeException: {"error":"partial write: field type conflict: input field \"value\" on measurement \"Motion_FF_Bed\" is type string, already exists as type float dropped=1"}

and this is my rule (is changed to work with true and false):

var Timer timer = null
rule "Licht Schlafzimmer bei Bewegung Einschalten"
when
    Item Motion_FF_Bed changed to "true"
then
       if(timer === null && flagItemsunset.state == ON)  {
        logInfo("FILE", "Setting to ON and creating timer")
        Light_FF_Bed_Ceiling.sendCommand(ON)
        timer = createTimer(now.plusMinutes(2), [|
            logInfo("FILE", "Timer expired and setting to OFF")
            Motion_FF_Bed.postUpdate("false")
            Light_FF_Bed_Ceiling.sendCommand(OFF)
            timer = null
        ])
    } else {
        logInfo("FILE", "Timer rescheduled")
        timer.reschedule(now.plusMinutes(2))
        
    }
end

that was the previous rule :

var Timer timer = null
rule "Licht Schlafzimmer bei Bewegung Einschalten"
when
    Item Motion_FF_Bed received update ON
then
       if(timer === null && flagItemsunset.state == ON)  {
        logInfo("FILE", "Setting to ON and creating timer")
        Light_FF_Bed_Ceiling.sendCommand(ON)
        timer = createTimer(now.plusMinutes(2), [|
            logInfo("FILE", "Timer expired and setting to OFF")
            Motion_FF_Bed.postUpdate(OFF)
            Light_FF_Bed_Ceiling.sendCommand(OFF)
            timer = null
        ])
    } else {
        logInfo("FILE", "Timer rescheduled")
        timer.reschedule(now.plusMinutes(2))
        
    }
end

With the On and OFF value i never had these error.

What item-type is Motion_FF_Bed ?
Try

Item Motion_FF_Bed changed to true
...
Motion_FF_Bed.postUpdate(false)

This is to do with persistence.
OH is trying to save the state to the DB as a string but the DB field is set to as float
Access your DB and change the type of the field or remove the table for that item and OH will recreate it with a string field.

1 Like

it is a string item

Maybe in OH but not in your DB

I checked and your definition with “true” works, if it is a string.
What OH-version do you use?
Restart OH.

i have installed version 2.3
I have delete the field with

drop measeurement Motion_FF_Bed

i have the same error after the drop measeurement itemname.
i have no experience with influxdb
can anyone help me which commands I have to enter?

now i get more details about the error:

2018-06-28 17:10:22.873 [vent.ItemStateChangedEvent] - Motion_FF_Bed changed from false to true

==> /var/log/openhab2/openhab.log <==

2018-06-28 17:10:22.896 [INFO ] [.eclipse.smarthome.model.script.FILE] - Timer rescheduled

2018-06-28 17:10:22.908 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Licht Schlafzimmer bei Bewegung Einschalten': cannot invoke method public abstract boolean org.eclipse.smarthome.model.script.actions.Timer.reschedule(org.joda.time.base.AbstractInstant) on null

2018-06-28 17:10:22.972 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost

java.lang.RuntimeException: {"error":"partial write: field type conflict: input field \"value\" on measurement \"Motion_FF_Bed\" is type string, already exists as type float dropped=1"}

	at org.influxdb.impl.InfluxDBErrorHandler.handleError(InfluxDBErrorHandler.java:19) [232:org.openhab.persistence.influxdb:1.12.0]

	at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) [232:org.openhab.persistence.influxdb:1.12.0]

	at org.influxdb.impl.$Proxy168.writePoints(Unknown Source) [232:org.openhab.persistence.influxdb:1.12.0]

	at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:151) [232:org.openhab.persistence.influxdb:1.12.0]

	at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:171) [232:org.openhab.persistence.influxdb:1.12.0]

	at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:144) [232:org.openhab.persistence.influxdb:1.12.0]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

I had exactly the same problem. As far as I can see, you have to drop the measurement and additionally the series:

drop measurement my_item
drop series from my_item

This solved the issue for me.
After this openhab created the item again in influxdb and this time

show field keys from my_item

tells me, that the fieldType is flow.

6 Likes

This worked for me after searching through all of my config without success.

Thanks for posting.
Another win for the OH community.

1 Like

problem was solved after reinstallation of openhab.

I have also messed around with different item types and would like to drop all data from my influxDB openhab_db database (without deleting the openhab_db database itself).
How to expand your drop statement above to all measurements and all series?