my journey in OH3 continues…
I have my homemade MQTT contact sensor (Homie 3.0.0) and I want to include in OH.
The MQTT side works perfectly when opening/closing the window
openhabian@openhabHost:~ $ mosquitto_sub -v -u openhabian -P <password> -t homie/esp_gateway/guestRoomWindowSensor/#
homie/esp_gateway/guestRoomWindowSensor/$name Guest Room Window Sensor
I went on in the UI and created an Equipment from Thing, linking the two relevant channels during the creation phase
You can immediately see, that while the battery is immediately recognized and value assigned (4.15 V), the Status is in an UNDEF state. Below the point definition
The result does not change if I try to use a MAP transformation.
The “funniest” thing - filtering the log file for this particular points, I can find only this
2021-01-21 21:10:44.170 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'espgatewayWindowSensorGuestRoom_GuestRoomWindowSensor_Battery' changed from NULL to 4.15
So, no trace of the battery item.
What is the next debug step I can take? Or is my mistake clear to everyone but me?
Can you show the Channel definition that’s linked to the Contact Item?
Isn’t that exactly the battery Item in your log?
Apologize, I meant the status item, of course.
Below the link definition
Can you show the Channel definition? The Thing Channel definition?
Below the Thing definition and the relevant channels. FYI, it is a Arduino based system (self-programmed) with a single micro-controller acting a gateway for all sensors and communicating with the MQTT broker (publishing channels, sending updates).
Can you spot anything?
Can you click Configure Channel for your Status Channel and show the configuration?
Or just click the Code tab and copy/paste the YAML!
I slowly see where you are getting at Perhaps cannot it taken as boolean?
Below the screenshot - is it normal I cannot see the code? The tab is empty - does it need some time to be generated?
Yeah, that’s what I was suspecting, as you’re sending
OFF. I don’t use the Homie convention, so don’t quite recognise this configuration page. What options have you got for
Data Type? Is this all the page shows, or are there more options?
Or, I guess, change your code to send 1/0 or true/false?
There are the usual options
I quickly tried String w/o success.
Ok,. I am getting there…
The point is actually defined as switch - if I change to switch I can see ON/OFF.
But I guess I can go to the source of the problem and reprogram the gateway to define the sensor as a contact - as it has to be
Give me another 5 minutes
Actually I am sure there are a couple of guys around in the community who are rolling their eyes and laughing like mad
I found this post and I understood the whole issue
- Contact accepts OPEN and CLOSED states only - ON/OFF are related to switch type
- Actually homie specs define only true/false as valid payloads
- BUT, since I am the owner and master of my sensors I just reprogrammed the gateway to send OPEN and CLOSED, violating the specs but avoiding the issue @rossko57 described (channel transformation maps to a string and makes the value unusable for Contacts)
Everything seems to work now!
thanks for your online support
That issue should now be fixed in OH3 - a transform profile still yields strings but any type Item will (try to) parse it into something suitable for the Item state. So a transform profile yielding “OPEN” should work with a Contact type Item.