[SOLVED] Send avgTemp to broke

From sensors scattered around the house, I get the average temperature from:
Group: Number: AVG avgTemps
Is it possible to send this value to the MQTT broker?
I would like the client to receive this value, which is a thermostat that I am building with an ESP8266 module
Thanks for your help
David

Yes

rule "average temp changed"
when
    Item avgTemps changed
then
    avgTempsMQTT.sendCommand(avgTemps.state.toString)
end

Create an item called avgTempsMQTT link it to an MQTT channel

As an alternative, you can use the publishMQTT Action. Replace the sendCommand with

    val mqttActions = getActions("mqtt","mqtt:systemBroker:embedded-mqtt-broker")
    mqttActions.publishMQTT("mytopic",avgTempsMQTT, true) // the "true" sets the retained flag to on

That is an extra line of code but doesn’t require creation of a new Item.

A third possibility which might work though I don’t know it it’s been tested is to create a Generic Thing with a publishing Channel like you would need to for Vincent’s approach. Then link that Channel to the Group. There’s a chance that will work.

work, thanks!
another small brick for my thermostat project !!

Please tick the solution post, thanks