Contacts - how do you use them?

I’m trying to use a contact but I can’t figure out how to actually use them.

With a switch I set it to ON or OFF, but with a contact I’ve tried OPEN, Open, open, ON, 1 and none work!

Any clues?



Are you trying to read a contact? What binding are you using?

I’m adding a contact as an item. I want to update it using a message queue (I’m having other issues with them) for now I’m just trying to update the contacts status using the rest api.

OPEN and CLOSED should work for contacts. That is what I send (the String) over MQTT to my contact Items from my sensors and it works like a charm.

Got it, use OPEN / CLOSED

I’m publishing the message “OPEN” and I get > given command is NULL, couldn’t post command to ‘Front_Door’

My item looks like this:

Contact Front_Door “Front Door [MAP(]” { mqtt="<[localbroker:/Door Switch/Front Door:command:default]"}

Also If I call it from the rest api I get this error:

Received unknown command ‘OPEN’ for item ‘Front_Door’

I’m calling the API like this:

It looks right to me. Not sure what is going on. Here is a working one of my Contacts for comparison.

Contact N_D_Front "Front Door [MAP(]" <frontdoor> (gDoorSensors, gRemindDoorSensors, gAlarmSensors, gHydraSensors) { mqtt="<[mosquitto:entry_sensors/main/front_door:state:default]" }

The only difference I see is I’m using “state” instead of “command”.

Odd, changing it to state gave this error:

2016-01-16 18:51:48.853 [ERROR] [.p.m.i.MysqlPersistenceService] - mySQL: Could not store item ‘Front_Door’ in database with statement ‘INSERT INTO Item54 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;’: Data truncation: Data too long for column ‘Value’ at row 1

OK, using state instead of command it works, however I still can’t use the rest API, and I’m getting that odd sql error.

Also introducing mapping and it just doesn’t work at all (but this is the same issue I’m getting in the other thread I started)

Sounds like something is hosed with your persistence set up.

Can you

mysql> show create table Item54;

and see how it was defined? (The theory being that you had Front_Door as a different kind of item, persisted some states, and then changed the item to Contact.)

the value was only 3, so I dropped the table, and re-created it as 6. Working great now :slight_smile:

1 Like