Window contact status does not show at BASIC UI

Guys,
I need configuration help before my head explodes.

I would like to display status of windows and doors in the OH2 system - open/closed plus an icon for totally 8 of windows - nothing more.
For this purpose, at the flat construction stage installed each window/door reed contacts and their wires led to one place from which I would like to read and forward state of them to OH2.
From what I see (at least searching tool said that), none of you have played on reed contacts that way and only use wireless sensors.
Digging in the subject found that “D1 mini” has 11GPIO`s so even more than needed.
Bought one, flashed with Tasmota and setup for 8 switches like below:
D3 GPIO0 Switch3 (11)
TX GPIO1 SI7021(3)
D4 GPIO2 Switch4 (12)
D2 GPIO4 Switch2 (10)
D1 GPIO5 Switch1 (9)
D6 GPIO12 Switch6 (14)
D7 GPIO13 Switch7 (15)
D5 GPIO14 Switch5 (13)
D8 GPIO15 Switch8 (16)
which after sending by MQTT gives me the expected result:
{“Time”:“2019-06-02T10:11:09”,“Switch1”:“ON”,“Switch2”:“ON”,“Switch3”:“ON”,“Switch4”:“ON”,“Switch5”:“ON”,“Switch6”:“ON”,“Switch7”:“ON”,“Switch8”:“OFF”,“SI7021”:{“Temperature”:null,“Humidity”:null},“TempUnit”:“C”}

After using transformation JSONPATH:$.Switch1 have theoretically read of ON/OFF Switch1 value but can not translate this result into the correct display in BASIC UI.

items code:
Contact Status_Door5 “Status Door 5” {channel=“mqtt:topic:5d6b44af:d1_ok5”}

sitemap code:
Text item=Status_Door5 label="[MAP(en.map):%s]" icon=“door”

transform:
CLOSED=closed
OPEN=open
NULL=unknown
ON=open
OFF=closed

Can you hint where to find the source of the problem?
Feel that I am really close :slight_smile:

1 Like

You probably want to look into openhab.log and events.log at first, in order to see what is and what is not happening from openHABs point of view.

If your Items are receiving updates, we’d probably want to see what those are, what you see instead on your UI.

Hi guys,
Little update after while. Battle almost finished so please support if possible:

Json transformation not changed since last post.
within Paper UI > things > Generic MQTT thing > changed Channel type from “Open/Close contact” to “Text Value”

items now:
String Status_Door1 “Status Door 1” {channel=“mqtt:topic:6ee09f16:d1_d11”}

sitemap now:
Default item=Status_Door1 label=“Door 1 [%s]” icon=“door”

So at the moment, I do have doors status (text “ON” or “OFF”) visible on Basic UI
BUT
1)once D1mini transmission stopped status still shows last position of reed contacts. How to refresh that?
2)icon - isit possible to display different icon for open and closed ?
3)might be something wrong with settings as it shows in log below, not sure what

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

2019-06-11 16:37:58.891 [WARN ] [eneric.internal.generic.ChannelState] - Command ‘OFF’ not supported by type ‘OpenCloseValue’: No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.OFF

I’m interpreting that as meaning “I want a dead box to send me a message that it is dead” :grinning:
Obviously that can’t happen, but if you expect regular updates from a device you can detect when they stop. Look into expire binding, written for the purpose.
openHAB allows an Item state of UNDEF which is ideal to indicate “don’t know state because communication was lost”.

Yes, dynamic icons it’s called in the docs.

Somewhere, you have a rule or UI click or binding channel that is sending command OFF to a Contact type Item, which isn’t allowed.

A Contact type Item will only accept updates to OPEN CLOSED or UNDEF. It will not accept any commands.
You seem to have incoming data from GPIO in the form ON or OFF, so that won’t fit.

Putting a MAP in the label of an Item only transforms between the Item state and your display UI. It doesn’t change the Item state.

A more useful place to do the transform in this case is in the channel, so that incoming OFF gets pushed to the Item as CLOSED for example. That’d be transformationPattern in your Thing 
 but you’re already using that for JSONPATH so you are goosed I think.

You could change your channel types in the generic mqtt thing to contact channels which have the option for custom on/open off/closed values which can be used together with the jsonpath transformation. Than you could link them to items of type contact. If you use those with text items it will show the right state as the item.
Johannes

The channels of the generic mqtt things at least in 2.5 m1 support chained transformations.
Johannes

1 Like

Thats it, expired bindings I was looking for :slight_smile:

About dynamic icon have to read last. After all configuration nicely done.

Could you explain a bit of transformation within channel? Is it by map file? Tried below without success

JSONPATH:$.Switch1[MAP(en.map):%s]

JGKK: will try switching types of channell tommorow - thx

Hi Stonke,
any updates with this issue please
 ran into same trouble, sonoff flashed with tasmota and gpio14 set for reed switch door sensor, change switchtopic2 to frontdoor
 and item in openhab is Contact type, but MQTT payload for door is ON and OFF
 how to change to OPEN and CLOSE
many thanks


My sensors report 1 for OPEN and 0 for CLOSED

In your thing configuration
Change the custom values to ON and OFF

1 Like

What version OH are you running? Mine doesnt have options like “Custom on/open or off/closed value”.

BTW anyone done transformation within channel that rossko57 mentioned above? Cant find anything.

Cheers

The JSONPATH that you are already using in your channel is one type of ‘transformation’.
What are you trying to find?