Why not have remote access?
Why is the point of a smart home if the smart home can’t communicate with you?
If you have an encrypted remote access then it’s as safe as any online bank.
Also if you think about it, what are the odds that someone drops in to your IP and port number (or DNS), and can guess your username and password?
Unless you have “user” and “password” then I could say it’s safe.
And if you are still worried then activate the two factor authentication, set up a ip_ban when multiple attempts are incorrect.
I assume you mean SSL (https) when you say “encrypted remote access” with the addition that I then would be as safe as any online bank. Yes, perhaps I would, but it’s not a valid comparison, it’s not only an auth or encrypted transport problem. I have absolutely no interest in exposing my network nor my server(s) to the Internet, and no HA https endpoints can help me with that.
And my point with a smart home is that my home is (should be) smart, I use only automations. If I on the rare occassion need to access HA, I use vpn.
On topic again, it would be so great if there were a background app that periodically “pinged” (either by icmp or udp) some LAN endpoint (like the HA server). If I had that, I could use the last ping timestamp to determine presence, without being dependent on remote access, vpns, routers that don’t report properly, phones that turn off their wifi, or wifi extenders that hide the wifi connection… Since the app would be extremely lightweight and out of the way, all members of my household could use it. (I was hoping that my kids would be able to use my “solution” above, as well.) I’m a developer, but I’ve never made a mobile app, so yeah…
It’s not only about accessing the system to check something.
Let’s say you have a camera and door sensors or whatever as a security system. Now you left home and 1 hour later someone breaks into your house. You’ll only be notified about this once you log into the VPN or arrive back home, which would make the security system more or less useless.
If you really don’t want to enable remote access, here’s another solution that works really good.
With this approach you’d need one xiaomi door/window sensor for each person in the household and one magnet attached to their keys or something else they always carry with them when outside home. As soon as you arrive home, you put the magnet on the door sensor and it reports you as home, once you leave the house you take your keys and it reports you as not home. You can then add some delays like “only show me not home when the sensor is off for x minutes” or "only trigger the alarm 5 minutes after a motion trigger so that you have enough time to put the magnet to the sensor.
Haha, that’s cool, although contrived I like it, but I like my approach a lot better, since it requires no extra hardware or anything (only this minimal app and an endpoint - or, presumably, a working implementation of the location_background HA mobile app sensor).
Of course I have notifications - why would I require remote access for egress communication?
So, inspired by Burningstone’s input I now have something up and running. I guess this also could be called “contrived”, but it fits into my ecosystem here at home. I started looking into Tasker and similar apps, and since I just wanted to create a PoC, I’ve chosen to use the free MacroDroid app. The setup consists of three parts, in a sense.
Pinger macro. I’ve created a macro in MacroDroid that periodically (every 60 seconds) sends a special GET request, under the condition that I’m connected to my home wifi. The GET request is sent every 60 seconds to (something like) http://$HA_HOST:$SOME_PORT/$NAME, where $NAME is just a person identifier. The endpoint is handled by a Python web server that I’ve written for this purpose.
Web server. This (Python) web server keeps track of all $NAMEs as well as their last “ping”, and it prunes the state for a $NAME that hasn’t pinged for 90 seconds.
HA API. I’ve enabled the HA API by adding api: to configuration.yaml. The Python web server sends requests to the “See” device tracker endpoint, http://$HA_HOST:8123/api/services/device_tracker/see, with the data {"dev_id": "$NAMEs_presence", "location_name": $LOCATION_NAME}, where $LOCATION_NAME is either “home” or “not_home”; the former is sent when the presence state is created for $NAME, and the latter is sent when the presence state is pruned for $NAME (as well as when the server is stopped).
The next/final step would be to create a lightweight standalone task/app (for instance using Tasker), that would send the GET request periodically.
Hello,
Sorry for coming a bit late ; did you manage to have it working ?
You could try to use an android app such as Presence Publisher, which sends MQTT messages on conditions to be defined (for example Wifi connection to your home SSID). That’s what I used on another domotic system I used before, didn’t set it up yet on HA anyway.
I’m trying to use WiFi connection name to detect presence, too. Especially for zones different from home that do not have a smart router or HA server locally. The problem is that HA companion app does detect changes in Wi-Fi connection if the app is in background on Android 13 with all battery optimisation methods turned off. As a result this approach of using Wi-Fi connection name for zone detection does not work. Any ideas how to fix that?
I am using the WIFI connection name too for presence detection, for home or when i am at work (here to turn the ringers off and on when i am leaving work). This works really fine for me, even ha companion is in the background the wifi name sensor changes.
What for a phone are you using? I am on a Samsung S21 and with all battery optimizations disabled it works really good.
Sure, here we go. The first one is for the ringer of the phone as an automation:
- id: smartphone_en_disable_mike_ringer_handy
alias: Smartphone - Ringer für Zone Work ein und ausschalten # Schaltet den Klingelton für Work ein und aus
description: 'Smartphone - Ringer für at Work ein und ausschalten'
initial_state: true
trigger:
- entity_id: sensor.sm_mike_wifi_connection
platform: state
to: 'YOUR WLAN SSID'
id: 'come_work'
- entity_id: sensor.sm_mike_wifi_connection
platform: state
from: 'YOUR WLAN SSID'
id: 'leave_work'
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: 'come_work'
sequence:
- service: notify.mobile_app_sm_mike
data:
message: "command_ringer_mode"
data:
ttl: 0
priority: high
command: "vibrate"
- conditions:
- condition: trigger
id: 'leave_work'
sequence:
- service: notify.mobile_app_sm_mike
data:
message: "command_ringer_mode"
data:
ttl: 0
priority: high
command: "normal"
For presence detection you could for example use a binary sensor:
I have more than one SSID (one for 2.4 and one for 5 GHz), if you only have one you can delete the second part including the or. I am using it on android, for ios it might be slight different. The automation with muting the ringer won’t work as far as i know, because you cannot mute the ringer with a notification command on android.