Persistence for door/window sensor

Hi guys!
I’d like to use persistence with a door sensor (for other items it’s working) but I don’t know how to set this up…
I’m using mysql persistence.
I tried with 2 item definition like this:

Number Door_Sensor "Door [%d]"


Switch Door_Sensor "Door [MAP(]"

I also have a chart:

Chart item=Door_Sensor period=12h refresh=30000 

in mysql.persist I have:

Door_Sensor : strategy = everyChange, restoreOnStartup

The chart doesn’t display anything…
How to set up correctly the items?

Hi, this topic help me

Thanks, but I did say for other items persistence is working.
I have charts for temperature that are displaying just fine.

I use groups for that:

Group gDoors
Number Door_Sensor "Door [%d]" (gDoors)

and in .persist file:

gDoors* : strategy =  everyChange, restoreOnStartup

But some times when you change type of item from number to string, mysql do not change it.
I have to manualy delete it from DB, or try give item another name.

Well, I figured it out…
I defined the door/window as number and the chart works.
Not at first, because I kept changing the item definition between switch, string and number and the mysql table was holding a mix of ‘ON’/‘OFF’/0/1, but I cleared the table corresponding to my item and everything work properly.

Yeah. Sorry, I missed this thread. Charts in OH2 can’t display SWITCH or CONTACT anymore (as they do not translate ON/OFF to 0/1 anymore like OH1 did).

So you need to have a numeric item type to get the chart displayed.