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

" 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.

Hint: you can’t
You need to split your channels
One for the state topic
One for the command topic
Then create items for each
Create groups
Create a dummy switch
Create a rule and send a command to the command topic group (One line rule!)

Makes senses
As @rlkoshak said, basic stuff

That’s what we’re telling you - you can’t.
What you can do is use a Group of MQTT linked Items to simulate that.

WTF is going on here.
How many times, I need EXAMPLES of the “refresh trigger” the “update” the “group refresh” whatever you want to call it.
You all seem to possess the knowledge I have no doubt, so why cannnot you grasp the basic request for AN EXAMPLE…

Here is my full files FYI , there , now , an example in your next would be wonderful? That would be a REAL REAL help.


/* 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" {
        /* Current temp , is published periodically by the TRV */
        Type 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) */
        Type string : Voltage                  "Voltage"                [stateTopic="/energenie/eTRV/Report/Voltage/8008", commandTopic="/energenie/eTRV/Command/Voltage/8008" ]
        Type string : Target_Temp              "Target temperatue"      [stateTopic="/energenie/eTRV/Report/TargetTemperature/8008", commandTopic="/energenie/eTRV/Command/Temperature/8008" ]
        Type string : Diagnostics              "Diagnostics"            [stateTopic="/energenie/eTRV/Report/Diagnostics/8008", commandTopic="/energenie/eTRV/Command/Diagnostics/8008" ]
        Type string : Identify                 "Identify"               [commandTopic="/energenie/eTRV/Command/Identify/8008" ]
        Type string : Exercise                 "Excercise"              [commandTopic="/energenie/eTRV/Command/Exercise/8008" ]
        Type string : Valve_State              "Valve state"            [commandTopic="/energenie/eTRV/Command/Valve_State/8008" ]
        Type string : Power_Mode               "Power mode"             [commandTopic="/energenie/eTRV/Command/Power_Mode/8008" ]
        Type string : Reporting_Rate           "Reporting rate"         [commandTopic="/energenie/eTRV/Command/Reporting_Interval/8008" ]


Group g_Refresh_TRV

/* Lounge TRV */
        /* States */
        String Get_Temperature          "Current temperature [%s]C"     (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Temperature"}
        String Get_Target_Temperature   "Desired temperature [%s]C"     (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Target_Temp"}
        String Get_Voltage              "Current voltage [%s]V"         (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Voltage"}
        String Get_Diagnostics          "Diagnostics code [%s]"         (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Diagnostics"}
        /* Commands */
        String Set_Temperature          "Set temperature [%s]"          (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Set_Temperature"}
        String Exercise                                                 (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Exercise"}
        String Identify                                                 (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Identify"}
        String Set_Valve_State          "Valve state [%s]"              (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Valve_State"}
        String Set_Power_Mode           "Power mode [%s]"               (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Power_Mode"}
        String Set_Reporting_Rate       "Report rate [%s]"              (gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Reporting_Rate"}
        /* Commanded by Refresh */
        String Refresh_Voltage                                          (g_Refresh_TRV,gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Voltage"}
        String Refresh_Diagnostics                                      (g_Refresh_TRV,gTemperature) {channel="mqtt:topic:MQTT_Broker:Lounge_TRV_Thing:Diagnostics"}
        /* Refresh button */
        Switch Refresh_Event            "Refresh Button"                (g_RefresH_TRV)

One assumes I need to do something with the g_Refresh_TRV group which will “trigger” (for want of a better word), the publishing of TWO topics with null payload to force a refresh of Voltage and Diagnostics. in CODE ? :slight_smile:

As per Rich, above, 1

But now I’m out of my experience, this is gettnig into Java etc, which is where I need the help, as stated, many times. Phew. Someone save me

Well in time it took to type all that, you could have provided the potential rule .

I really do not understand this forum. It is a place for help, and I have asked for specific help. Several hours later, what I note is “clever people” telling me what I should do but vitally, NOT answering the question. In of the posts above, all that is required, is a few lines of rule code. That’s all. I really do not understand why - if you really want to help- you post the obvious. It is obvious because I’ve already read the articles and I am stuck. I thought that was pretty obvious. Perhaps you do not actually know how to do it - that would explain a lot. I am 55, I am not a programmer, I have a wife kids and grandchildren to care for, I dont sit up through the night coding up programs and scripts, I dont really care for all that, Im just trying to ask a very basic question for specific basic answer. “Basic Stuff” you all say, really, is it - show me!

In the meantime, I shall await guidance from a clever person who just posts an example/suitable close enough code rule , with an exclamation mark so that I can finish the job.

So easy , yet proving so difficult.

In our extensive experience, writing the code for you ends up resulting in a huge time sink. We write this Rule for you, you copy it, don’t under stand it, then need us to write the next one and the next one and so on forever. Or even worse, we need to debug it for you when it doesn’t work.

So here.

rule "Request a refresh"
    Time "cron 0 0/5 * 1/1 * ? *"

It doesn’t get much simpler than that. You should have been able to come up with that from the links I provided. This is like half a step away from “hello world” the canonical first program one writes in any language. This is literally as simple as it gets for Rules.

And this is pretty close to at least one of the Examples in the Rules Documentation I linked to:

rule "Increase counter"
    Time cron "0 0 0 * * ?"
    counter = counter + 1

So now one must ask, do you really know any more now than when you started? Do you understand what the Rule above does? Why it works? How to debug it when it doesn’t work? No, you don’t. And now you will copy and paste that code, run it, and have no idea what to do when/if it doesn’t work. You have no idea how to expand it. You have no idea how to write another rule that does something different. And we here on the forum are now suck for ever writing your code for you.

And when you ask for examples, it shows that you neither read the docs which are riddled with examples (e.g. nor did you browse or search the forum (

Anyway, you get this one for free. But as you can see, in the future, we won’t usually be writing your code for you, especially when you demonstrate either a lack of understanding which is made clear from reading the docs, or a lack of effort to search for something in the forum that already addresses what you need.

Then state clearly and explicitly where you are stuck. And the real key is show us what you’ve done (i.e. show us your attempts at .rules code). I’m stuck isn’t something we can help with. “I’ve written this rule (paste in code) and put it in a file at path blah/blah/blah and nothing happened.” THAT we can provide help for.

So far what you’ve asked for is for us to do it for you. And we don’t do that because it ends up becoming a huge time sink for all of us. For a one liner Rule like this “show me an example” literally is “do it for me.” And you’ve shown no attempt to do it yourself.

Don’t know where to save the Rule file?

Don’t know what format a Rule should have?

Don’t know how to cause a rule to trigger periodically?

Don’t know how to send a command to a Group Item?

Don’t know how to put it all together?

So either you didn’t bother to read the docs or use the resources available to you or you did in which case you need to tells us exactly and specifically where you went wrong. Don’t like reading docs? Prefer Videos? If you had bothered to click on the link I provided in post 15 above you would have encountered a bunch of great video guides that will help.

We have all provided just about everything you need on this thread to do what you are after. But you have not bothered to even click on the links. You just want what you want exactly the way you want it.

We all have wives and kids and families too. We don’t sit up through the night coding up other peoples home automation system for them. We don’t even do so for our own home automation systems. But if you think you can get away with building a home automation system without learning to write Rules you are in for disappointment. If you can’t or wont use the resources provided to you, and there are thousands of man hours of effort provided to you in documentary and explanatory effort in the links that exist in this thread that you have ignored, you will not be successful with openHAB.

If there is something specifically not clear in these docs, tell us and we will try to make them better. But so far all you’ve done is ask us to do it for you. It doesn’t work like that. You have to be able to read the docs and apply them to be successful with openHAB or any home automation system really.

And yes, we are spending way more time here on these posts telling you what to do but not coding it for you for a reason. If we give you a fish, we’ll be stuck being your fisherman forever. If we teach you to fish than ultimately we have more time to help more people.

As I like to say, our time has value too. None of us are getting paid for this.

1 Like

Lol. Oh Rich that was priceless. How much time have you guys invested in writing essay on this “basic stuff” to use words above. Would it not be much simpler to paste the code, quciker, easier and far far less time. That’s where I needed help, having read the docs , I’m not good enough yet to complete the job.

Im still LoL at your statement above. My sides…

Rich, youre asking me the question, so your posing a load of questions to A QUESTION. It doesnt get better does it.

Ok , well now that you post that I went here:
So now I have learnt something - See! My method works.

I get that you once were stupid like me, and had to start somewhere, but unlike you Rich I am neither interested nor inclinded to become an expert in OH. I asked a specific question which until now, several hours later and hundreds of lines in posts, you have answered. I am most grateful to you Rich, now I shall play with this and other rules and items to get what I want and how I want it to work. This is a great help Rich. Thanks

p.s. your first Time "cron … " should be Time cron "…:slight_smile:
It’s erroneous …

2020-01-02 22:02:00.216 [WARN ] [lipse.smarthome.core.items.GroupItem] - Command 'ON' has been ignored for group 'g_Refresh_TRV' as it is not accepted.

I’ll need to debug your solution,

anyone else have an idea on WORKING code? This is getting silly, all day on this forum to get a bloody simple TRV status.

That’s because the items in the group are not the same type

Yes Rich, Ive just noticed.
My topics need to be an empty string so I changed the trigger to

g_Refresh_TRV.sendCommand(new StringType(""))

All working THANKS Rich, albeit on a cron job. To preserve battery in the TRV I only want to send commands when a “REFRESH” button is pressed on HABpanel. I will need to do more digging on this but for now at least the TRV is working and reporting.

The command. You changed the command.
Triggers are what trigger rules

Turn of phrase Rick. I refer to “trigger” in the sense of triggering an action (such as sending a command). Not to be confused with channel and item triggers. :slight_smile:

Next , to do this via a dashboard in HABpanel

I am not Rick I am Vincent…
OpenHAB has its own language. Using the correct terminology will avoid confusion.

1 Like

That’s fine. As you’ve already realized, you’ll have to persuade people to write code for you, because every install and requirement is unique. But I think you’ll need to work on your approach for that.

1 Like

Actually, I think “my approach” was appropriate to begin with, Then, commensurate with perceived attitudes, it deteriorated due to sheer and inexplicable frustration. Here, certainly in Barclays bank and in the UK, people are generally polite and forgiving. But this post tests the will of a meek sheep.

We do come across sporadic forums and posts such as this. Mostly Open Source where clever people have contributed and become “ingrained” into the product and almost take on a delusion of grandeur where their mere intervention is not worthy of beginners, because such oracles have spent vast amounts of time (alluded to above indeed). and why should that time be given to mere mortals.

It really is a rather distasteful attitude . Here, I work in support, if someone asks for instructions written, I give them .If someone asks for links, I give them. If someone asks for advice, I give it. I and WE do this here, because we HELP. HELP. We HELP. We do not project our own delusions of supremacy on others. We recognise that not everyone has time, capability, awarness, competence and so on, to achieve what they seek,
This might be useful for folks here to “tune their approach”

Alas, I am almost entirely minded to conclude it will not and the folly will persist . Such a shame the such great wisdom cannot be imparted as needed.

A saving grace will be that posters reflect on this, sadly I doubt they will.

That’s the point. We don’t work here. We are volunteers. You need to start by helping yourself. Just asking for code written for you will not help. Show your code and tell us what you expect it to do and what doesn’t work and we’ll help. But you came in and said “write my code for me”.

I can do that (I charge for the service BTW). But you won’t learn anything out of it.

In the forum you need to start by helping yourself first and then we’ll help.

It starts from there: How to ask a good question / Help Us Help You

Also, my post above:

Hint: you can’t
You need to split your channels
One for the state topic
One for the command topic
Then create items for each
Create groups
Create a dummy switch
Create a rule and send a command to the command topic group (One line rule!)

Is everything you need. Work the steps, one by one. Figure it out. Understand it. Make mistakes. Get fustrated. Swear a bit. Try again. Search the forum. Try again. Read the docs. Read them again,. Have a coffee. Then when really stuck, POST WHAT YOU DID. and show what you tried. Then, we’ll help

1 Like

You’re paid to do that.

Excellent. You can spend as much of your time as you wish doing just that.

1 Like

Why keep on this futile discussion. You are clearly behaving in a manner consistent with my perceptions, so only to as further reinforce my assertions. If it comes down to money , then dont help. Just dont bother. There’s no need to if money is what you seek. Ah,perhaps you cite this benefit in gratuitous defence of your egos.

You are in every way, shining examples, of souls who have lost their way in compassion and empathy, and serve only to further elate your own belief in importances.

Im done on this thread

At the end of the day, you didn’t like the responses to “Please write my code for me, here is my specification.”

The advice is free; you are quite free to ignore it, modify it, complain about it, take umbrage at presentation skills, change your requirement along the way, or even do better yourself.

Most importantly, no-one has stopped anyone else from writing code for you, or from providing personal tuition. Perhaps that could still happen.

1 Like