Configuring outbound MQTT connection to ThingsBoard

Hello!

I am very new to Home Assistant and I am trying to figure out if the following scenario is possible.
I have set up Home Assistant and added a few devices like Tado radiator valves and Hue lights

I was wondering if I could make Home Assistance publish changes in i.e. the radiator temperature over MQTT and send them to ThingsBoard server (that has a MQTT broker listening on 1883) .

The reason for doing this is that ThingsBoard only supports few standard protocols for device connectivity while Home Assistant has a much broader connectivity library

Thanks

1 Like

Out of curiosity what did you end up doing?

Unfortunately I did not find a solution

I solved it by using curl and sending the data to the Thingsboard API. Here you go my case:

In configuration.yaml

shell_command:
  tb_sparsnas: 'curl -v -X POST -d "{{ states("sensor.electricity_consumption") }}" http://192.168.2.205:8080/api/v1/3lR8c123WMZOyabcpFNA/telemetry --header "Content-Type:application/json"'

Please note that 3lR8c123WMZOyabcpFNA is the access token of the Thingsboard device and that 192.168.2.205 is the Thingsboard server. Port 8080 is default in Thingsboard.

In automations.yaml

  - alias: Sparsnas Electricity Consumption
    trigger:
      platform: state
      entity_id: sensor.electricity_consumption
    action:
      service: shell_command.tb_sparsnas

I guess there is a more elegant way of achieving this. Please post and enligt.

API source: https://thingsboard.io/docs/reference/http-api/#telemetry-upload-api

3 Likes

I’m doing IOT as a hobby for 8 years. Writing Arduino, ESP32, RPi python codes, etc.
I just started using Home Assistant this week, and I’m amazed of its capabilities. What earlier took days and weeks of coding, now you can do so simply with HA.

Back to the topic:
I solved this problem by:

  • plugging a Zigbee dongle to an old Raspberry Pi 3

  • installing Zigbee2MQTT on it

  • writing a nodejs code on Raspberry which subscribes to its MQTT topics and sends data to ThingsBoard API

And you solved it with a few lines of yaml.
At the moment I can’t see a more elegant solution.
Very nice! :clap: