OwnTracks on iOS - 2 devices not reporting, one is

Yes (I don’t use any iPhones, and it sounds like the iPhone interface is a bit different).

I’d suspect a configuration error with OwnTracks, but you say you’ve checked that they’re all configured correctly.

I’ve updated the subject to match what you’re describing, which hopefully will attract others who’re familiar with OwnTracks on iOS

Thank you for your help. At this time, it looks to me that I have two problems.

  1. Two of my iPhones are not reporting
  2. iPhone that is reporting is not updating HA.

I see in CloudMQTT that my phone sends location information, but, for some reason, it is not updated in HA.

Thank you.

If you’re not seeing the update in HA, then it means one of the following:

If you need help with those, you’ll need to provide the (correctly formatted - see the blue box at the top of every page) configuration settings from your configuration.yaml file.

I am trying to use formatting. Not sure if it works the way you wanted to.

I have this line in my /etc/mosquitto/mosquitto.conf file

    include_dir /etc/mosquitto/conf.d

This is my /etc/mosquitto/conf.d/cloudmqtt.conf file:

    connection cloudmqtt
    address mXX.cloudmqtt.com:12345
    remote_username XXXXX
    remote_password XXXXX
    clientid ha
    try_private false
    start_type automatic
    topic # in

I have this in my configuration.yaml file:

    device_tracker:
    # Owntracks
      - platform: owntracks
        max_gps_accuracy: 200
        waypoints: True
        waypoint_whitelist:
          - Phone1
          - Phone2
          - Phone3

Do you see anything wrong? Thank you very much for helping me.

Right, but in HA, what are your settings for MQTT?

Anything in /etc/mosquitto/ is the configuration for mosquitto, and isn’t used at all by HomeAssistant. Please see the link I provided above.

As for your device_tracker, that looks ok, but you need to get MQTT right before anything will turn up in your known_devices.yaml. Again, please read the documentation I linked to above.

Maybe I misunderstood, but in this questions; Multiple MQTTs issue I was told that I cannot use it because I have another MQTT configured.

I have MQTT working with my garage door now.

Because of that I removed MQTT section for Presence Detection from the configuration file.

Thank you.

Yes, you can only talk to a single MQTT server. That thread tells you that the solution is to bridge your local MQTT server with your CloudMQTT system(s).

Now, the important questions are:

  1. Are you using your local mosquitto install with your garage door opener?
  2. Did you follow the advice in that other thread to bridge to the remote CloudMQTT server?
  3. Have you checked that the bridge is working?

Sorry, I am very new to this and not sure if I could answer all your questions. I just discovered HA about a month ago.

  1. I believe that I am using local mosquitto with my garage door opener. The config file points to my local HA server with port 1883.
    This is config file on my garage opener RPi:
    mqtt:
        host: 192.168.1.112 #HA IP Address
        port: 1883
        user: username
        password: password
    doors:
        -
            id: 'Garage Door'
            relay: 23
            state: 17
            state_mode: normally_closed
            state_topic: "home-assistant/cover"
            command_topic: "home-assistant/cover/set"
    

I have this entry in my HA configuration file for MQTT Cover (Garage Door RPi):

    cover:
    # Garage Door
      - platform: mqtt
        state_topic: "home-assistant/cover"
        command_topic: "home-assistant/cover/set"
        name: "Garage Door"
        qos: 0
        retain: true
        payload_open: "OPEN"
        payload_close: "CLOSE"
        payload_stop: "STOP"
        state_open: "OPEN"
        state_closed: "STATE"
        optimistic: false
        value_template: '{{ value.x }}'
  1. Yes, I configured the bridge and opened port 1883 on my firewall.
  2. I do not know how to check if bridge is working.

Thank you.

Did you configure an incoming bridge (in CloudMQTT) or an outgoing bridge (in Mosquitto)?

If you configured an incoming bridge, please provide a screenshot so we can see the settings (mask the username/password and hostname). Have you checked that you can reach Mosquitto from the Internet? Indeed, why not simply create users in Mosquitto for your iPhones, and then point them directly at Mosquitto?

If you configured an outgoing bridge, please provide the entries in mosquitto.conf for the bridge (again, mask the username and password).

This is the bridge that I configured in CloudMQTT. I tried Out and Both, but nothing worked.

This is my /etc/mosquitto/mosquitto.conf file. I temporary started logging, everything is default:

    pid_file /var/run/mosquitto.pid
    user mosquitto
    port 1883
    listener 9001
    protocol websockets
    persistence true
    connection_messages true
    allow_anonymous false
    password_file /etc/mosquitto/pwfile
    include_dir /etc/mosquitto/conf.d
    log_dest file /var/lib/mosquitto/mosquitto.log
    log_facility 5
    log_type all

This is my /etc/mosquitto/conf.d/cloudmqtt.conf file:

    connection cloudmqtt
    address mXX.cloudmqtt.com:12345
    remote_username hass #user name one of the users I created in CloudMQTT
    remote_password hass #password one of the users I created in CloudMQTT
    clientid ha
    try_private false
    start_type automatic
    topic # in

I found something strange last night. I have logging enabled, so I run this command:

    sudo systemctl restart mosquitto

This is the output that I have in log file:

    1498411340: mosquitto version 1.4.12 (build date Thu, 25 May 2017 22:38:16 +0100) starting
    1498411340: Config loaded from /etc/mosquitto/mosquitto.conf.
    1498411340: Opening websockets listen socket on port 9001.
    1498411340: Opening ipv4 listen socket on port 1883.
    1498411340: Error: Address already in use
    1498411341: mosquitto version 1.4.12 (build date Thu, 25 May 2017 22:38:16 +0100) starting
    1498411341: Config loaded from /etc/mosquitto/mosquitto.conf.
    1498411341: Opening websockets listen socket on port 9001.
    1498411341: Opening ipv4 listen socket on port 1883.
    1498411341: Error: Address already in use

I guess the port 1883 is in use. When I change this port in /etc/mosquitto/mosquitto.conf to, for example, port 8883, the mosquitto service starts. When this service starts (I also change port in the bridge of the CloudMQTT and firewall rule), if I run tests, I see that whatever comes to CloudMQQT arrives. I can see it in log file.

How to “create users in Mosquitto for your iPhones, and then point them directly at Mosquitto?” Can you please point me to component that does it? Is there a difference between presence or what you suggested?

I worry that I add more components to HA, they will use MQTT and does it mean that I will have problem with every new switch, sensor, etc…?

Thank you.

So:

  • You’ve configured CloudMQTT to provide a bridge to your Mosquitto system
  • You’ve configured Mosquitto to provide a bridge to CloudMQTT

You only need one of those - do please read the thread you were referred to here. With just the Mosquitto bridge, you don’t need port forwarding.

Your next problem is finding the process that’s listening on port 1883:

sudo netstat -pant|grep 1883

Not all components use MQTT. If you do then you either need a single MQTT broker that everything talks to, or a working bridge between your central MQTT broker and all other MQTT brokers.

You create the users in Mosquitto. A quick Google search suggests you need mosquitto_passwd for creating the users, just as you did when you created the user for the bridge in from CloudMQTT.

You’re simplifying things. Right now you’re trying to use 2 MQTT servers, and bridge them. That’s perfectly possible, but it requires that you invest time and effort in ensuring you’ve got the bridges working. Right now, all the signs are that you’ve got a number of issues, including that you’ve got something other than Mosquitto running on port 1883.

To simplify it while you learn, you can either configure your garage opener to use CloudMQTT (to match the OwnTracks configuration), or you can configure OwnTracks to use your local Mosquitto server.

Thank you for helping me.

I read the thread and some people were saying that it did not work until they configured bridge in CloudMQTT, so I configured both. Also, someone was talking about firewall forwarding. I will remove the bridge and try it, but not sure why mosquitto service would not start. This is the output of the command you gave me:

    pi@Home-Assistant:~ $ sudo netstat -pant|grep 1883
    tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      510/python3
    tcp        0      0 127.0.0.1:35453         127.0.0.1:1883          ESTABLISHED 510/python3
    tcp        0      0 127.0.0.1:1883          127.0.0.1:35453         ESTABLISHED 510/python3
    pi@Home-Assistant:~ $

Also, I have this when I check status for mosquitto service:

    pi@Home-Assistant:~ $ sudo systemctl status mosquitto -l
    ● mosquitto.service - Mosquitto MQTT Broker
       Loaded: loaded (/lib/systemd/system/mosquitto.service; disabled)
       Active: failed (Result: start-limit) since Sun 2017-06-25 12:22:21 CDT; 1h 3min ago
         Docs: man:mosquitto(8)
               https://mosquitto.org/
      Process: 2452 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
     Main PID: 2452 (code=exited, status=1/FAILURE)
    Jun 25 12:22:21 Home-Assistant systemd[1]: Unit mosquitto.service entered failed state.
    Jun 25 12:22:21 Home-Assistant systemd[1]: mosquitto.service holdoff time over, scheduling restart.
    Jun 25 12:22:21 Home-Assistant systemd[1]: Stopping Mosquitto MQTT Broker...
    Jun 25 12:22:21 Home-Assistant systemd[1]: Starting Mosquitto MQTT Broker...
    Jun 25 12:22:21 Home-Assistant systemd[1]: mosquitto.service start request repeated too quickly, refusing to start.
    Jun 25 12:22:21 Home-Assistant systemd[1]: Failed to start Mosquitto MQTT Broker.
    Jun 25 12:22:21 Home-Assistant systemd[1]: Unit mosquitto.service entered failed state.
    pi@Home-Assistant:~ $

I can make it work if I change the port from 1883 to 8883, but I do not know if it will effect anything else. What do you think?

Thank you.

I removed the bridge in CloudMQTT and changed port from to 8883. Mosquitto started and, when something comes from CloudMQTT, the misquitto log shows me the following:

    1498418642: Sending PINGREQ to local.ha
    1498418642: Received PINGRESP from local.ha
    1498418701: Sending PINGREQ to local.ha
    1498418702: Received PINGRESP from local.ha
    1498418761: Sending PINGREQ to local.ha
    1498418762: Received PINGRESP from local.ha
    1498418793: Received PUBLISH from local.ha (d0, q0, r0, m0, 'owntracks/Phone1/P1', ... (154 bytes))
    1498418822: Sending PINGREQ to local.ha
    1498418822: Received PINGRESP from local.ha
    1498418881: Sending PINGREQ to local.ha
    1498418882: Received PINGRESP from local.ha
    1498418911: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1498418917: Received PUBLISH from local.ha (d0, q0, r0, m0, 'owntracks/Phone2/P2', ... (148 bytes))
    1498418941: Sending PINGREQ to local.ha
    1498418942: Received PINGRESP from local.ha
    1498419002: Sending PINGREQ to local.ha
    1498419002: Received PINGRESP from local.ha
    1498419062: Sending PINGREQ to local.ha
    1498419062: Received PINGRESP from local.ha

The presence coordinates for the users do not change. Maybe because of that port, but I am not sure.

Any ideas?
Thank you.

Your first problem is because some python3 process is listening on that port. Possibly that’s the HomeAssistant process, since it has a built in (very limited) MQTT broker. Please provide the output of:

ps axu | egrep "\s510\s"

The coordinates not updating suggest that the phone isn’t pushing updated coordinates. Are you sure they are?

This is the output of that command:

    pi@Home-Assistant:~ $ ps axu | egrep "\s510\s"
    homeass+   510  2.8  6.2 175364 59276 ?        Ssl  09:49   9:33 /srv/homeassistant/homeassistant_venv/bin/python3/srv/homeassistant/homeassistant_venv/bin/hass -c /home/homeassistant/.homeassistant
    pi@Home-Assistant:~ $

I am sure that updates are coming because, if I remove my garage door and configure HA to use Presence without all this modifications, everything works.

Thank you.

So, it looks like currently HA thinks it needs to start it’s internal MQTT broker, which is the source of your port clash. The garage door opener is reporting to it, hence why that works yet your Mosquitto bridge to CloudMQTT doesn’t appear to do anything for you.

Configuring mqtt as you’ve done should stop that happening. Do you have any other mqtt lines in your configuration?

I do not have anything else that uses mqtt at this time, Just starting with HA, but I believe that I have more later.

Sorry, but I did not understand what you mean by configure mqtt as I have done. Do you mean to change port to 8883? It is like that now, but the presence status is not updating.

Any ideas what can I do to fix the presence?

Thank you.

Ok, first thing to do is post your entire configuration.yaml, and any files you include, removing any usernames and passwords. It’s likely that you’ve got multiple mqtt: entries, which is causing HA to start it’s own internal broker.

Once we’ve fixed that, we should be able to fix the presence detection.

Here is my configuration.yaml file:

    homeassistant:
      # Name of the location where Home Assistant is running
      name: Home
      # Location required to calculate the time the sun rises and sets
      latitude: 55.5555555
      longitude: -55.5555555
      # Impacts weather/sunrise data (altitude above sea level in meters)
      elevation: 301
      # metric for Metric, imperial for Imperial
      unit_system: imperial
      # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
      time_zone: My/Location
      customize:
        cover.garage_door:
    #      friendly_name: Garage
          icon: mdi:garage
        switch.coffee_maker:
          icon: mdi:coffee
    # Show links to resources in log and frontend
    #introduction:
    # Enables the frontend
    frontend:
    # Enables configuration UI
    config:
    http:
      # Uncomment this to add a password (recommended!)
      # api_password: PASSWORD
      # Uncomment this if you are using SSL or running in Docker etc
      # base_url: example.duckdns.org:8123
      api_password: MyPasswordHere
    # Checks for available updates
    # Note: This component will send some information about your system to
    # the developers to assist with development of Home Assistant.
    # For more information, please see:
    # https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
    updater:
      # Optional, allows Home Assistant developers to focus on popular components.
      # include_used_components: true
    # Discover some devices automatically
    # discovery:
    # Allows you to issue voice commands from the frontend in enabled browsers
    conversation:
    # Enables support for tracking state changes over time.
    history:
    # View all events in a logbook
    logbook:
    # Track the sun
    sun:
    # Text to speech
    tts:
      platform: google
    ###################Customized##################################
    binary_sensor:
    # Ring Doorbell
      - platform: ring
        monitored_conditions:
          - ding
          - motion
    cover:
    # Garage Door
      - platform: mqtt
        state_topic: "home-assistant/cover"
        command_topic: "home-assistant/cover/set"
        name: "Garage Door"
        qos: 0
        retain: true
        payload_open: "OPEN"
        payload_close: "CLOSE"
        payload_stop: "STOP"
        state_open: "OPEN"
        state_closed: "STATE"
        optimistic: false
        value_template: '{{ value.x }}'
    device_tracker:
    # Owntracks
      - platform: owntracks
        max_gps_accuracy: 200
        waypoints: True
        waypoint_whitelist:
          - Phone1
          - Phone2
          - Phone3
    # Ring Doorbell
    ring:
      username: [email protected]
      password: MyPasswordHere
    sensor:
    # Weather Prediction
      - platform: yr
    # CPU Speed
      - platform: cpuspeed
    # System Monitor
      - platform: systemmonitor
        resources:
          - type: disk_use_percent
            arg: /home
          - type: memory_free      
    # Ring
      - platform: ring
        monitored_conditions:
          - battery
          - last_activity
          - last_ding
          - last_motion
          - volume
    switch:
    # Coffee Maker
      - platform: tplink
        host: 192.168.1.114
    # Zones
    zone:
      name: Home
      latitude: xx.xxxxxxx
      longitude: -xx.xxxxxxx
      radius: 100
      icon: mdi:home
    zone 2:
      name: Work
      latitude: xx.xxxxxxx
      longitude: -xx.xxxxxxx
      icon: mdi:worker
    zone 3:
      name: MiddleSchool
      latitude: xx.xxxxxxx
      longitude: -xx.xxxxxxx
      radius: 250
      icon: mdi:school
    zone 4:
      name: HighSchool
      latitude: xx.xxxxxxx
      longitude: -xx.xxxxxxx
      radius: 250
      icon: mdi:school
    group: !include groups.yaml
    automation: !include automations.yaml

This is my automation.yaml file:

    - alias: Turn Off the Coffee Maker At Midnight
      condition:
        condition: state
        entity_id: switch.coffee_maker
        state: 'on'
      trigger:
        platform: time
        at: 00:00:01
      action:
        service: switch.turn_off
        entity_id: switch.coffee_maker

This is my groups.yaml file:

    default_view:
    #test:
      name: Home
      view: true
      entities:
      - group.garage_door_group
      - switch.coffee_maker
      - device_tracker.phone1_p1
      - device_tracker.phone2_p2
      - device_tracker.phone3_p3
      - sensor.yr_symbol
      - sun.sun
    Automations_View:
      name: Automations
      view: true
      entities:
      - automation.turn_off_the_coffee_maker_at_midnight
    Garage_Door_Group:
      name: Garage Door
      entities:
      - cover.garage_door
    Ring_Group:
      name: Ring
      entities:
      - binary_sensor.ring_front_door_ding
      - binary_sensor.ring_front_door_motion
      - sensor.ring_front_door_last_activity
      - sensor.ring_front_door_last_ding
      - sensor.ring_front_door_last_motion
      - sensor.ring_front_door_battery
      - sensor.ring_front_door_volume
      - sensor.ring_office_volume
    Ring_View:
      name: Ring
      view: true
      entities:
      - group.ring_group
    System_Group:
      name: Local System
      entities:
      - sensor.cpu_speed
      - sensor.disk_use_home
      - sensor.ram_free
    System_View:
      name: System
      view: true
       entities:
      - group.system_group

Thank you.

So, it would appear you’ve removed the mqtt: configuration, which is why the internal broker is starting. You need to restore that and shut down HA so you can start Mosquitto. Once you start Mosquitto and it’s running, then you can start HA again.

mqtt:
    host: 192.168.1.112 #HA IP Address
    port: 1883
    user: username
    password: password

Once you’ve done that, and the garage door opener is correctly working, we can tackle the presence detection.