Home Assistant + ESPresense (Room-Level Presence & Automations)
By Lazy Tech Geek
Summary
Topics Covered
- Reduce Transmit Power to Stop Room Bouncing
- Dynamic Dashboard Shows Only Relevant Room Controls
- Auto-Enable Guest Mode Using Tile Tracker
Full Transcript
Hey, it's Dave here. Today I'm going to show you how to set up ES Presence with Home Assistant so you can track devices by using ESP32 nodes. We'll go through
the setup, adding devices into Home Assistant, and then look at some real world examples like conditional visibility on dashboards and a few practical automations.
[music] Before [music] we get started, there's a couple of prerequisites. Alongside Home Assistant,
prerequisites. Alongside Home Assistant, you'll need the Mosquito Broker add-on installed as well as MQTT integration set up. If you haven't done that
set up. If you haven't done that already, I've got a separate video that walks you through it step by step, and I've linked it in the description. Now,
this is quite a long video, so definitely make use of the chapters if you want to jump to a specific section.
If you're not familiar with ES Presence, it's essentially a collection of ESP32 boards configured as Bluetooth proxy nodes that actively listen to compatible
Bluetooth devices such as mobile phones, smartwatches, or accessories like tile key rings and then communicate that information back to Home Assistant via
MQTT.
Home Assistant can then use that data to update device locations or trigger automations.
Most of what I'm covering comes directly from the official ES presence documentation, which I recommend reading through if you want more detailed reference material. In one of my earlier
reference material. In one of my earlier Bluetooth proxy videos, Jerry mentioned using PoE based ESB30 boards for better reliability and to avoid Wi-Fi
interference. So, in this video, I'm
interference. So, in this video, I'm going to cover using both Wi-Fi and Ethernetbased ESP32s using the boards you can see on screen.
With that out of the way, let's get started by flashing an ESP32 board.
Starting off with the Wi-Fi based ESP32 board. To flash the firmware, if you
board. To flash the firmware, if you head over to the following website, then you're going to select connect. And
in this example, I know it's compport 4.
So I'm going to select that one and select connect.
Now I'm going to choose install ESP presence.
Check the box arrays device. Click next.
And just before I click install, I'm just going to hold down the boot button.
Once installation is complete, if you click next, now we're just going to enter in our Wi-Fi details, then click connect.
Now, if you find yourself stuck in a loop where it doesn't appear to be connecting to the Wi-Fi no matter how many times you put in the credentials and you are 100% certain you've put them
in correctly, it might have actually connected anyway. So, if you just press
connected anyway. So, if you just press skip and then just click on logs and consoles and then click back, it should in a second. Now, I've got the option
visit device. And if I select that,
visit device. And if I select that, you can see it's got an IP address. So
clearly it has actually connected to the wireless.
Now I'm not going to cover those settings just yet because I want to go through flashing a PoE Ethernet ESP32 board and then I'll cover the settings
of both backto back at the same time instead of repeating myself.
Now I'm going to cover flashing the POE ESP32 board. If you're only interested
ESP32 board. If you're only interested in the Wi-Fi baseboard, feel free to skip this section and jump straight to where I configure the device settings.
Before you plug this into your computer, make sure the programmer board is connected to the ESP32 because you can't flash this board via
the built-in USBC port. Now, pay close attention to the orientation, but don't worry if you've already soldered the header the wrong way around, which I
did, by the way. You can simply flip the programmer board so it can be connected either way as shown in these examples.
So again, make sure you're on the following web page if not already and then select connect and then select the relevant compport your device is
connected to and click connect.
Then select install ESP presence. Select
arrays device. Click next. And then just before I press install, I'm going to press the boot button.
Once installation is complete, if you click next.
Now, while we will be connecting this device via Ethernet and using PoE, you still have to connect it to the wireless. So, you can then visit the
wireless. So, you can then visit the device and then enable a setting under Ethernet. It sounds a bit messy, but
Ethernet. It sounds a bit messy, but it's just the way the firmware is set up.
So, I'm just going to enter my Wi-Fi details, then click connect.
Now, if you find yourself stuck in a loop where it doesn't appear to connect to the Wi-Fi while you are 100% certain you've entered the credentials correctly, it probably has connected.
And if you just click skip and then click on logs and console and then just go back, you should now see visit device. And you
can see it's got an IP address. So that
has actually connected to the wireless successfully.
Now that both devices are flashed, I'm going to open them up and walk through the configuration. or access one from
the configuration. or access one from the ESP presence portal and the other by opening its IP address in a separate tab. If your screen already looks like
tab. If your screen already looks like this, I'm going to close this window and click connect again just so we're starting from the same point.
So from the ESP presence portal under nodes install firmware, we're going to click connect and I'm going to select compport 6.
Click connect and then visit device. And this is the device I'll be using for Ethernet. And
I'm just going to open another tab for the Wi-Fi based ESP32 board, which is this one here.
Now, the settings are going to be more or less identical apart from the name of the device and the Ethernet type.
So, I'm going to start off with the one which is purely going to be Wi-Fi only.
For room, I'm going to call it bedroom_1.
Now, under seconds to wait for Wi-Fi before captive portal, what that means is after 60 seconds, if it doesn't connect to Wi-Fi, it's going to essentially turn into like a hotspot
where you should be able to see it as a Wi-Fi to connect your mobile phone or tablet to, and that will open up a web server where you can then type in your
Wi-Fi details and connect that device to your network. I'm just going to leave
your network. I'm just going to leave that as default, which is 60 seconds.
And then a setting underneath where it's got seconds to wait in captive portal before rebooting. That's set to 300
before rebooting. That's set to 300 seconds. So I'm just going to leave that
seconds. So I'm just going to leave that as it is. That will just restart your board and hopefully it might reconnect to your wireless automatically. I'm just
going to leave that as it is. Ethernet
type I'm going to select to none.
And then MQTT is just my MQTT server settings. In most case, it would just be
settings. In most case, it would just be your home assistant IP address. Port I'm
going to leave as default, which is 1883. Username. It can just be any of
1883. Username. It can just be any of the usernames you connect to Home Assistant with. You might want to have a
Assistant with. You might want to have a specific username, something like MQTT room. In this example, I've just made a
room. In this example, I've just made a demo account and I've just called it MQTT room demo along with a unique password.
Now, this part here where it's got Home Assistant Discovery Topy prefix, just leave that as it is. What it means is that if you've got autodiscocover
enabled under MQTT, the device will automatically be added. It's almost
certainly going to be that setting. I'm
just going to head over to Home Assistant and show you where that is.
So if you go to settings, go to devices and services and if you just search for MQTT,
then go to this configuration button here. And if you select MQTT options,
here. And if you select MQTT options, you'll see here you've got that discovery prefix, which is actually Home Assistant already. So unless for some
Assistant already. So unless for some reason you had changed it, then this setting here, just leave it
exactly as it is.
The rest of those settings I'm not going to change. Now I'm going to click save.
to change. Now I'm going to click save.
And then on the top left, you can see you've got restart device.
While that device is restarting, I'm now moving over to the ESP board that I want to configure using Ethernet.
I'm going to give it a slightly different name. And just to make it easy
different name. And just to make it easy for me to remember, I'm just going to add PoE as a prefix.
The rest of the settings I'm going to leave identical. I'm just going to put
leave identical. I'm just going to put in the MQTT details. Now the part that you are going to need to change is
Ethernet type. Now the particular board
Ethernet type. Now the particular board I've got is this one. So you'll have to look at your manufacturer settings in terms of which one you should be using.
And now I'm going to save the changes.
And one thing with this device is when I click restart, it did appear to still be connected to the wireless. So, what I ended up doing is just unplugging the
cable, plugging it back in, and then once it had properly restarted or reseted, then when I looked on my router, I could see it definitely was
connected via Ethernet. So, pressing
restart didn't seem to work or at least didn't seem to work for my case.
So, I'm additionally going to physically unplug and replplug the device. So, it's
completely powered off and powered back on.
Now that I've unplugged the USB cable from the ESP32 board that I'm using, Ethernet, and I've now plugged in an Ethernet cable to that board, which is
connected to a switch that supports PoE, it should now be connected to network.
And it's highly likely it's going to have a different IP address because it's using the MAC address of the Ethernet port instead of the Wi-Fi MAC. So if I
try to refresh this page, it's almost certainly not going to resolve with the same IP.
So the fact that's not working is actually a good sign.
Now I'm just going to quickly go into my home router and just find that IP address.
And that's looking promising. So you've
got ESP presence POE lounge 1. The IP
address doesn't finish in 220. It's
finishing 231. And there you can see type Ethernet, which is promising.
Now that we've connected those devices to the network and we've put in the MQTT settings, we're just going to go to Home Assistant and we should find those two
new devices will show under MQTT.
If we go to settings and then select devices and services and do a search for MQTT and you should find them with the prefix
ES presence which is these two here.
So if I click on the first one and you can see all of these entities exist because auto discovery was enabled. And if you want to you can
enabled. And if you want to you can click here to visit the device which also gives you the IP address as well.
And if I just go back one step, I can do exactly the same for the one with POE. And I could have got the IP
with POE. And I could have got the IP address that way. When I click on that, it finishes in 231, which is different to earlier when it was 220 at the end.
For this next part, I'm going to cover enabling Bluetooth transmission on common devices using a PowerPoint slide rather than walking through every method live on screen. Now, you can download
these slides if you want to go through them later or in your own time. And as a reminder, feel free to skip ahead using the chapters and just watch the sections
you need. I probably should admit this
you need. I probably should admit this next bit is a little bit on the boring side.
Before we get started, these slides are available as a downloadable PDF. If you
want to follow along or reference them later, there's a link in the description.
To enable BLE transmission on your mobile via the Home Assistant app, if you go to settings, then if you select companion app,
then select manage sensors, then select BLE transmitter, then turn on enable sensor.
Now, these are the BLE settings you can change. For most people, you can leave
change. For most people, you can leave them as default, but I'll quickly explain what each one does.
Advertise mode controls how often beacons broadcast. Low latency sends the
beacons broadcast. Low latency sends the updates more frequently, given faster room detection at the cost of a slightly higher battery usage.
Transmit on home network only. Only
broadcasts when connected to your home network. This helps save battery while
network. This helps save battery while preventing unnecessary BLE broadcasting when you're away. However, you'll need to tell Home Assistant which network is
your home network. I'll cover that shortly.
Major used to group beacons together.
You can leave this as default unless you're deliberately grouping multiple devices.
Measured power represents signal strength at 1 meter. ES presence uses this as an estimate distance, so it's best left unchanged.
Minor is a unique ID for this specific beacon, useful for distinguishing between multiple devices.
Enable transmitter must be left on otherwise nothing will broadcast.
Transmitter power controls the Bluetooth range. The higher the power increases
range. The higher the power increases the range but uses more battery.
And the UU ID is the unique identifier for the beacon. ES presence uses this to recognize and track the device.
Now these three settings, UU ID, major, and minor together to find the beacon's identity. These values are what ES
identity. These values are what ES Presence uses to recognize the device.
So make note of them. You'll need them later.
For transmitter power, I've left it as medium, which was the default setting.
You'll probably want to play between medium and low because if you do set it to high and you've got multiple ESP32 nodes around your house, you might find
yourself in a situation where you're in the kitchen, but it's still able to broadcast one that's in the lounge. So,
in some ways, you actually want to be using a weaker power, so it can only connect to the nearest node. advertise
mode was defaulting to low frequency.
So, I'm just going to leave that exactly as it is.
Now, as mentioned earlier on the transmit on home network only, I'm just going to show you exactly how to tell Home Assistant what your home network is.
So, from the companion app, if you go to home and then you should see home network, and in this example, I haven't actually set one yet. Then it should show you the wireless network you're
currently connected to. And this
example, when I click on it, I can now see it's available and I've got the X to remove. And you may have different
remove. And you may have different bandwidths. In my example, I've got 5
bandwidths. In my example, I've got 5 GHz and 2.4. So, you can either manually type in the name of the other wireless, or if you were to then connect to that one, it would show that as an option,
and then you could have repeated the previous steps. But I'm just manually
previous steps. But I'm just manually typing it. Clicking add. And now you can
typing it. Clicking add. And now you can see I've got two of my wireless showing.
And the one that finishes in 5G is the one that I'm connected to at the moment.
And as I go back a step, you can see there home network. And it's got two of my home network SSIDs. So now Home Assistant is able to recognize whether I'm home or not for that setting to
work.
Now, as an alternative for Android mobiles, there's an app called Beacon Scope which will essentially achieve the same outcome. Now, just to mention, if
same outcome. Now, just to mention, if you don't need to know this particular section, feel free to just skip ahead.
So, if you want to use Beacon Scope, if you download that from the Play Store, you're going to get some sort of a warning about the app will run in the
background. And just click okay.
background. And just click okay.
And if you go to transmit and I just use the top option which is ibeacon sample and then from here you can give it a name. It's more or less exactly the
name. It's more or less exactly the same. You can see you've got proximity
same. You can see you've got proximity UU ID which is exactly the same as the home assistant. Again you've got the
home assistant. Again you've got the major, you've got the minor transmit power and measured power advertising rate. It's more or less identical. And
rate. It's more or less identical. And
just to give you an example, this is what the ID is going to look like from your node where it's going to be the
proximity UYU ID hyphen major hyphen minor as shown in that example.
Now transmit power earlier I had set to medium.
So I'm just going to change it to medium in this example too.
And then as I go back if you just click on and then it's naturally going to turn on, which is going to be the same outcome as if you're using the companion
app.
Now, I'm going to cover adding iOS devices like your iPhone, iPad, or Apple Watch to ESP presence, and this is a slightly different step to the Android
ones.
You're going to need to connect to one of your nodes via its IP address. And if
you scroll down, you should see an option. Click here to edit other
option. Click here to edit other settings.
From this page, if you go to devices and select enroll, you're going to be presented with this window. From the drop-own menu, select
window. From the drop-own menu, select device type. I'm going to select phone
device type. I'm going to select phone because it's an iPhone. However, you can actually just leave it as it is. What
happens is when you select that drop-own menu under the bottom bit where it's got enter custom ID, it will have a prefix of phone and colon. So when I enter a
name and call it iPhone, you'll notice the custom ID is phone colon iPhone. So
all that drop-own menu seems to do is just add a prefix and there's nothing stopping you from overwriting it. So, in
this example, if I didn't actually select that drop-own menu and I just called it Dave's iPhone underneath, it's just going to take away some special characters and remove the spaces and it
will look like below.
In this example, I'm going to leave the drop-own menu as phone and I'm just going to have the very generic description iPhone. And then I'm going
description iPhone. And then I'm going to select enroll.
When you do this, it's going to go into a pairing state, and you've got about a couple minutes to go into the settings on your iPhone.
So, from your iPhone, go to settings, go to Bluetooth, and you should see ES Presence as one of the devices you can connect to. Then, select pair.
connect to. Then, select pair.
And don't be concerned that you see not connected afterwards. That's totally
connected afterwards. That's totally normal.
Then when you go back to your web browser, you should see now it's got new device ID is and then it's got phone colon iPhone.
And then under devices, I can now see that phone. And if I go to fingerprints,
that phone. And if I go to fingerprints, phone colon iPhone, that's the unique ID that you'll need to use later when we
add the device into Home Assistant. You
can also filter as well by anything that's got a name and then a colon, which is quite cool because here I can just filter by phone and I can go
straight to that phone because I'd previously added a device that's got phone colon as that unique name.
Now, if you're anything like me and you're a little bit indecisive and you've chosen a name really quickly and then later on you thought actually I don't want that name. I want to change
it or how do I unenroll that iPhone and then read it again with a different name. I'm now going to show you these
name. I'm now going to show you these steps. And just to make it very very
steps. And just to make it very very clear, you must do it in this exact order.
So from your iPhone, if you go into Bluetooth settings and then just click on that I button where it's got ES presence, then you're going to select forget this
device.
forget device.
And if you go to one of your nodes by the IP address and select devices, you need to make note of that phone's IRK
ID, which is shown in this example.
Then you'll want to download and install MQTT Explorer if you don't already have it, which I've linked here.
When you launch it, it's going to ask for the MQTT connection details. And
it's these following three fields that you'll need to change. The host, which is basically going to be your Home Assistant IP address. And then you'll need a username or password that you use
to connect to Home Assistant. Once
you've entered those details, you can then select connect.
And then if you expand ES presence, then expand settings. and you want to look
expand settings. and you want to look for that IRK ID that I showed you earlier. Select that and then if you
earlier. Select that and then if you click on the bin icon to delete it, then select yes.
Once that's deleted, that entry should now be gone.
But if you go back to the web interface of one of your nodes and open the devices page, you'll notice the alias is now blank, but the ID is still there.
This is because there's a cached record on that node. If you restart that node, the cached entry will be cleared and a device will disappear, putting you back
in a clean state where you can reenroll it. Just be aware that if you have
it. Just be aware that if you have multiple nodes, that cached entry may still exist on the others until they're restarted as well.
That said, if you reenroll on that device with the correct name, ES Presence will automatically overwrite that stale state on the other nodes. So,
in most cases, this isn't a major issue.
Now that Bluetooth transmission is set up, I'm going to show you how to find the device IDs for your devices. You'll
need these later when adding those devices into your configuration.
There's a couple of ways you can do this and depending on how your ESP32 is connected, I'll walk you through both options
to get the IDs for your devices. I'm
going to show you two ways to achieve this. One is if you go back to the ESP
this. One is if you go back to the ESP presence firmware web page and under nodes install firmware, you've got connect. And that's assuming that your
connect. And that's assuming that your ESP32 board is connected via USB and connected to your computer. For that
option, you just select connect. I'm
going to select the device and choose connect.
Now, if we click on logs and consoles, this is going to show you a series of fence of devices. And as I bring my phone closer to the ESP32 board.
Okay, that's now popped up. You can see that's got close and it's got here this iBeacon entry. And you'll need to copy
iBeacon entry. And you'll need to copy that exactly as it is.
Now I'm just going to come out of that and show you another way which is quite similar. So, if I just do back,
similar. So, if I just do back, you can either click visit device, which is going to take you straight to the IP address of that ESP32 node. But if you
didn't know the IP, I'm going to show you another way around it. So, I'll just close that window.
Now, if I just go into Home Assistant, and if you go to settings, devices and services, then do a search for MQTT.
And I'm just going to look for that ESP32 board that's nearby, which is this one here.
And you'll see you've got this option, visit. And that's going to take you to
visit. And that's going to take you to the web page. And now if you scroll down and look for click here to edit other settings
and then if you select fingerprints. Now
this is similar to the logs but it's not going to say close when a device is nearby. But what you can do is you can
nearby. But what you can do is you can change the order in terms of distance which will help you. And there's also a filter here where it's got a series of
prefixes. So, iBeacon's really useful
prefixes. So, iBeacon's really useful because in this example, I happen to already know that this one is my mobile phone and the other one which is unique
is my watch and that's the ID that you're going to need to copy and going to the iPhone. It's under phone because when I enrolled it, I selected that
drop-own menu phone which just adds that phone colon and then it just has that name iPhone. So, what you'll want to do
name iPhone. So, what you'll want to do is copy that whole ID because you'll need it later.
And if I go here, there's also another option of tile, which again is really useful. If you are using tiles, before
useful. If you are using tiles, before you do this, you will need to install the tile app and just initially get it activated following the manufacturers's
instructions and then you should be able to see it broadcasting as a device to find. But having the prefix tile makes
find. But having the prefix tile makes it very very quick and simple to just copy that ID.
Now that we have the device ids, we need to add a few entries to the configuration.yamel.
configuration.yamel.
This allows the beacons to appear as entities in Home Assistant and lets ESRs update their state based on which room or node they're closest to. back on to
the official ESP presence documentation under configuration home assistant. If I
just scroll down a little bit further, you'll see some example YAML configuration showing how to add your Beacon devices. And now if I scroll back
Beacon devices. And now if I scroll back up, the guide includes a link to the MQTT room integration page,
which is this one here. And if I just scroll down a bit further, this section details the configuration variables which you can use. Away time out is a
setting where after no updates after X amount of time, it will then change your entity from home to not home. Then
you've got device ID, which we got earlier when tracking the sensor. The
name is like a friendly name. It's
optional and you can just give it something that you can associate your device with. state or topic needs to be
device with. state or topic needs to be exactly like this.
And time out, which defaults to 5 seconds, is when the device is able to then connect to another node or ESP32 board. So the state of the room can
board. So the state of the room can actually change.
Now, while unique ID is technically optional, I would strongly recommend adding it. If you don't, Home Assistant
adding it. If you don't, Home Assistant will throw its toys out the pram. And
when you click on the entity settings from here, you're going to run into a warning message saying the entity ID can't be managed from the UI because it
doesn't have a unique ID. If I click on this other example sensor here, this is what you should be able to do. So just
include unique ID to get around that problem. Now if we go back into Home
problem. Now if we go back into Home Assistant, I'm now going to add those entries to the configuration.yamel YAML
file. If you go into file editor and from your configuration.yaml, you
can either paste the entries directly in here or you can split them. I'm just
going to show you both. This is an example is if you want it directly in your configuration.yaml.
your configuration.yaml.
I've specified sensor and then I've got these values here for my devices or beacons.
It's got platform MQTT room. The device
ID is what we got when scanning.
Name is essentially friendly name and I've just called it Dave's watch. Now
for state topic, it's the same as device ID, but it must have espress.
If you just copied the device ID and pasted it twice here, which by the way I did, you will see it in Home Assistant.
But ES presence isn't going to interact and update the state of where it is.
Time out I've left as 10 seconds. Away
timeout is 120 seconds. And then as mentioned earlier, add the unique ID value. I've removed the spaces with
value. I've removed the spaces with underscores. And I've got rid of any
underscores. And I've got rid of any special characters. The rest of the
special characters. The rest of the entries are just exactly the same. Now,
for those of you who wanted to split your configuration YAML, which is what I've done, you can see here I've already got this sensor value and it's got include directory merge list and it's
going to a folder called config and then another folder called sensors, which is actually why I've got that red icon warning me because it's probably telling me about a duplicate key mapping, which
yes, it is. So, I'm just going to show you that now. So, if I close this window down and don't save changes, I'm now going to browse to that config
folder and then go to the sensors folder.
Now, I'm just going to create a new file. You can call this what you want,
file. You can call this what you want, but it just seems appropriate to call it beacons.yaml.
beacons.yaml.
Then, I'm going to click okay, and I'm just going to make sure that file is open. So I'm just going to click on it again. That's better. Now I've got the actual entry and I'm just going to
paste my YAML into it. Now this is more or less exactly the same. The only
difference is at the top it doesn't have sensor. It's just got these values for
sensor. It's just got these values for the beacons and they're just two extra indentations to the left. I'm now going to save that
and then go to developer tools. And from
the YAML tab, we're just going to check the configuration's fine and then give Home Assistant a restart.
Once Home Assistant has restarted, if you go back into developer tools and select states, and I'm just going to search for one of those devices by its
name. And that's looking promising. I
name. And that's looking promising. I
can now see Dave's watch entry does exist and it's also got the state as bedroom_1 which is one of those nodes. You can
also find them if you go into settings and then go to devices and services.
If you do a search for MQTT, you're now going to have this extra option of MQTT room presence which confirms you've got your YAML entries
correct.
You'll see here it's got five entries.
So, I'm just going to click on that.
And these are the five I added earlier.
So, if I click on Dave's watch and if I just click on that settings icon, I haven't ran into that warning message because I included unique ID.
Now I'm going to do a quick live demo and walk between rooms just to confirm ES Presence is updating the devices state as expected.
So I'm currently in the bedroom and I'm now going to walk into the lounge and see how long it takes for the state to change.
I'm now in the lounge and you can see there you are POE lounge one. So that has worked.
one. So that has worked.
Now while I was demoing this earlier I did run into a few issues where the device kept bouncing between rooms. To fix that I ended up changing a few
settings on both my devices and the ES presence nodes. So let's cover that now.
presence nodes. So let's cover that now.
from your device like your mobile phone, you might want to go to the companion app and then go into manage sensors BLE transmitter and there's a setting called
transmit power. Earlier I left it on
transmit power. Earlier I left it on default settings which was medium and you might want to consider reducing it to low or ultra low so it's unable to
transfer as far which may contribute to reducing it connecting to another nearby node.
Another option is from your configuration.yaml.
configuration.yaml.
There's a setting called timeout and you might want to increase it from 10 to 30.
That might contribute to remediating some of the issues when there's perhaps a fluctuation with the signal strength going up and down. It will prevent it from disconnecting too quickly and
reconnecting to the next nearest node.
The third option is from the ESP32 boards. If you connect to the web portal
boards. If you connect to the web portal and then scroll down and select click here to edit other settings under devices, you'll see a section called
counting. Start counting devices less
counting. Start counting devices less than in meters. Means that anything that's under 1 meter, it won't even start counting. And the next one below,
start counting. And the next one below, which is stop counting, that then means that once it goes above a certain value, it will then stop counting and eventually that device will leave. And
the fourth option is depending on the property that you're living in, if you're in a small confined space, you might want to try and space out the nodes in case they're just too close in
terms of proximity. So I'd try one of those four options or maybe all of them and hopefully you'll get that kind of sweet spot and it might iron out your issues.
At this point, ES Presence is fully set up and working. Your devices will now update their state as you move between different rooms. So technically, you can stop watching here if you just wanted
the core setup. If you do want to keep going though, I'm now going to move on to a few example use cases and automations to show how you might
actually use this data in practice.
One popular way to use ES presence is with dynamic dashboard views using conditional visibility. For example, if
conditional visibility. For example, if I'm in the bedroom with my phone, I only need to see and control devices in that room. Then, when I move into the lounge
room. Then, when I move into the lounge or kitchen, the dashboard automatically shows the relevant lights or curtains for that space. Let me show you an
example of that working.
In this example, you can see I've got these buttons, lights, or switches which relate to the lounge, dining room, or kitchen. And for me, that's actually one
kitchen. And for me, that's actually one room somewhat merged together. But what
I would like is that when I walk into the bedroom, I only want it to show items related to the bedroom.
So, if I go into edit dashboard, you'll see here this is actually one section with a series of cards. So, what
I'm going to do is clone that section.
So, if I click on edit, then go to menu and select edit in YAML.
I'm just going to copy all of that code.
And then if I scroll down, I'm going to create a new section, click edit again, then go to menu, edit in YAML, and I'm just going to paste all
of that. Now, when I click save, you can
of that. Now, when I click save, you can see I've got this value here, and I've got this value here. So, I've somewhat cloned that card. I'm also just going to
move that card up.
So, now you've got two of them here.
One's going to be the lounge and the other's going to primarily be the bedroom. What I will need to do is
bedroom. What I will need to do is change these cards to relate to objects in the bedroom. I'm just going to fast forward to a stage where that's already done as that's somewhat intuitive and
this is more of a ES presence video than a home assistant dashboards one. So now
you can see I've added another section for the bedroom which is here. Now, just
for demo purposes, I've actually added a location button here so that when I do demo walking into one room and the other, you can quickly see that Home
Assistant has identified that. The next
step is to configure visibility. And
while you could do it for each separate card, it just made more sense for me to create a whole new section. And I'm
actually going to apply the visibility based on the section. It's just a bit more efficient way of doing it. I'm
going to go into edit, go to visibility.
Now, before I add the condition, you're going to need to know the entity name of the device, mobile phone, or watch. And
you're also going to need to have a list of the possible states it can fall into depending on what room you're in, as you won't be able to search for that in this
particular area. I'm just going to open
particular area. I'm just going to open up another Home Assistant tab and show you how to find that. If you go to settings, then go to devices and services,
do a search for MQTT and select MQTT room presence.
Then select entities here and it's going to give you a list of various entities.
And the one I'm going to be using is this S23 mobile.
Then I'm going to select settings. And
you'll see here is the entity ID which I'll need to copy. And if I go back one step under activity, you can see it's got the various states that it's fallen into. So you'll want to copy these as
into. So you'll want to copy these as well to go into your conditional visibility rules. I already know them.
visibility rules. I already know them.
So I can close that down and go back to the last tab. Now I'm going to add my condition. And in this example, I'm
condition. And in this example, I'm going to be using the or value because I've got multiple nodes and I want it to be like if I'm in kitchen one or kitchen
two, lounge one or lounge two. And if
you are using the or value, [clears throat] make sure you do it from within this particular box. If you
select or and then you click on this add condition, it then becomes an field. And
the problem you're going to run into is a device cannot equal more than one state value. So the visibility condition
state value. So the visibility condition will never be true and you're never going to be able to see that section. So
I'm going to select add condition entity state. I know it's my mobile
entity state. I know it's my mobile phone so I can paste that in. Select
that and equals to is going to be bedroom one. It's a custom state. Now
bedroom one. It's a custom state. Now
I'm going to repeat it again. Add
condition entity state. Paste the mobile phone in.
And this time it's equal to bedroom 2.
And just reminding you all of these or values are within the same box if you did want it to equal this or this. And
just before I click save, if I go into edit and YAML and scroll down, you can see this is the part of the conditional visibility code where it's got this
condition and it's either state bedroom one or state bedroom 2.
Now I'm going to save that.
And I'm essentially going to be repeating exactly the same steps for this section so I can have conditions based on which room I'm in. There's no
need for me to repeat those steps again as I've already detailed them earlier.
One quick extra thing to bring up when using conditional visibility is that if you've created sections for individual rooms, none of them will be visible when you're not home. In that case, it's
worth adding an additional away section for things like heating, alarm, or cameras for when your mobile's device state is not home.
So, now I'm in the bedroom and I'm going to walk into a lounge and see if the dashboard view is going to update.
I'm now in the lounge and there you can see it's got room POE lounge one and some of the buttons, curtains and lights have updated. So that's worked.
have updated. So that's worked.
Another example automation is getting a notification if you leave home without your wallet. I'm using a tile tracker
your wallet. I'm using a tile tracker here and this is the kind of notification you'll see on your phone.
So, if we go into settings, then automations and scenes and select create automation,
then select create new automation.
And if you go to the top right and click on those three dots and select edit in YAML and I'm just going to paste in this example code.
So, I've called this automation warning if wallet left at home. The trigger is my mobile phone, which is sensor. S23
mobile, and it's when it changes to state not home for longer than 1 minute.
Now, you may want to bump that time up or down, but I've left it as a minute because it just rules out any false positives if your phone bounces between not home and home. So, I've just left
the sweet spot as 1 minute. Then you've
got the condition which is this part here. And what it's doing is it's
here. And what it's doing is it's checking the state of my tile wallet.
And if it's not not home, unknown or unavailable, then it's going to proceed to the action because that should be saying something
like kitchen one, kitchen 2, bedroom 1, bedroom two, or one of the rooms. The action that it's going to be running is it will send a message with the title
wallet left at home. And it will have this message here. You may have left your wallet at home. It's still detected in and it's running a state from sensor
tile wallet. So that's going to reveal
tile wallet. So that's going to reveal the location that it's in. So if it's in bedroom one, it will say you may have left your wallet at home. It's still
detected in bedroom 1. and it's going to send that action to my mobile here, which is notify.mmo
app. And I've specified the mobile name.
Now, if you wanted to, you could actually change this to just notify.
Notify, and that will just send it to all of your devices, but since it's referring to my wallet, I would rather receive it on my phone. I'm just going
to undo and put that back to it was. And
just before I save changes, I'm going to click on these three dots and go edit in visual editor just to show you the visual setup. So you've got here when
visual setup. So you've got here when and it's S23 mobile not home and it's for 1 minute.
Then you've got and which is another condition and it's running this template which is the state sensor tile wallet and again when it's not one of those values and
then do is the notification send a notification file mobile which is mine and then that's the message that it's sending. So you can just copy this
it's sending. So you can just copy this code and then go into visual editor and you might want to change it from there or you can do it from the code and just
changing those devices and entities to your own.
I'm now going to save those changes and then just click rename to proceed.
And now that automation is set up. The
code for these automations will be saved on GitHub if you want to download them.
So, just to give you one more real world example of how you might use ES presence. Originally, I was going to
presence. Originally, I was going to build an automation to alert me if I left home without my keys. But because
my building uses a key fob to get back in, that would really just give me an advanced warning that I've already locked myself out, which isn't very helpful.
So, instead, I'm going to flip it this way around. At home, I already have a
way around. At home, I already have a Node Red process flow that turns the heating off when I leave. The problem is if I've got a guest over, they sometimes
complain that it's cold once I'm gone.
To handle that, I've previously created an input boole called guest mode. When
it's enabled, heating stays on even if I leave. What we do now is automate that.
leave. What we do now is automate that.
When a guest's tie or key ring is detected at home, guest mode turns on automatically. And when it's been away
automatically. And when it's been away for more than 12 hours, it turns back off. Let me show you how to set that up.
off. Let me show you how to set that up.
So, if you go into settings, automations and scenes, and then select create automation,
then select create new automation.
And if you click on the three dots and select edit in YAML and I'm going to paste in the following code. Now we're
going to achieve this in two separate automations.
This first automation is to turn on guest mode and it's referencing sensor tile keyring. And whenever the state
tile keyring. And whenever the state changes, it's then going to check this template which is this part here. and
it's going to be triggering when the state is not not home, unknown or unavailable.
I can't just make it so when the state is home because it's not going to show home, it's going to show the state of one of the rooms like bedroom one, lounge one. So that's a similar template
lounge one. So that's a similar template to the one I demonstrated earlier. And
once that's recognized as essentially being home, it's then going to change the input boolean to be on, which is
this one here, input boolean guest mode.
If I click on these three dots and just do edit in visual editor, so you can see how it would look visually.
There's the when condition tile key ring whenever the state changes.
And you got the and value here which is that template value again whenever it's not not home unknown or unavailable.
And the then do is just turning on input boolean guest mode.
I'm not going to save this one because I'm going to quickly go to the other automation. But what you would normally
automation. But what you would normally do straight away is obviously click save.
And now we're going to essentially do the reverse. So if you click on these
the reverse. So if you click on these three dots and select edit in YAML and I'm just going to overwrite this code.
This time it's going to be disabling guest mode. So the trigger is sensor
guest mode. So the trigger is sensor tile keyring. And when the state changes
tile keyring. And when the state changes to not home for 12 hours, it's then going to turn off the input boole which is guest mode.
I'm just going to quickly click on those three dots and just show you in visual editor again.
So the when value is when the state of tile keyring goes to not home.
Then it's going to turn off guest mode.
And then you would finally click save and then just select rename for changes to apply.
So, that's ES Presence set up and working with Home Assistant from flashing your ESP32 nodes all the way through to tracking your devices by room
and using that data in dashboards or automations. Hopefully, this has given
automations. Hopefully, this has given you a good foundation to start experimenting with your own ideas, whether that's presence-based dashboards notifications or
automations that react when things are actually in your home. If you found this video helpful, feel free to give it a like and please let me know in the comments how you're using ES Presence so
myself or others can get inspired by your ideas. Thanks for watching and I'll
your ideas. Thanks for watching and I'll see you in the next one. Bye for now.
Loading video analysis...