MQTT Configuration (CloudMQTT, OwnTracks)

My ultimate attempt is to have the front porch lights turned on by the time I pull down my driveway. I decided to use CloudMQTT (not sure if that is a wise choice) but when I get home, my lights are not on.

To detect and publish my location to CloudMQTT, I am using OwnTracks.

Any ideas as to what I’m doing wrong or should be doing different?

Own tracks is configured to use Significant Change Monitoring Mode, but also used Move Monitoring Mode which didn’t work.

This is from my configuration.yaml:

mqtt:
  broker: m16.cloudmqtt.com
  port: 
  keepalive: 60
  username: 
  password: 
  
owntracks:
  max_gps_accuracy: 200
  mqtt_topic: "owntracks/#"
  events_only: false  
  
zone:
  - name: Home
    latitude: 
    longitude: 
    radius: 500
    icon: mdi:worker  

This is my automation.yaml

- alias: Lights - Front Porch - Come Home After Sunset
  trigger:
    platform: state
    entity_id: device_tracker.phone_capo
    to: 'home'
  condition:
    condition: sun
    after: sunset
  action:
    - service: light.turn_on
      data:
        brightness: 255
        entity_id:
          - light.porch
    - delay: '00:04:00'
    - service: light.turn_off
      data:
        entity_id:
          - light.porch

Does your automation run correctly if you manually trigger it? What does your owntracks device tracker sensor show in HA when you pull into your driveway? Have you sat there and watched to see how long it takes to show you home? Have you tried manually updating your location from owntracks while in your driveway to determine if owntracks is slow or you have another issue? Have you tried making your home zone bigger so owntracks will switch to home sooner?

I used to use owntracks (using Ariela now) in conjunction with WIFI and bluetooth presence detection for faster more reliable home/away detection. Not sure how far away bluetooth/wifi would pick you up outside for what you’re trying to do though.

First off you need to be sure that status updates from owntracks arrive on your machine. I did it by looking at my phones battery status. That status gets transmitted to HomeAssistant too, so you can somewhat tell when and if the update arrived. (You can also check timestamps, if you know where to look)

On my Server, I have installed “Mosquitto”, which is a private version of CloudMQTT. Basicly it does not make any difference, since both do the same thing. I prefer using Mosquitto because
a) I have a PC with HA running, so adding Mosquitto is no issue at all
b) my data stays in my hands

as for setting up HA, I have the following entries in my configuration.yaml

device_tracker:
  - platform: mqtt
    devices:
      user:
        'owntracks/user/device'

mqtt:
  broker: [IP]
  port: [PORT]
  client_id: !secret mqtt_user
  username: !secret mqtt_user
  password: !secret mqtt_password

owntracks:
  max_gps_accuracy: 75
  mqtt_topic: "owntracks/#"
  keepalive: 60
  protocol: 3.1.1
  waypoints: true
  secret:
    owntracks/user/device: !secret mqtt_user

These entries do the following:
device_tracker:
Allowes the device_tracker to access mqtt data and use it with your “known_devices.yaml”
“user” is the thing after “device_tracker.” which in your case is “phone_capo”. However, “user” in “owntracks/user/device” may be different!!! you have to take whatever you typed into Owntracks as “UserID”! Same for device, use whatever you typed into “DeviceID”.

mqtt:
Gives HA the credentials to access your mqtt broker by giving ip, port and credentials to log-in.

owntracks:
That’s HAs included tracker. Basicly it helps HA to read your received data. In my case I have set Owntracks to encrypt my location-data so noone can read it. If you want that too, HA needs the password you have set. (I use a file called “secret.yaml” in the same folder as configuration.yaml is – alternatively you can type your password in clear text there)

Please try using this template and fill in your personal informations for it to work. If HA is able to show your mobile’s battery status, you are good!

Edit: What you also may need to do is to edit your “known_devices.yaml”. More information on that are here, at the bottom end of the page: https://www.home-assistant.io/components/owntracks/

I played with Node Red to connect Cloud Mqtt to Mosquitto with success, using a Mqtt input node configured to Cloud Mqtt going to a local Mqtt output node for example Mosquitto it’s a bit of a hack but it’s worked for me for about a year with little problems.

Thanks for your help! I learned the automation was off, which is why it was not working. Thank you again!

I’m newbie with mqtt (cloudmqtt) how to add a second user to ‘owntracks/user/device’ ?
I need to add multiple. A simple code would be appreciated
Thanks

Any hint to suggest?

Why do you want to add multiple users to the same device tracker ? HA will never know where you are if it receives data from multiple users.

I think you want to add a second (or more) device tracker for other users.

Exact I want add my wife

But I don’t know how

try :

device_tracker:
  - platform: mqtt
    devices: 
      {my-device-id1}: 'owntracks/{my-username1}/{my-device-model}'
      {my-device-id2}: 'owntracks/{my-username2}/{my-device-model}'
  - platform : owntracks
    max_gps_accuracy: 200
    mqtt_topic: "owntracks/#"

It does not opn port 8123:

- platform: mqtt

    devices:

      RF: 'owntrack/Raffaele/iphone6S'

      CV: 'owntrack/Chiara/iphone6S

    mqtt_topic: "owntracks/#"

What I’m misssing?
Tried owntrack and owntracks

Tried also your code but cannot access to HA

[quote={my-device-id1}: ‘owntracks/{my-username1}/{my-device-model}’
{my-device-id2}: ‘owntracks/{my-username2}/{my-device-model}’’
[/quote]

What do you mean for my-device-id ?