I have owntracks in configured in device_tracker.yaml file.
- platform: owntracks
max_gps_accuracy: 75
waypoints: yes
and my cloudmqtt.conf look like this -
connection cloudmqtt
address m11.cloudmqtt.com:1111
remote_username xxx
remote_password xxx
clientid xxx
try_private false
start_type automatic
topic # in
and i am getting requests from owntrack from android with this command -
mosquitto_sub -h m11.cloudmqtt.com -p xxx -u xxx -P xxx -t ‘#’ -v
On HA i have configured sensor for battery as -
- platform: mqtt
state_topic: 'owntracks/xxxh/Nx'
name: Battery N4
unit_of_measurement: "%"
value_template: '{{ value_json.batt }}'
but no value. I can see the value if run from ssh.
I have local broker also and is working fine… so i bridged cloudmqtt.conf. Am i missing something
Mukund
(Mukund)
April 28, 2017, 7:20am
17
I finally got this working after following this post and some others. There are a few things that need to be done for it to work end-to-end.
In /etc/mosquitto/mosquitto.conf file add
include_dir /etc/mosquitto/conf.d
in /etc/mosquitto/conf.d directory create a file as per the OP
connection cloudmqtt
address <host:port >
remote_username <>
remote_password <>
clientid <>
try_private false
start_type automatic
topic # in
Your device_tracker config should look like his
device_tracker:
platform: mqtt
devices:
paulus_oneplus: /location/paulus
annetherese_n4: /location/annetherese
from: MQTT device tracker - Home Assistant
What I also did was to create a bridge on cloudmqtt to my local mosquitto install.
First I created a new user in mosquitto by doing
sudo mosquitto_passwd /etc/mosquitto/pwfile username
Go to the Cloudmqtt console and create a bridge to your local mosquitto.
url: mqtt://USER:PASSWORD@host:port
Direction: out
Local Prefix: owntracks/#
Remote Prefix: owntracks/#
Obviously I had to portforward in the router to the local mosquitto port.
Hope this helps
Mukund
1 Like
You can create bridge on your local MQTT Server and you do bot need port forwarding for it. Connection initiator will be local MQTT server not CloudMQTT
1 Like
Mukund
(Mukund)
April 28, 2017, 11:14am
19
Didn’t work for me, so I did the other way. I’ll try disabling the bridge from cloudmqtt and see if the connections stay.
If you don’t configure bridge on local MQTT connection wil be lost.
Here is my config for brdging mosquitto with cloudmqtt
connection couldmqtt
address <your cloudmqtt account>
topic # in 1
try_private true
notifications false
start_type automatic
remote_clientid <your client id>
remote_username <your user name>
remote_password <your password>
keepalive_interval 300
cleansession true
bridge_protocol_version mqttv311
local_clientid hass
bridge_cafile /etc/ssl/certs/ca-certificates.crt
bridge_insecure false
3 Likes
@sffjunkie
Confirmed working with below.
1 Like
davedan
(Dave Dan)
April 30, 2017, 5:38am
22
I wonder where is the certificate coming from. Is this something that can be downloaded from the cloudmqtt website? It’s from your own environment (meaning your own cert)?
I gave this a couple of tries but I can make it work.
The cert is not created or added by you.
I think it’s installed as part of HA…
Just looked at mine and it is dated 2/2/2017
Mukund
(Mukund)
April 30, 2017, 8:10am
24
Can you please share your /etc/mosquitto/mosquitto.conf file?
Cant get it to work. Keep getting the following
Connecting bridge cloudmqtt (instance.cloudmqtt.com :port)
1493539560: Connecting bridge cloudmqtt (instance.cloudmqtt.com :port)
1493539560: Bridge mosquitto-cloudmqtt-bridge sending CONNECT
1493539561: Socket error on client cloudmqtt, disconnecting.
Mukund
(Mukund)
April 30, 2017, 8:28am
25
ok, confirmed working with SSL port.
This is list of root CA’s. It’s a part of OS. It’s required to verify CouldMQTT cert which presented during connection establishment.
Mukund
(Mukund)
May 1, 2017, 6:10am
27
Now something else is wrong with my config.
Since getting this working I’ve pointed my device_tracker config to mqtt. Now the status doesn’t seem to be getting updated.
Instead i get the raw JSON as the state of the devices.
my MQTT settings are as below. Can you please tell me what i’m doing wrong?
mqtt:
broker: 127.0.0.1
port: 1883
client_id: home-assistant-1
username: pi
password: !env_var password_mqtt
discovery: true
protocol: 3.1
keepalive: 60
Mukund
(Mukund)
May 1, 2017, 10:18pm
28
this is now fixed. All i had to do was change the device tracker to cloudmqtt platform.
Do you mean setting the platform to owntracks because I’m getting errors when using cloudmqtt as platform.
Mukund
(Mukund)
May 13, 2017, 11:13am
31
Yes, sorry. That’s what i meant.
platform: owntracks
Cloudmqtt in a broker. It receives a store messages from your owntracks app.
Thanks!
Although my ha location does not seem to update when using the local mosquitto mqtt(I’ve set up the bridge to cloudmqtt) server. I’m not getting any errors but it just doesn’t update.
My in my configuration.yaml I have:
mqtt:
broker: 127.0.0.1
port: 1883
client_id: home-assistant-1
username: mosquitto user name
password: mosquitto password
discovery: true
keepalive: 60
And also:
device_tracker:
- platform: owntracks
max_gps_accuracy: 75
Then I have to following text in the cloudmqtt.conf file under /etc/mosquitto/conf.d:
connection couldmqtt
address my cloudmqtt serveradress:my cloudmqtt SSL port
topic # in
try_private true
notifications false
start_type automatic
remote_clientid ha
remote_username cloudmqtt username
remote_password cloudmqtt password
keepalive_interval 300
cleansession true
bridge_protocol_version mqttv311
local_clientid hass
bridge_cafile /etc/ssl/certs/ca-certificates.crt
bridge_insecure false
Does anyone know what I’m doing wrong?
How is your owntracks configured?
I’ve configured it to connect to to the cloudmqtt server with another user than the one I’m using to bridge mosquitto to cloudmqtt.
So when looking in the cloudmqtt console under websocket I can se the location is sent from owntracks but it does not update in ha. I’m thinking maybe somethings wrong with the bridge?