Presence detection via Tasker and MQTT (Android only)

I have my own .com domain name. I use cloudflare to manage it (free). So I effectively have unlimited sub-domains.
In letsencypt you get a separate ssl certificate per sub domain.
I did hear somewhere that lets encrypt may be doing wildcard ssl certificates soon so in theory you could have one ssl certificate for all. But you will need your own domain name to do that.

I see.

I managed to have nginx, on a pi3, work for HASS using letsencypt and duckdns.org.
So far so good.

Now I wish to fix mqtt, with SSL, and nginx, having a hard time.

Also i didn’t understand how to configure nginx for accessing other services at home when I am outside my network

You can also use Automate instead of Tasker. I’ve made three Owntracks compatible location Flows you can install directly from the app.

I had issues where Tasker stops publishing mqtt messages without any errors. Now I am using httt post and script to publish mqtt mesagges and it seems that this works more reliably. Also, I do not need to rely on Tasker MQTT plugin which is relatively slower than http post. I am relatively new to home assistant and do not have python knowledge so I may wrong…

I too have switched to http post, yes much more reliable than mqtt…

I have the following setup in tasker / ha / owntracks. Owntracks is set to use private mqtt server running on my hassio.

Tasker: On wifi connect.

  1. Use http post to update a h.a. sensor to the name of wifi ssd i connected.
  2. Use hhtp post to run a script on ha. That script sends an mqtt signal from h.a. to owntracks to force a location update.

Tasker: on wifi disconnect

  1. Update the ha wifissd sensor to ‘away’
  2. Delay 5 min then do a force owntracks mqtt Location update.

Hi - could you share more specifics about how you did the http post with Tasker? I am not having success with doing that. Can’t get the post to deliver json service data. Are you using shell scripts, or what exactly has worked for you? Thanks.

First I assume you have the ability to access home-assistant from outside your home network.

I use the Tasker HTTP Post action:-

In “Server:Port:”

https://home-assistant.wherever.com/api/states/sensor.myphone?api_password=mypassword
Whatever DNS…you really need dns…you have setup to point to your home IP.

if you access via the standard port then:

https://home-assistant.wherever.com:8123/api/states/sensor.myphone?api_password=mypassword

In “Data/File”:

{"state":"%location","attributes": {"battery": "%BATT", "charging": "%Charging","wifi_ssid":"%wifi_ssid","latitude":"%lonlat1","longitude":"%lonlat2"}}

The variable %location for me is either ‘home’ or ‘away’. The rest are pretty obvious

1 Like

Thank you for sharing all those specifics. It turns out that I am able to update a sensor, as you are doing, with Tasker HTTP post. And I am set up just that way, meaning that I have DNS and https. (And by the way, that is pretty cool!)

However when I try to pass data to a service with Tasker HTTP post, for example, by trying to pass properly formed json to /api/services/light/turn_off it always comes back with a 400 error. I have tried all different options for syntax, and none of them work. If I pass no service data at all to the service, then it will turn on all my lights, but I just can’t find a way to use the Tasker HTTP post to send data to a service.

People seem to be successful doing this same thing with curl, but for whatever reason home assistant doesn’t seem to like the way Tasker passes data to a service??

If you are able to succeed using Tasker to post to a service, and turn a light on or off, I would definitely be interested in finding out what the secret sauce is!

i also used http post in the pre token era and now i feel a bit lost…

mqtt sounds nice but is too unreliable for presence detection imho

anyone with a good setup right now that does not require api_password?

The guy in this post provided a solution for the new auth system. It works for me.

2 Likes

Hello everybody,

You may also check this:Ariela - Home Assistant Android Client
Its and android client for Home Assistant with build in device tracker (GPS or Wi-Fi or both), MQTT sensors, push notifications etc.