Can someone confirm is the MQTT Event bus should receive entries from a grouped SUM or AVG group. Ie an average temperature
I have no idea about the 1.x binding. But MQTT 2.5 Event Bus will support that.
Yeah I haven’t moved to that yet. I’m still on 2.3
Seems the sum or average groups are not published by default when a member updates. Looks like I’ll have to make a rule to publish the value.
Interested, I hope it does!!! I will test on 2.4 soon
There were no changes to the MQTT 1.x binding between 2.3 and 2.4. if it doesn’t work in 2.3, I have no reason to believe it will work in 2.4 or 2 5.
Just a minute here … openHAB does not permit you (where “you” includes any binding you configure) to update the state of a Group type Item.
The only way to update the state of a Group is to update it’s members and have some aggregation function e.g. AVG
It’s not possible to directly mirror a Group Item in this way.
You can do it indirectly - mirror all the group members so that a local Group Item can do its own aggregation.
I don’t know if it is possible to use another indirect way - to configure event bus to transmit a Group state that you can receive into different type Item, e.g. a plain Number type.
That is a good point, though does it actually cause an error? It’d be kind of meaningless to update a Group Item but I think it would actually work (i.e. the state changes and there is no error). It’d be wiped out again the first time one of the Group’s members receives an update for sure. I ran a quick test through the REST API and it worked just fine. Maybe there are checks in Rules that are skipped in REST… but this looks like something you shouldn’t do, for sure, but I don’t think it’s something you can’t do.
I wonder if I need to add some checks to my event bus implementation to filter out the Groups. Though I could see some use cases where one would still want to post the Group state through the event bus. Like your example, I have a Group:Number:AVG on one OH that pairs with a Number Item on the other. In that case all would work fine.
I could see that being useful. So I probably just need to add a check in the filter Rule to avoid postUpdate to a Group Item but still allow the publishing of a Group Item’s state.
That would theoretically be possible. The bus works on Item name so as long as the Group and the Number Item are the same name the bus should work, assuming that the MQTT 1.x event bus doesn’t filter out the Groups, which seems to be the case. But you would have to be very careful to set up the bus to only work one way. If you need two way you probably can’t use the MQTT 1.x event bus because you can’t pick and choose which Items get published, they all get published.
You can pick and choose which Items get published with the 2.x event bus though.
Yeah I get that for aggregation groups, and you’d be stupid to try and do that.
But the thought the aggregated value would be pushed out to the bus (ie an average temperature)
But I’ll have to confirm but I’m sure I’ve exposed a light group to home assistant and it receives and updates status.
I thinkit must work:
# downstairs lights - platform: mqtt name: 'Downstairs Lamps' command_topic: "openhab/in/g_zwave_downstairs_lamp/command" payload_on: "ON" payload_off: "OFF" state_topic: "openhab/out/g_zwave_downstairs_lamp/state" icon: mdi:lightbulb
Is the home assistant switch that controls my group g_zwave_downstairs_lamp. Where the group is defined as:
Group:Switch:OR(ON, OFF) g_zwave_downstairs_lamp "Downstairs Lamps" <light> (g_lighting)
Group:Number:AVG g_temperature_average "Average Temperature [%.2f °C]" <temperature> (g_temperature)
Is never output on th eevent bus…Seems to be a difference in the handling between a switch group (which i guess is read/write) and a aggregate group…which is read only. Maybe that’s the answer.
It’s not the end of the world, and I can get around it in other ways. And an @rlkoshak says newer implementations of mqtt based onthe v2 version, handle all this differently anyway
Controlled the group switch from openhab:
openhab/out/g_zwave_downstairs_lamp/command ON openhab/out/g_zwave_downstairs_lamp/state ON
Controlled the group switch from home assistant:
openhab/in/g_zwave_downstairs_lamp/command OFF openhab/out/g_zwave_downstairs_lamp/command OFF openhab/out/g_zwave_downstairs_lamp/state OFF