Using PROFILE with ITEM

Hello I would like to solve a problem that I have had since using openHAB, which is about 4 years. I am using version 3.2.0 on a computer with the latest version of Linux. I also use several ESP8266 chip with different sensors, DHT22, PIR, Hall effect sensor … Each chip is programmed to inform me that it is well connected to the system via the LWT instruction of MQTT. It works from the beginning but however it only works when the chip is started. If I restart openHAB I then receive the message that the chip is Offline, however I know that it is connected since I receive information on temperature, presence detection and / or open or closed door. With the migration to openHAB 3 I started to use the PROFILE “timestamp” among other things to update the date and time of the last action. This is very interesting since many of my rules have become unnecessary. I would like to understand which PROFILE I could use to modify my ITEMS which indicates to me the connection status of each chip using the information available for temperature, presence detection and or detection that a door has been activated. open or closed. I have tried unsuccessfully to use the PROFILE “Follow”, yet this is the one that seems most appropriate to me. Could you please help me with this problem that I got used to, as I found it laborious to restart all my chips every time openHAB restarted. Thanks in advance. I could provide a list of my ITEMS however they are all in French which could cause a problem.

This is probably the root of your problem. Sounds like you have not properly got LWT set up to ‘retain’ on the broker.

Not sure what you try to do with that. ‘Follow’ changes the state changes of an Item into commands on the linked channel.

Thank you for your quick reply. My Broker configuration in openHAB is marked RETAIN TRUE and in addition using MQTT Explorer I can see that the status is still Online however for openHAB it is marked Offline. I thought I could use one of the PROFILEs to accomplish the task, however with your comment on the PROFILE Follow I’m starting to doubt that this is the correct one. Basically what I want to accomplish is to use the different channels available on each chip and when a channel is used and the associated item changes it can also indicate that the chip is still online.

Not relevant, it is the LWT topic from the remote device that needs to be retained, so that openHAB can read it at boot time.

Can we see that?

Can we see your Thing/channel set up for that?

To rossko57, You were right and I apologize, I am sorry. After checking I noticed that in the part of code which concerns the management of the Lwt I had entered 1.1 (QoS 1 + retain = TRUE) but that in the following lines of the reconnection loop, if not succeeded in plugging into MQTT, I had written “client.publish (topicLwt,” Online “) I replace these lines with” client.publish (topicLwt, “Online”, 1) "and now it works. I humbly believe that I completely missed it since I endured this situation for the last 4 years. Thanks again. If you could also point me to the best tutorials to learn more about Profiles that would also be much appreciated. Any of the ones I find don’t show useful examples.

1 Like