Mqtt integration publish non-mqtt sensor value to mqtt

TLDR: How to configure the MQTT integration so that it publishes my MATTER sensor values to MQTT?

HI there,

I am new to HA but not to home automation. I once built dht20 + esp8266 based sensors that talk directly mqtt to my server (which is in a cloud). I did want to drill a whole in my private network security by being reachable from the internet. I would like to keep it that way.

Now 2 things changed: A) I became a father and have only very little time to get things up and running. B) Our house got a new heating and 11 Bosch Room Thermostate 2 along with it. I also own a Bosch SHC 2 by now.

My goal is to have a Raspberry Pi 4 receiving the sensor values from each room and telling them to my mqtt server in the cloud. I thought it would be smart diving into HA for that. I already managed to get the sensor values visible and controllable in HA by using the Matter Integration. (I wasn’t able using the bosch shc integration). I also added the MQTT integration and successfully published messages in the settings page so that it was received in the other end. BUT - How to make the system now take the sensor values and publish them over MQTT. As far as I understood the documentation - it is rather common to have a sensor that talks MQTT and the mqtt integration is the receiving end… So is my plan working at all?

Sorry if this has been answered a bazillion times already - as I said - I only have limit … Oh a poo diaper waiting for me to be changed!

alias: publish backroom temp sensor to mqtt
description: ""
mode: single
triggers:
  - minutes: /1
    trigger: time_pattern
conditions: []
actions:
  - action: mqtt.publish
    metadata: {}
    data:
      qos: 0
      retain: true
      payload: "{{states('sensor.backroom_temp') | float (0) }}"
      topic: sensor/backroom_temp

Here’s how I do it with an automation. There will be other ways of doing it.

Let me rephrase that. I figured some yaml configuration is possible in the “developer section”. I still didn’t manage to add this event. (I was however able to send one of my sensors value once to mqtt - which is a step) :wink:

Is your YAML to be added as an event? Or am I off?

thank you very much for this quick reply! How am I actually configuring this add-on? I installed HA by flashing an SD card and booting it. I don’t even have an SSH connection to the underlying linux. Is this possible by the browser?

Hi
This is an automation. You go in via settings on the browser and create a new automation and switch to yaml rather than gui then paste this in changing things like name and sensor name in the payload. This will publish the sensor you have in mqtt. This will not create a new sensor just the mqtt entry.

  - trigger: state
    entity_id:
      - sensor.backroom_temp

In my 1st example above it just sends a new value to the mqtt topic every minute but if you just wanted to send a message only every time the sensor changed value your could use this new trigger of state above.

1 Like

This works like a charm!
But let me add: I actually wanted to get the value out because the original Bosch App lacks the opportunity to check the history of a value. I did manage to get this working for my old sensors in my server and it would only be copy and paste to get it working for new mqtt messages. However I figured that HA has a pretty neat tab for exactly that. So maybe I will instead try out HA more and just use it as it is supposed to be used :wink:

Anyways - thank you very much!