I have an existing generic MQTT bridge thing for my Door reed switch which currently returns OPEN/CLOSED on my Door1_state
I would like to migrate this to Tasmota which returns ON/OFF for this sensor, but to reduce some of the automation changes is it possible to transform this channel from ON=CLOSED to OFF=OPEN
I have seen a “CUSTOM ON/OFF value” mentioned in the OpenHab UI but how do I code this in my thing file ??
**DOOR.thing**
Bridge mqtt:broker:mqttbroker "Mosquitto" [ host="localhost", port=1883, secure=false, clientID="openhab" ]
{
Thing topic garage1 "sensor ESP32" @ "Garage"
{
Channels:
Type string : status "ESP32 status" [stateTopic="device/garagehw/LWT" ]
Type switch : Door1_switch "Garage Door1" [commandTopic="cmd/garagehw/RELAY1", on="SWITCH", off="SWITCH" ]
Type contact : Door1_state "Garage state Door1" [stateTopic="status/garagehw/SWITCH1" ]
Are you saying there is no custom mapping I can use for a type Contact
Type contact : Door1_state "Garage state Door1" [stateTopic="status/garagehw/SWITCH1" ]
ideally I can use something like CustomClose=“ON” CustomOpen=“OFF”
or something list this not sure if you can chain multiple transform patterns ??
Type contact : Door1_state "Garage state Door1" [stateTopic="tele/garage/SENSOR"
transformationPattern="JSONPATH:$.Door" transformationPattern="MAP:tasmota-switch.map"]
There is an on and off property for switch and contact Channels.
When using .things files always refer to the docs first. Alternatively you can create the Thing in the UI and look at the code tab. The fields have the same names in the UI and the files.
I’ve created a Thing using UI with two two channels one using Contact and the other a String
I see the String being populated with ON/OFF but nothing for the Contact
Ideally I would like to have contact OPEN=ON and OFF=CLOSE but perhaps I’m missing something
Is this even possible ie to map/transform channel data to item
ie transform ON->OPEN
channels:
- id: testdoor1
channelTypeUID: mqtt:contact
label: test door 1
description: mqtt tasmota test door1
configuration:
stateTopic: tele/mygarage/SENSOR
off: OFF
on: ON
- id: testdoor1a
channelTypeUID: mqtt:string
label: testdoor1a
description: ""
configuration:
stateTopic: tele/mygarage/SENSOR