Thanks @elPaulio… Your provided link is a good one… Though, it wasn’t fixed straightway, after several times installing/uninstalling and tinker with the mosquitto config file and the app, finally it worked.
Interestingly, when it works, its awesome, simply awesome! I still have some confusion though. I have two zones configured in my setup, but it looks the owntracks reported accuracy doesn’t meet the criteria of zone, hence is not updating the zones very reliably.
The confusion is with the usage of two device tracker simulatanously (in my case Netgear and Owntracks). The known_devices.yaml file is filled with two entries one from Netgear component another from owntracks component; I then followed the documentation of owntracks to fill the _ entry. After this part, two issues arise, one is a warning that reports that duplicated entries found, second is there is two entity_id to represent a device now, I am not sure what entity should I use to show in the frontend. So, I configured the group to show owntracks_device entity_id for showing my location and Netgear entity_id to represent my other users. Can anyone suggest here ?
And last thing is, as I went through a lot of hassle and good amount of time to set this thing properly, I would like to write up a summary steps for future reference for the novice like me…
Summary Steps:
Assumptions:
Home-assistant is running on raspberry-pi and the OS is very recent hassbian.
- Install Mosquitto-Server in Raspberry-pi either by following these two commands:
sudo apt-get install mosquitto
sudo apt-get install mosquitto-client
Or completely following the link provided in step 2. In my case, I finally installed in this way as I was having trouble to auto start mosquitto server by following the steps mentioned in the post.
- Then configure the mosquitto server by following the link provided by @elPaulio ( Question | DigitalOcean ). If more than one person is going to use this setup, then create users accordingly but in this case the command should be a bit different (omit -c switch). e.g. mosquitto /etc/mosquitto/pwfile yourusername instead of mosquitto /etc/mosquitto…
Note: If step 1 is followed, only the user creation part,config file creation and Testing part should be copied.
-
For hassbian OS, MQTT is disabled, expert Linux users might do it differently/accurately but I did it whatever I understood remove the mosquitto.override by sudo rm /etc/init/mosquitto.override
-
Test the MQTT setup by mosquitto_pub/sub command , reference would be found in the link.
-
If all good, then configure the home-assistant configuration yaml file by following the mqtt component and. This configuration will set hass as a mqtt client. Restart the machine which should auto start mosquitto server and hass server if all is well so far. And you shouldn’t see any mqtt related error in the log.
-
Now time to install the owntracks app in device, I found the app configuration is somewhat clumsy. So, it’s worth a few words. In the app configuration, go to mqtt private mode and fill in the host, port [uncheck websocket], in Identification fill in user/pass with the device ID. In security, unless you have set up certificates to use, just uncheck TLS (I found this damn thing auto enabled itself if just clicked which causes a lot of trouble, so make sure it is unchecked). Then in this configuration window, you should see a notification (connected/not connected) if clicked the tick symbol. Then go back , you are good to go for the owntracks configuration in hass now.
-
In hass configuration under device_tracker, follow the owntracks component in the documentation, it should be straight forward. However, if you modify some part e.g. waypoint: True then must fill up the Waypoint whitelisting entities. Those entities should be the mqtt usernames exactly you created during mosquitto_password setup. Time to restart hass once again.
-
Now time to check the known_devices.yaml and look for the entry similar to “user_device”, if you didn’t find it yet, try to manually push a notification from the app by pressing the up arrow button in the home page. Once you found the entry, all good unless you have another entry with the same device with under some other device_tracker (e.g. Netgear/NMAP), in that case dont remove the entries rather copy the MAC address from the previous entry to the blank field of new entry. Time to restart hass one more time.
-
If you had followed so far, the next part is the easiest. Check for the entity_ID in hass /dev-state. Look for a new entry like device_tracker.username_deviceid. If there is one, just add this entity to show in the front end. If no default_view is configured, it should be shown automatically, if configured, you already know how to show it in frontend, so not going further in this part.
-
Some handy commands:
To manually start and test the server in case auto start is not happening:
sudo mosquitto -c /etc/mosquitto/mosquitto.conf
sudo mosquitto_sub -h server_ip_address -v -t owntracks/# -u username -P password
To create and/or update password of a single user:
sudo mosquitto_passwd -c /etc/mosquitto/passwd username
To add another user:
sudo mosquitto_passwd /etc/mosquitto/passwd username
Hopefully, this steps would save some time for the future novices like me who is roaming like a headless chicken
Thanks all for your responses… You guys really rock.