[SOLVED] QH2 Console: what to send to a contact?

I tried to close a contact via the console…
… none of these worked…

openhab> smarthome:status Door_Shed_Tower_Roller_East
NULL
openhab> smarthome:send Door_Shed_Tower_Roller_East Closed
Error: Command 'Closed' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East CLOSED
Error: Command 'CLOSED' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East OFF
Error: Command 'OFF' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East 0
Error: Command '0' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East closed
Error: Command 'closed' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East 1
Error: Command '1' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East off
Error: Command 'off' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH
openhab> smarthome:send Door_Shed_Tower_Roller_East Off
Error: Command 'Off' is not valid for item 'Door_Shed_Tower_Roller_East'
Valid command types are:
  RefreshType: REFRESH

the contact is defined as follows (and worked in OH v1):

Contact Door_Shed_Tower_Roller_East		"Roller Door East [MAP(en.map):%s]"		<door>		(gShed_Tower, gShedDoors)			{mqtt="<[mymosquitto:ArgyleCourt/Shed/Tower/Rollerdoor/East:state:default]"}

What are you trying to achieve exactly? A contact is a read only item, so not something that you can set:

I set up a new system.
It has contacts which are undefined; I want to reset these to closed.

Sending a command via MQTT works:

mosquitto_pub -t ArgyleCourt/Shed/Tower/Rollerdoor/East -m "CLOSED"

2018-12-29 21:09:38.762 [vent.ItemStateChangedEvent] - Door_Shed_Tower_Roller_East changed from NULL to CLOSED

A contact: Status of contacts, e.g. door/window contacts. Does not accept commands, only status updates.

So how do set these contacts to closed based on a rule?

You can’t, they only represent the current state of a device or a property of that device. So for example, you would use a contact for a door sensor, which you can not change via a command. The only way to change the state of a contact is by doing something in the physical world, so opening or closing a door, which is then registered by the sensor, and the status is updated as such.
If the device is something that you can actively control, you should use a Switch, not a Contact.

Try „smarthome:update“ from the console or „postUpdate“ from rules.

You cannot send a command to a CONTACT item only update

1 Like

You cannot send a command, as they point out.

You can update the Item in a rule

rule "initialise"
when
   System started
then
   myContactItem.postUpdate(OPEN)
end

There may be good reasons to do that. Perhaps it’s a virtual Item, with no real binding. Perhaps a real device only reports changes, so you want it initialized at some known state at system startup. Etc.

Commands and updates are different things.
Commands sent to an Item get passed to any bindings. Commands need not change the state of that Item immediately, or indeed at all.
Updates change the state but do not get passed to bindings.

Contact type Items are unusual in that they have no “output” function, no purpose in passing commands to bindings, by design.

1 Like