In a sitemap I can see all the switches and the master (group) switch, it behaves as expected (when at least one switch is ON, the group switch is ON). Now, I understand, that when the state of group switch is updated (because of the change of one of its members) no command is received by the group. But update is received. Now, I want to publish such change to MQTT, so I used this:
(originally I used command but that cannot work). This however, doesn’t work either. Why?
PS: I know I can e.g. publish directly from the rule using MQTT action, or I can have another Switch item for the master switch and sendCommand to it whener the group switch receives an update.
No. The scenario is that the individual switches indicate whether it is necessary to heat in particular room (and to open the valve) and the master (group) switch indicates whether the kettle/boiler should be powered on/off. So I want to publish a change of a group gHeating. If I click on the sitemap directly on the master switch, the command is sent (because the click on UI sends a command, I get that). However, if I change e.g. Bedroom_heating switch, the gHeating receives an update (I know that because I made a rule
rule kotel
when
Item gHeating received update
then
logInfo("Debug","Kotel received an update")
end
Here you have two items that are part of gHeating group but no mqtt info. Are all items communicating via mqtt and have you verified mqtt is setup correctly.?
The Group is not an item, the mqtt info should be for each item.
Example:
I am not sure if you are answering my questions. Let me answer yours:
Yes, MQTT is setup correctly
I don’t know how Group is handled, whether it is an item or not, but having my setup when I click in the Basic UI on the Group switch (which looks like this in the sitemap: Switch item=gHeating label=“Heating” ) the MQTT message is sent. If I click on one of the sub-switches and such click changes the state of the gHeating switch (i.e. all the sub-switches are OFF and I click on one of them so it goes ON, the Group switch also goes ON because it is an OR switch), no MQTT message is sent. I suspect it is because no command was received on the Group switch. But why does it not register state change (as I mentioned in the previous post, linking the docs).
What is incorrect? What you have written is in fact the same as I had there (state:*:${state}), at least according to documentation. And I don’t see any errors in logs (and I saw some when I had incorrect syntax before). So that won’t be the problem I think …
So if you are right, do you see anything in the logs?
I have the same config on a group item and it works.
Add spaces after the { and before the}
The binding parser can be picky sometimes.
rule test
when
Item Bedroom_Heating received update
then
logInfo("Debug","Bedroom received update")
end
rule test2
when
Item Bedroom_Heating received command
then
logInfo("Debug","Bedroom received command")
end
rule kotel
when
Item gHeating received command
then
logInfo("Debug","gHeating received command")
end
rule kotel2
when
Item gHeating received update
then
logInfo("Debug","gHeating received update")
end
I have recorded the scenario that I am talking about. See, when I click directly on Heating a command is received and MQTT message is sent. When I click on Bathroom switch, Heating is updated (so a state is changed) but no MQTT message is sent.
They are not bound yet, it doesn’t matter at the moment. Why do you guys always need to ask unnecessary questions? I have posted a problem, a discrepancy between theory (what documentation says) and praxis (what is happening in reality) and haven’t got any answer.
Have you seen in the video (gif) above that the messages are received correctly?
To put you more into my situation, I have installed my first openHab setup last year. It worked, including mqtt bindings, but it was a mess. I haven’t used much of the openHab features (like groups at all) so I wanted to make it better, so I started this test environment (see the mqtt topic) and I stumbled right at the beginning. And it’s been like 15+ posts and all we discuss here is where did I make a mistake. Which is fine, in 99 % of cases the mistake is between the keyboard and a chair, I get it. So I tried to answer all your questions, now I posted a video showing that the MQTT binding is working fine, that the Group:Switch is working as a group switch and that the update is not publishing to MQTT. So please understand, that I am a little bit tired of saying the same all over again.
Would you please have a look at the video and tell me, if this is how it should behave? I sort of expect, that someone will come and say: “Well, GroupItem when receives an update from its member does not propagate it to bound channel. This a feature/bug. Deal with it, make a workaround or report the bug.” Or, that someone says: “You have incorrectly configured this and this”. That’s what is happening so far but nothing was proved to be incorrectly configured yet.
Hi,
thanks @shrap for bringing up this question. I struggled with the same in the past and did not further investigate. The problem ist not the MQTT but the questions why is the message send when the group switch is operated from the UI, but not when any of the group member switches is changed and the state of the group switch therefore changes as well.
Right?
Marcel
Exactly. First I thought that he update message is not received by the group at all, but it is as one can see from the log (in the video above). I have now tried regular item (Switch) setup like this
Switch Test <heating> { mqtt=">[shrapovo:test/cidla/cmnd/test/power:state:*:default]" }
so essentialy the same as the group switch before. And I made a rule for the Bedroom switch:
rule Bedroom2
when
Item Bedroom_Heating received command
then
logInfo("Debug","Bedroom received command")
Test.postUpdate(receivedCommand)
end
and to check what input the Test item receives, I added
rule test
when
Item Test received command
then
logInfo("Debug","Test received command")
end
rule test2
when
Item Test received update
then
logInfo("Debug","Test received update")
end
And surprisingly (or maybe not), it works as expected, i.e. when I click on the Bedroom switch, an update (not command) is sent to Test switch and that update is published to MQTT. So the problem is when the updated item is GroupItem, then the MQTT outbound message is not sent. From my point of view it is a bug (or at least it needs to be documented).