General introduction to teddycloud <> MQTT (with HA)

I am sorry to have to ask this, but unfortunately I was not able to find a post here explaining the first steps in connecting teddycloud with a MQTT broker in order to use it with home assistant.
I found the vid on YouTube and I found some docker references in the forums but any preparations needed for maybe MQTT to allow teddycloud to connect seem to be hidden for me. Same goes for the wiki.
Does anyone have a small tutorial? Thank you in advance.

Setup your MQTT Broker, connect HASS to it and also connect teddyCloud to it by configuring the mqtt settings. Then it should show up unter MQTT in HASS

image

Hey there,

thank you for reminding me of the topic. I have solved this thanks to @ruN and instantly forgot about that topic like almost all forums are whenever you look up anything.
That is why I want to provide the steps myself so anyone else being as curious as I was can find the solution here.

If you want to have teddycloud available in Home Assistant you will have to perform a few steps to do so.

First of all a running instance of teddycloud is required which is done by steps described in the wiki and the forums thorougly.

Next is the creation of MQTT credentials so teddycloud is eglible to submit its data. What I was not aware of is that Home Assistant not only uses MQTT but instead it manages the MQTT server using its MQTT broker addon. So in order to create credentials you will have to use Home Assistant itself. The generic documentation can be found here: HA MQTT User Creation
In our case we will have to go to Configuration → Users → Users. You should see these already here: Home Assistant Content, Supervisor and yourself as an administrator.
Create another user for instance teddycloud. Set a password, set him to active and in my case I have chosen for the user to be a local user (e.g. use your private LAN). Once saved I have decided to restart my whole home assistant (device) to be sure changes are applied however this might have been unneccessary.

Third:
Important! Do not check “Enable MQTT” at the beginning. Settings are applied immediately so before you have entered credentials and so on leave the switch be in order to avoid failed login attempts and stuff.
I recommend to press each field’s save button once the details are entered correctly.
MQTT hostname: hostname of your MQTT server (in most cases the same server hosting your HA instance - especially if you are using HASSIO)
MQTT port: 1883 is fine for now
Username & Password: the ones set in Home Assistant for the new users. Beware password is not hidden!
Client identification: could be anything you want if you want to run different instances of teddycloud this is for you to identify each’s logging.
Topic prefix: internal handling again, leave it as it is or adjust in case of multiple teddycloud instances.
QoS level: 0 is fine
One more thing: under Category Core .server set Host URL to your teddycloud’s URL, e.g. http://tc.fritz.box
It is said in the forums this might be needed to have it running properly. Nothing lost if it set correctly anyways.
Press save on the text field. Now reload the whole page and ensure all settings are entered correctly and if not repeat.
Once all is correct even after reload of the page, toggle the switch “Enable MQTT” to have teddycloud inform MQTT about all devices and entities. After about 10-20 seconds refresh the page again to see if “Enable MQTT” still is on. If the connection fails or settings are incorrect teddycloud will disable MQTT by itself after a few tries thus checking here will get you an idea if everything went well.

If MQTT connection is working properly you will find the devices and entities in the developer tools of Home Assistant. If “Enable MQTT” has switched back to off you can check the MQTT logs in Home Assistant: go to Configuration → Addons → MQTT Broker → Logs

On your server running the teddycloud docker you can run:

docker container logs $(docker container ls -a | grep teddycloud | cut -d ’ ’ -f 1) --follow

Once you can see the logs reenable MQTT in teddycloud and check for the logs popping up.

Hi
I followed this instruction, thank you all very much for the input. However, I am not able to get the connection running. The log file in the teddycloud container shows the following error:

ERROR|platform_linux.c:0398:resolve_host| getaddrinfo Name or service not known
ERROR|mqtt.c:0318:mqttConnect| Failed to resolve ipv4 address!
INFO |mqtt.c:0314:mqttConnect| Connect to ‘http://homeassistant.local

I already tried to change the address to the actual IP Adress where Home Assistant is running

Does anyone has an idea on what the issue is?

Thank you very much

Because your teddyCloud instance has no DNS and or Access to your network due to a general misconfiguration

Thank you for your fast answer. Unfortunately I have no idea on how to resolve it.
I followed the guide on the TeddyCloud to flash the ESP32 Box and everything works fine, I just fail to active MQTT. I host it on the same instance as my Home Assistant (on a differnt docker, set up over the portainer Add in, so the IP Address / Host URL is the same). I also run Adguard, but disabling it didn’t solve the problem. Any idea on where to start looking for the misconfiguration or on how to assign a DNS to Teddycloud? Or if you need any additional information I am more than happy to provide them. Really appreciate your help!

In your compose yaml, just add dns like so:

    ...
    image: ghcr.io/toniebox-reverse-engineering/teddycloud:latest
    dns:
      - 192.168.0.5 # local dns resolver
      - 1.1.1.1 # global dns resolver
    ...

But when you say, there is no connection by using an IP, @0xbadbee said, you seem to solve network access first. Are you using macvlan?

Hi,thank you very much for the answer. I won’t be at home until next weekend to try it out but will let you know once I tried it out

Hello,
Thank you for opening this topic.
I have the same problem that neither the TeddyCloud nor the Toniebox is displayed as a device in Home Assistant under “MQTT”.

TeddyCloud version 0.6.3 is installed in Portainer as a container and works perfectly with the Toniebox.

Home Assistant 2025.1.3 and Mosquitto broker 6.5.0 are installed.
The Mosquitto broker was installed with Zigbee2MQTT.

In Home Assistant there is a user “mqtt_user” for the login on the Mosquitto broker.
This works for many devices such as Shelly or Nuki.

The TeddyCloud is configured as follows:
.server
Bind IP: IP of the teddycloud
Host URL: http://teddycloud.fritz.box

MQTT:

  • MQTT hostname: homeassistant.fritz.box
  • MQTT port: 1883
  • User and PW as on the other devices
  • Client Identification: teddyCloudServer
  • Topic prefix: teddyCloud
  • QoS level: 0

hass:

  • Home Assistant name: homeassistant
  • Unique ID: teddyCloudServer

In the MQTT Explorer I can see that the TeddyCloud connects and also sends topics:
homeassistant.fritz.box
→ “teddyCloud” with sub-elements

→ homeassistant
→ sensor
→ “teddyCloud_Box_(ID)” with sub-elements
→ event
→ “teddyCloud_Box_(ID)” with sub-elements
→ binary_sensor
→ “teddyCloud_Box_(ID)” with sub-elements
→ image
→ “teddyCloud_Box_(ID)” with sub-elements

Unfortunately, no “device” appears in Home Assistant under “MQTT” even after days of playing tonies with the toniebox.
What could be the reason for this?

I am not too sure in what interval the broadcast message is published from TeddyCloud. But since TC is publishing topics (as you was able to watch them), there must be either configuration issue or the initial broadcast never happend/received properly.

Restarting TC have not worked? When restarting TC and turn on TonieBox, do you see the broadcast in mqtt client? If so, HA needs some adjusment on the topic i guess…

Hello ks61625,

Thank you very much for the tip! That was the solution.

I have already restarted the TeddyCloud several times, but now 10 times within 30 minutes.
Suddenly MQTT displayed a new device “homeassistant” from the manufacturer “Team RevvoX” in Home Assistant.
After I placed a Tonie on the box, another device “toniebox_red” was then displayed.

Why MQTT displays the TeddyCloud as “homeassistant” is not entirely clear to me. The only occurrence is the parameter “Home Assistant name” in category hass.
Is this not to be understood as “The name of the Mosquito broker in Home Assistant” but as “Name of the TeddyCloud”?

Thank you!
Stefan

Hey Stefan,
as far as I can tell this is caused by your used user credentials. I have created a separate user solely for the use by teddycloud. You said, you had been using mqtt_user which had been used by all other appliances and I assume you had assigned “homeassistant” as friendly name.

Best regards

Hi, I am back home and tried it out, unfortunately without any success. I added the three lines with the DNS as suggested:
dns:
- 127.0.0.1 # local dns resolver
- 1.1.1.1 # global dns resolver

I also tried again changing “homeassistant.local” with the IP Address instead (same IP address for MQTT hostname and Host URL, the one where I can reach homeassistant and teddycloud and the different ports). I get again the same error:
INFO |mqtt.c:0314:mqttConnect| Connect to ‘http://192.168.xxx.xx
ERROR|platform_linux.c:0398:resolve_host| getaddrinfo Name or service not known
ERROR|mqtt.c:0318:mqttConnect| Failed to resolve ipv4 address!

And I do not use macvlan. But everything else, besides MQTT, works perfectly. I can reach teddycloud under the IP Address and I do have a connection to Teddycloud and Boxine.

You obviously have local networking issue.

This makes no sense to me as 127.0.0.1 is always the latestd dns fallback resolver. Ou have to enter your real LAN DNS server here. So could be a pihole, fritzbox or what ever. But 127.0.0.1 is obviously having issues with resolving.

I would try to connect to TC terminal and try to ping or curl the needed ip addresses.

Sorry, this was my last desperate move to make it work and I copied it that one out.

As I use AdGuard on Home Assistant I manually set up the Primary DNS server IP address in my router UI (192.168.xx.xx - the same as home assistant and teddycloud is running on and also the one “adguard is listening to”). I tried that and also turned AdGuard off to prevent the risk of blocking anything (even though I did not see anything in the logs). I then used the IP on which I can reach the UI of the router (192.168.yy.1), same result.

If I try nslookup on prompt command I get “can’t find homeassistant.local: Non-existent domain” (is this the right way to ping the needed ip address?)

I really appreciate your patience and help here as I am not quite and expert if it comes to local network / dns settings.

It is really hard to say what exactly the local problem could be. It really depends on your setup. Try to inspect docker network and their ip-addresses. Lets say there are 3 container (1 HA, 1 AG, 1 TC) all in same docker network. So you can assign dns server in TC to the local docker IP of AG as well, in case you cant reacht them by theire router given IP. Also log into TC terminal and check if you can reach AG in general (by router ip, docker ip). Other than that try to assign the same network into all 3 container. Or play around with macvlan if needed.

Unfortunately, there is not “the one” solution for your issue, since it is a really individual setup. Just giving hints here…

Hi

Thank you so much, you pointed me to the right direction. As I am not really an expert in this area, I am not sure if all was necessary, but this is what I did and I now see “teddyCloud - Server” as Device under MQTT (as defined under Category hass in the teddycloud settings). I hope I can help someone else with that as well at some point.
After some digging in how portainer works with networks I saw in the configuration, that teddycloud runs on the network “teddycloud_default” (which gets generated automatically regarding some documention I read), while Adguard and HA run on “hassio”. So I added teddycloud to the hassio network. Under Settings in teddycloud I then used the local docker IP from Portainer (172…) for the Host URL and the MQTT hostname.

However, as of now I only see the device “teddycloud - server” with the controls that seem to be the settings from teddycloud. However the entities are all “unavailable” and I do not see another device after I place a Tonie on the box (like Stefan described). How can I see what Tonie is currently played?

In the mean time a big thank you again for your patience and helping me to get the connection done.

You’re welcome!

Well, not seeing the box in HA/MQTT sound exactly like this post. Is this same for you?

I would check mqtt if there is really nothing, then this should help. If There is smth in mqtt but not in HA, HA needs some adjustments I guess.

I downloaded MQTT Explorer to check the raw data that got sent and I saw teddycloud server and the teddycloud box. So far so good. But when checking the message I realized that the IP addresses in the strings were different, so I went back to the settings and played around and it turned out not all my steps in my previous posts were correct.
Following setup was the solution:
Host URL: the IP address were teddycloud is hosted
MQTT hostname: the local docker IP from portainer were the mosquitto broker is hosted
DNS resolver for teddycloud in portainer: the local docker IP where AdGuard is hosted

So again, thank you for your help as you pointed me again into the right direction