Hi @vitalikkh
I’m not sure how to advise you as my experience of MQTT is limited to Home Assistant’s native Mosquito broker.
Hopefully someone else can help.
Hi @vitalikkh
I’m not sure how to advise you as my experience of MQTT is limited to Home Assistant’s native Mosquito broker.
Hopefully someone else can help.
You can only link to one mqtt broker in home assistant. Therefore if you are already usung mosquitto, you can’t directly connect HA to the external broker.
You can however use you mosquitto broker to connect to the external broker. Use bridging
Thank you for the info on bridging MQTT brokers. This bridging may do the trick.
But where do I enter the configuration shown below for the MQTT Broker on HA?
JSON data from my frontdoor should be your smart bed
Sensors
0
TaskName "BME280"
Temperature 11.24
1
TaskName "PIR_VD"
Switch 0
2
TaskName "Drukknop"
Switch 0
3
TaskName "relais"
Switch 0
-------------------------------------
MQTT sensor and switch examples
This if you do not get auto discover
-------------------------------------
Temperature sensor example
# mqtt_sensors:
- name: "t_frontdoor"
unique_id: '##########'
state_topic: frontdoor/BME280/Temperature
unit_of_measurement: °C
device_class: temperature
value_template: "{{value_json}}"
----------------------------------
binary switch
- name: pir_door
unique_id: '#########'
state_topic: "frontdoor/PIR_VD/Switch"
payload_on: "1"
payload_off: "0"
device_class: motion
# value_template: "{{value_json.x}}"
switch, relais in this case
---------------------------------------------
# mqtt switch:
- name: light forntdoor
unique_id: '#########'
state_topic: "frontdoor/relais/Switch"
command_topic: "frontdoor/gpio/12"
payload_on: "1"
payload_off: "0"
optimistic: false
qos: 0
retain: true
--------------------------------------------
Hope this points a bit in the right direction for you, make sure that your MQTT broker is entered in the bed, the URL and the correct Password else nothing works.
Hope this helps a bit, good luck.
I am really sorry (I am not a SW person) but I still cannot understand how to bridge my
HA Mosquitto MQTT Broker with the external (I guess, Amazon) MQTT Broker.
This is an info how to connect to the the external MQTT Broker (I am not sure if this is enough):
AWS endpoint MQTT over TLS : a2k32ezw8t07q7-ats.iot.us-east-1.amazonaws.com:8883
Could you please provide me a detailed example how to bridge HA MQTT Broker with this
Amazon MQTT Broker?
Also I need to know which HA Configuration file must contain a MQTT Bridging entries?
Thank you,
The forum does have a search function
Yes, and I am using forum search, google search, etc …
I did learn a lot but still cannot get MQTT bridging working.
First of all - my HA installation came preloaded on ODROID N2+ hardware.
I am not 100% sure but I think this is Supervised HA installation. Am I right?
Second - I got a lot of info from Reverie tech support on how to configure MQTT.
I tested the connection with MQTT Explorer very successfully. So the provided info is correct and
sufficient for the establishing a successful connection to the AWS IoT MQTT Broker.
They also send me an info how to configure Mosquitto MQTT Broker:
log_dest stdout
log_type error
log_type warning
log_type notice
log_type information
connection awsiot
address XXXXXXXXXXXXXX.amazonaws.com:8883
topic # out
start_type automatic
try_private false
bridge_cafile /ssl/Amazon_AWS/XXX_CA.pem
bridge_certfile /ssl/Amazon_AWS/XXX_certificate.pem.crt
bridge_keyfile /ssl/Amazon_AWS/XXX_private.pem.key
My understanding is: the above configuration should be entered in the mosquitto.conf file
and file should be in the /share/mosquitto location.
I created a mosquitto folder ander /share and created a mosquitto.conf file with all the above entries.
Also I created a Amazon_AWS folder inder /ssl and pasted all 3 certificate related files into this folder.
I restarted MQTT Broker few times and even rebooted few times the HA.
But to my eyes the Mosquetto MQTT Broker does not use all my updated configurations.
Just in case, here is a Mosquuetto MQTT Broker log after rebooting the HA:
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/mosquitto.sh
[12:33:19] INFO: SSL is not enabled
cont-init: info: /etc/cont-init.d/mosquitto.sh exited 0
cont-init: info: running /etc/cont-init.d/nginx.sh
cont-init: info: /etc/cont-init.d/nginx.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun mosquitto (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
[12:33:20] INFO: Starting NGINX for authentication handling…
s6-rc: info: service legacy-services successfully started
[12:33:20] INFO: Starting mosquitto MQTT broker…
2023-05-19 12:33:21: Warning: Mosquitto should not be run as root/administrator.
[12:33:22] INFO: Successfully send discovery information to Home Assistant.
[12:33:22] INFO: Successfully send service information to the Supervisor.
Please advice what I am missing and how to get it working.
Thank you,
UPDATE
OK, I changed customization option to true:
customize:
active: true
folder: mosquitto
Now log said configuration was red:
[14:48:17] INFO: Starting mosquitto MQTT broker…
1684522097: Loading config file /share/mosquitto/mosquitto.conf
but bridge still is not working. At least I don’t see any evidence.
UPDATE 2
I enabled all logging (added log_type all to the conf file) and i can see some log entries
related to the attempted connection to the AWS IoT MQTT:
2023-05-19 18:48:52: Bridge local.HomeAssistant doing local SUBSCRIBE on topic #
2023-05-19 18:48:52: Connecting bridge awsiot (xxxxxxxxx-ats.iot.us-east-1.amazonaws.com:8883)
2023-05-19 18:48:52: Bridge HomeAssistant sending CONNECT
2023-05-19 18:48:52: mosquitto version 2.0.15 running
2023-05-19 18:48:52: New connection from 127.0.0.1:44288 on port 1883.
2023-05-19 18:48:52: Client closed its connection.
2023-05-19 18:48:52: Client local.HomeAssistant closed its connection.
If I am not mistaken local Mosquitto MQTT Broker closes the connection.
What is wrong in my configuration?
This is Supervisor checking the Mosquitto add-on, and is normal behaviour. Nothing to do with your bridge.
Well, bridge is not working.
Obviously something is wrong but I cannot figure out what exactly.
Any ideas what to check or try are very welcome.
MQTT Experts,
Please advice.
I am desperately trying to get my setup working but now I am very confused what I am seeing.
I tried to execute mosquitto_pub command with multiple options from the Terminal window:
I am seeing exactly the same results regardless if Mosquitto MQTT Broker (HA add-on version)
is running or stopped. Of course, nothing is working. But it looks like bridging function may not
even required. I am very confused with my results.
When I am trying to use MQTT Explorer (on Windows 11 PC) everything is working perfectly fine.
Please help me to get things working from HA.
No, it is home assistant operating system.
mosquitto_pub is communicating directly with Amazon so your mosquitto.conf is irrelevant to mosquitto_pub
Try putting your bridging conf in a file just named bridge.conf in /share/mosquitto
And what makes you think it is not working? What does mosquitto_sub tell you?
Put another way, what are you are expecting to see?
I am trying to control my Smart Bed (Reverie 5D).
If I execute “PUBLISH” command from MQTT Explorer my bed is moving accordingly.
This tells me all provided info is 100% correct.
However when I am using “mosquito_pub” command from Terminal window with all the same
options/parameters nothing is happening, i.e. bed is not moving.
Response “Client HA_AWS received CONNACK (0)” tells me the connection to the AWS MQTT
was established. So, all certificates, etc is also correct and accepted from the MQTT CLI.
Something must be wrong with ether Topic or Payload or both.
Next line has a correct Topic name and sends 10 bytes as a Payload.
Number of bytes is correct but I don’t see how Payload looks like.
The working payload is in JSON format : {“ABC”: “number”} This works from MQTT Explorer but
fails from the HA MQTT CLI.
Do you have any idea what could be wrong?
If you showed us the payload instead of a picture of a red blob it might be helpful.
This is what I figured out. Further more, the behavior is the same even if I stopped Mosquitto
MQTT service in HA. The CLI command seems to be still doing the same things.
So, do I still need to add config for Bridge function?
My current mosquitto.conf file is this:
# log_dest stdout
# log_type error
# log_type warning
# log_type notice
# log_type information
# log_type all
connection awsiot
address a2k32ezw8t07q7-ats.iot.us-east-1.amazonaws.com:8883
topic # out 1
try_private false
cleansession true
clientid HA_AWS
start_type automatic
notifications false
bridge_protocol_version mqttv311
bridge_attempt_unsubscribe false
bridge_insecure false
bridge_cafile /ssl/Amazon_AWS/Amazon_AWS_CA.pem
bridge_certfile /ssl/Amazon_AWS/Amazon_AWS_certificate.pem.crt
bridge_keyfile /ssl/Amazon_AWS/Amazon_AWS_private.pem.key
Do I need to rename mosquitto.conf to bridge.conf ?
The location for the *.conf is /share/mosquitto
If I change active: false to active: true the conf file is/was used but this did not change a behavior,
logins: []
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
active: false <--- changed to true
folder: mosquitto
Anyway in mosquitto_pub you have to escape the quote marks, ie Using The Mosquitto_pub and Mosquitto_sub MQTT Client Tools- Examples
The payload format is: {“ABC”: “decimal_number”}
The info I was provided is CONFIDENTIAL. I am sorry, but because it is confidential I
cannot tell you the exact ABC value and exact decimal_number value.
I guess, the format of Payload is important but actual values should not matter.
Yeah and that kinda sucks, to seek help from an OS community for some bullshit confidentiality bollocks. I guess they aren’t interested in helping their customers.
I am/was very surprised they actually sent me all this confidential info in a first place.
For them I am just a regular customer.
But everything is actually working just fine from MQTT Explorer (Windows app).
Now my goal is to get it working from HA. And I guess, I am just a heir away from the success.
Unfortunately my software skills are very limited but I hope, i will get it working.
If you don’t mind, could you please provide me an example of 100% working CLI command?