How to "trigger" an mqtt topic to read another topic

So I have a TRV setup with MQTT and “Generic Thing” - successfully using PaperUI (do not want to use files - please note) . The TRV automatically reports one state topic - TEMPERATURE which is the Actual Temperature of the room. It does this without any intervention and I can see the temperature on a linked item.

My “Generic Thing TRV” has a number of MQTT topics where a command topic (no payload) must be sent in order to read the corresponding state topic. For example, to obtain the VOLTAGE topic , one must send a null payload to topic /energenie/eTRV/Command/VOLTAGE/8008 (8008=manufactuer deviceID) and then the eTRV will publish the voltage value, once but the value is persistent, to the topic /energenie/eTRV.Report/Voltage/8008, for example 3.012 (an asci string for the voltage).

I have managed to do this through a very basic manufacturer provided control software and it all works, but my question to you good folk is:-
How would I model this (or how should I) in OH PaperUI? I have got the channels set up for the VOLTAGE command and state topics, but I’m not sure what Items I need and how to set these up or if indeed Items are the right thing to do? And do I have do do something else with the Channels? I have also noted the ability to setup a “Publish Trigger” on the MQTT Broker thing, is something I need?

All state topic payloads are of type String and all are persistent, that is to say that once the topic state value is updated, then the corresponding value persists until it is refreshed by means of publishing to the corresponding command topic - which is effectively a “Refresh request” . It is this refresh request that I’m not sure how to model in OH.

And, then, how might I setup HABpanel ? Maybe a widget that that shows the state and refreshes when clicked? Is it even possible?

I do not work with files so please kindly , I am looking for help with Paper or Basic UI, please, no files , please :slight_smile:

What is it? I am interested. Thanks

Sorry?Pardon?

I think I’d be building -
An Item representing your reading - “Voltage” - that links to an MQTT state topic listening for updates from the device.

An Item representing your “fetch button” - that links to an MQTT command topic that sends the needed “prompt” to the device.
You’d probably model that as a switch, and additionally link to expire binding to set back off after use.

Yes, I have the first, and that works but the second bit you mention is currently outside HAB as per my OP. So yes, how would I build the second bit - that was precisely my question. Are you able to elaborate how please? I have a Switch item but it’s not sending anything to the command topic. What would be REALLY great is for one refresh button to send all the commands needed , to refresh all the states

What device is it? I have been looking for MQTT trvs
Thanks

You have an MQTT thing with a command topic to do what you want? Link it to an Item. Send your Item commands.

If you choose a Switch type Item (as the closest thing to a “button”) you would want to see that the ON command gets transformed into whatever MQTT payload you actually need.

Ah, sorry. It’s Energenie: https://energenie4u.co.uk/catalogue/product/MIHO013

Although I acquired 5off for £99 in Black Friday :slight_smile:

Works perfectly with Raspberry Pi running Energenie’s ENER314-RT 433Mhz transceiver board: https://energenie4u.co.uk/catalogue/product/ENER314-RT running @gbpenton Client code that I setup as a systemd service on Openhabian.

Ok, so not Wifi MQTT but 433MHz - “Gateway” - MQTT
Not for me…
433MHz is just too unreliable
Not to mention the price!

Thanks anyway

I have a Thing with Channels where each Channel is setup for the corresponding State or Command topic. So I have:

TEMPERATURE
State =/energenie/eTRV/Report/Temperature/ to read current temp
TARGET TEMPERATURE
Command =/energenie/eTRV/Command/Temperature/ to set target temp
State =/energenie/eTRV/Report/TargetTemperature/ to read AFTER the command was sent for set temp
VOLTAGE
Command =/energenie/eTRV/Command/Voltage/ to request a report on current voltage
State =/energenie/eTRV/Report/Voltage/ to read AFTER the command was sent for voltage
POWER MODE
Command =/energenie/eTRV/Command/Power/ to request a report on current power mode
State =/energenie/eTRV/Report/Power to read AFTER the command was sent for powermode

etc.

What do I need to do so that I can press a “Refresh Button” and get ALL of them refreshed?

Wifi = more expensive, more power hungry, issues with congestion
433mhz = cheap (board was £2, TRVs were £20) but you can get remote controlled TRVs and switches for a tenner on auction sites - they use 433Mhz.

So far, no reliability issues - works perfectly - just want to use HAB now as the single integrated smart home system

1 Like

You need to send multiple command topics, right?
More than one way to go about it.

I think because you need to send “real” commands to your TARGET TEMPERATURE that would make it difficult to also send the “refresh” over the same channel.

One file-free approach;
Set up individual channels with your “refresh” command topics.
Link these channels to individual “do it” Items.
Put those Items in a Group.
Send a command to your group.

There are more elegant ways using rules, but you want to avoid files.

Not sure I understand,
I have channels setup, with State and Command topics.
I added a Switch Item and a Switch channel on the TRV thing, set the command topic, but when I operate the switch item, nothing happens?

EDIT: Hang on,
I have to say, this UI is better than nothing but it’s not intuitive.
This isnt easy or quick with the UI, so my “no files please” was unwarranted.
I will create a basic file setup and post back for help…
How would I do this in files (.things and .items) ? Can you provide an example using some arbitary IDs that I will substitute for my own.

Here is a working .things file, what next, please?

/* Bridge to TRV over MQTT */
Bridge mqtt:broker:MQTT_Broker [ host="localhost", secure=false ] {
  /* Generic MQTT Thing for TRV */
  Thing topic Lounge_TRV_Thing  "Lounge TRV" @ "Lounge" {
    Channels:
        /* Current temp , is published periodically by the TRV */
        State String : Temperature    [stateTopic="/energenie/eTRV/Report/Temperature/8008" ]
        /* In the following channels , states can only be obtained AFTER the corresponding commandTopics are triggered (with NIL payload) */
        State String : Voltage        [stateTopic="/energenie/eTRV/Report/Voltage/8008", commandTopic="/energenie/eTRV/Command/Voltage/8008" ]
        State String : Target_Temp    [stateTopic="/energenie/eTRV/Report/TargetTemperature/8008", commandTopic="/energenie/eTRV/Command/Temperature/8008" ]
   }
}

I have tried to research this but I need help please.
Maybe using profiles? https://www.openhab.org/docs/configuration/items.html#profiles will help? But i am stuck on what channels and items I need , and maybe things?
Also read this Design Pattern: Proxy Item but it is way above what I can do so not sure if it is suitable, but some form of Push Button widget in HABpanel that fires off multiple commandTopics would be great - if possoibe?

:frowning_face: This is not how MQTT is supposed to work. The device should just publish the voltage value. It shouldn’t require the subscribers to do anything to get the value.

If you want to do anything with the Channels you must link them to Items.

Not in this case I think.

On first thought, assuming you have more than one of these devices:

  • Create a Generic Thing for each device. Have a Channel for the refresh topic, the value topic, and any other topic provided/used by that device.
  • Link Items to all the Channels you care about. The refresh Channel should probably be a Switch type. then you can sendCommand(ON) to it and it will publish the empty message to the refresh topic in response.
  • Add all the Items linked to the refresh topic to a Group:Switch.
  • Create a Time cron triggered Rule that periodically sendComman(ON) on the Group. The command will be forwarded to all the members of the Group, which will result in the message being sent to the refresh topic and in turn the devices will publish the value to the state topic which will be received by OH and the Items updated. I believe this trigger type works in the NGRE PaperUI Rules UI.

Step back a second. You are trying to run before you can walk. Review How to get started (there is no step-by-step tutorial). Your struggles are because you lack an understanding of how OH works. In particular, the relationships between Things, Items and Rules.

No,…
Actually I do understand the OH architecture , what I need help with is the specific triggering to publish to many topics at once. The rest I am okay with. I do have items and linked channels. But the whole point of the question was HOW to model this in OH - admittedly granted through the UI then I was won over by the ease of files however I lack the SPECIFIC of what and how to do it.
Perhaps you could impart your experience with a suggestion that provides by example, a snippet of code to put in the file(s)
I am presuming you are capable of providing an example, there are many on the docs Ive read (which are extensive), so I clearly need to tie a few things together - how?

In so far as “not how its supposed to work” - that’s the manufacturer , not my design.

EDIT, me entire .things is:-

/* Bridge to TRV over MQTT */
Bridge mqtt:broker:MQTT_Broker [ host="localhost", secure=false ] {
  /* Generic MQTT Thing for TRV */
  Thing topic Lounge_TRV_Thing  "Lounge TRV" @ "Lounge" {
    Channels:
        /* Current temp , is published periodically by the TRV */
        State String : Temperature              "Temperature" [stateTopic="/energenie/eTRV/Report/Temperature/8008" ]
        /* In the following channels , states can only be obtained AFTER the corresponding commandTopics are triggered (with NIL payload) */
        State String : Voltage                  [stateTopic="/energenie/eTRV/Report/Voltage/8008", commandTopic="/energenie/eTRV/Command/Voltage/8008" ]
        State String : Target_Temp              [stateTopic="/energenie/eTRV/Report/TargetTemperature/8008", commandTopic="/energenie/eTRV/Command/Temperature/8008" ]
        State String : Diagnostics              [stateTopic="/energenie/eTRV/Report/TargetTemperature/8008", commandTopic="/energenie/eTRV/Command/Temperature/8008" ]
        State String : Target_Temp              [stateTopic="/energenie/eTRV/Report/TargetTemperature/8008", commandTopic="/energenie/eTRV/Command/Temperature/8008" ]
        State String : Identify                 [commandTopic="/energenie/eTRV/Command/Identify/8008" ]
        State String : Exercise                 [commandTopic="/energenie/eTRV/Command/Exercise/8008" ]
        State String : Valve_State              [commandTopic="/energenie/eTRV/Command/Valve_State/8008" ]
        State String : Power_Mode               [commandTopic="/energenie/eTRV/Command/Power_Mode/8008" ]
        State String : Reporting_Interval       [commandTopic="/energenie/eTRV/Command/Reporting_Interval/8008" ]
   }
}

As I and others in this thread have recommended… to repeat myself

  • Create a Generic Thing for each device. Have a Channel for the refresh topic, the value topic, and any other topic provided/used by that device.
  • Link Items to all the Channels you care about. The refresh Channel should probably be a Switch type. then you can sendCommand(ON) to it and it will publish the empty message to the refresh topic in response.
  • Add all the Items linked to the refresh topic to a Group:Switch.
  • Create a Time cron triggered Rule that periodically sendComman(ON) on the Group. The command will be forwarded to all the members of the Group, which will result in the message being sent to the refresh topic and in turn the devices will publish the value to the state topic which will be received by OH and the Items updated. I believe this trigger type works in the NGRE PaperUI Rules UI.

Since you understand OH, which one of the above steps do you have problems with? There is nothing in the above that is complicated. It’s all very basic openHAB stuff. Since you already have the Things and Items you just need to create the Group, add your Items to the Group, and write the Rule.

See Items | openHAB for how to create the Group in a .items file, or you can create it in PaperUI.

See the following for creating the Rule

All you have to do is sendCommand(ON) to the Group on a polling schedule.

It’s a one line Rule.

We are happy to help with details but we are not going to write this for you. We’ve told you what you need to do, more than once and from more than one user in this thread. If you have a specific problem or confusion we will be happy to help. But again, we are not going to write this for you.

" Since you understand OH, which one of the above steps do you have problems with? There is nothing in the above that is complicated. It’s all very basic openHAB stuff. Since you already have the Things and Items you just need to create the Group, add your Items to the Group, and write the Rule."

Creating the rule and using that to “trigger”/“fire” the “refresh” topics

Not seeking to be boring, but in fear of repeating myself

Perhaps you could impart your experience with a suggestion that provides by example, a snippet of code to put in the file(s)
I am presuming you are capable of providing an example, there are many on the docs Ive read (which are extensive), so I clearly need to tie a few things together - how?

That is the help I need. If you want to keep repeating yourself and point to this and that, then there is really no point you doing so here, because it is not helping me. Of course Ive read docs, all of the configuration ones and for my bindings. I NEED HELP

See the following for creating the Rule

And since you understand OH, I’m sure you understand that Rules don’t trigger MQTT topics. Rules update or send commands to Items. The Items are linked to Channels on Things. Depending on how the Channel is configured, it receives the Command and sends a message to the device using what ever technology it uses, in this case sends an MQTT message.

Tell you what Rich, hey, many thanks for coming on here, but maybe leave it for someone else. Im getting frustrated and I dont want to hack you off so may be you can leave this thread. It is not helping one iota but I do thank you for all the links to the docs Ive read.

I’m pulling hair out here so if someone who has the capability to by example provide the code I need, Id appreciate you posting here .

I think I will await someone who can , BY EXAMPLE , using CODE , IN FILES , how to setup ,not cron , but pushbutton in HABpanel to effect an update in state topics by posting to command topics. Thank you so much.