Store Homematic Door Contacs in InFlux DB

Hi,
actually im using to store the state of a door in an influx DB.
Because the Homematic Door Contact is usingthe enum OPEN and CLOSED which is not storable in the Database.
I´ve read in the forum that you can convert by using a rule:

val WohnzimmertuereDB = if(StateDoorWohnzimmer == OPEN) 1 else 0

but this don´t works, i tested to ebbed into a whole rule:

rule "WonzimmertuereKonvertieren"
    when
    Item StateDoorWohnzimmer changed from CLOSED to OPEN
    then
    val WohnzimmertuereDB = if(StateDoorWohnzimmer == OPEN) 1 else 0
end

i really need a working solution, because it is very important to show the door states of my house because of security reasons.

Thanks!!

You didn’t read closely enough.

WohnzimmertuereDB.postUpdate(if(StateDoorWohnzimmer.state == OPEN) 1 else 0)

Thank you very much for your help, actually i´m migrating my very complex Smarthome (Wago, Homematic, MQTT, Tradfri and Hue) from IP-Syncom to Openhab2 and this is sometimes a really frustrating job.