353 lines
22 KiB
Plaintext
353 lines
22 KiB
Plaintext
Episode: 4512
|
|
Title: HPR4512: HomeAssistant - Nmap ("Network Mapper")
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr4512/hpr4512.mp3
|
|
Transcribed: 2025-11-22 15:16:13
|
|
|
|
---
|
|
|
|
This is Hacker Public Radio Episode 4,512 for Tuesday the 18th of November 2025.
|
|
Today's show is entitled Home Assistant End Map Network Mapper.
|
|
It is hosted by Rato and is about 37 minutes long.
|
|
It carries a clean flag.
|
|
The summary is Presence Detection in Home Assistant End More.
|
|
Hi, this is your host Rato and this is a show about Home Assistant.
|
|
Recorded in June 2025.
|
|
I will focus on the application of End Map.
|
|
This abbreviation stands for Network Mapper and Network Exploration Tool in Home Assistant.
|
|
A bit more context from the main page of End Map.
|
|
While End Map is commonly used for security audits,
|
|
many systems and network administrators found it useful for routine tasks such as
|
|
network inventory, managing service upgrade schedules,
|
|
and monitoring host or service uptime.
|
|
These are the headings I will talk about today.
|
|
Short introduction and why End Map.
|
|
My personal automation.
|
|
Radiation of Bluetooth, CQP or Wi-Fi.
|
|
Enhance my automation.
|
|
The co-pilot.
|
|
The outro.
|
|
So let's get started.
|
|
My short introduction and why End Map.
|
|
Well, first of all, I would like to bring to you the terminology used within Home Assistant
|
|
to you.
|
|
When I started 20-23 or so with Home Assistant, I had to watch some videos on the terminology
|
|
used and how to weigh on the terminology and what is what for, basically, because for
|
|
me it didn't sound sometimes after what I was looking for.
|
|
So this time I want to focus on automation and Blueprint.
|
|
Notemation is, as the word says, without your interaction, basically, the system should
|
|
do something that you expect.
|
|
For example, if you walk into a room, the light goes on.
|
|
Or if you turn on the TV, the different light goes on or the other light goes off.
|
|
Now, there are situations where you may need the same automation for different rooms.
|
|
And instead of copying it over from one room to the other, there is a thing called Blueprint
|
|
in Home Assistant.
|
|
It's the Blueprint you can also share with other users from Home Assistant and other
|
|
users from Home Assistant can share it with you.
|
|
This is really handy.
|
|
Often, you find them in a blog post, in a forum post, and it will lead you mostly to
|
|
GitHub Guests page, where you can sometimes, if it is well done, you even have a link
|
|
in the forum, and it will do it mostly automatically, and then you get a nice GUI, basically, to
|
|
put in all the parameters you need, like which lamp or which light and which sensor and
|
|
to combine them and how you would like to have the color of the light, for example.
|
|
And this is the thing with automation in Blueprint.
|
|
So first, you basically experiment with automations in YAML and such.
|
|
You can now a switch between YAML and go back to the visual editor, and we'll go back
|
|
to the YAML.
|
|
And finally, it is nice to get the Blueprint in case you need it again.
|
|
So that's my short introduction for automation in Blueprint.
|
|
The next one is why using NMAP, there is the thing about Presence Detection within
|
|
Home Assistant.
|
|
This can be, well, different Presence Detection, of course, well, one of the Presence Detection
|
|
could be somebody at home or not.
|
|
I name now the Presence Detection is my PC running or not.
|
|
One of the offers to use within Home Assistant is NMAP.
|
|
You can use the Ping command, and if it is a mobile phone or a mobile device, you can
|
|
use the Home Assistant Companion app, I think that's the name.
|
|
So what's mine is about Tower PC, and I wanted to use NMAP because the idea of a Ping
|
|
that is pinging my PC to find out if it is still here or such, I don't know, didn't
|
|
sound so nice, and maybe I read something else because NMAP can do really a lot.
|
|
Anyway, so I went for NMAP.
|
|
NMAP is very interesting, the usage within Home Assistant.
|
|
At some point I read that there are some Home Assistant integration that you can work
|
|
together with your router, and so the Home Assistant can really connect to your router.
|
|
You then have to edit somehow in the menu in there, if you have such a router, and NMAP
|
|
can do even more, however my router of course doesn't support that function, and so I cannot
|
|
use that.
|
|
If you want to use or play a little bit around with NMAP, this is quite easy.
|
|
If you go to Settings, go into your Home Assistant, you go to Settings, Integration, and usually
|
|
at the bottom somewhere there is a plus sign, and there you can look for the NMAP tracker.
|
|
The beginning of my personal automation, so in 2023 I built the server, the base of
|
|
the server was Open MediaVolt, and on top of that is the Home Assistant.
|
|
So in 2023 I was building an overview in Home Assistant that's, I guess, what everybody
|
|
does a little bit to get on the screen what you really want.
|
|
Part of it was a server state, like free storage, memory, temperature, a weather forecast, and
|
|
others.
|
|
Then you also get, come along with Hex the Home Assistant, store anything.
|
|
Once this was running I started learning about automation.
|
|
I tried to learn from others with little success, way to complex for me, and way more than
|
|
I needed.
|
|
There were blueprints to download, they could do nearly everything, but then not exactly
|
|
what I was looking for.
|
|
Many of us are looking for small solutions that fit their own purpose, because we also
|
|
think that a lot of overhead can make things, can later on get a problem.
|
|
One thing and the other thing is you want to optimize it as much as possible, well, not
|
|
all of, not all people have that feeling, but I have it.
|
|
So I built my own automation from scratch.
|
|
The idea was as much as needed, but as little as possible, to understand my code in a
|
|
years time and comments all around it.
|
|
Even if it was clear to me at that moment in a years time, it won't be.
|
|
So I tried to carefully put some comments what each section was doing and so, and yeah,
|
|
my chest is on GitHub, I will link it there.
|
|
I think it is a good place to begin.
|
|
And from there you can enlarge it to your needs or whatever.
|
|
I called it motion-illuminance light source sun brightness.
|
|
To do that, I needed some devices around it, and there were three devices, well, actually
|
|
two was enough.
|
|
So the one was the Xiaomi Aquara motion sensor, the RTCQ, I put the link in the zone out,
|
|
and the Draught Free Bulb E27 from IKEA, this is just a white one.
|
|
I also added, because I heard from some guy on the internet, not the one from HPR, the
|
|
Xiaomi Miya Thermohugrometer with Bluetooth BLE, it's called LYWSD, also the link in the
|
|
show notes.
|
|
So with them connected to my home assistant, I had a motion sensor, and within the motion
|
|
sensor is also an illuminance sensor, so I can find out how many looks are in the surrounding.
|
|
The light source is clear, is the bulb, and the sun is also clear, well, the sun parameter
|
|
was actually whether it is daytime or it is nighttime, so sunset, sunrise.
|
|
And the brightness I just explained in a moment.
|
|
So when you walk in my room, in my office, the light should go on if the illuminance is
|
|
below a value of 37, in my case.
|
|
And if it is during the day, so if the sun is up, it should be a brighter light than after
|
|
sunset, it should be a little bit less bright.
|
|
So that's what the brightness is for.
|
|
And I got all these things together kind of easily, but then there is one thing.
|
|
When you sit on your chair for a while, and you're not moving a lot in your chair while
|
|
sitting on the computer, and even if you have this motion sensor, two and a half meter,
|
|
I don't know how many foods that are, two and a feet, two and a half meter behind you,
|
|
would that be seven feet, even if you have seven feet behind you approximately, it wouldn't
|
|
recognize you after a while.
|
|
Sometimes it does, sometimes it doesn't.
|
|
And so I set the timer to a couple minutes, and then I had to add some counter measurements
|
|
that the light would not suddenly go off.
|
|
So I had like, if it doesn't have any motion for six minutes, then it would go to like
|
|
30% of light for another 40 seconds.
|
|
And within this time frame of the 40 seconds, I had enough time to move my hands around
|
|
until the light got bright again, so the timer was reset.
|
|
This is not that bad, because you move instead of just sitting still all the time, right?
|
|
So it is good for your body, basically, nonetheless, after a while, you get fed up with it.
|
|
But that's in a later section of that podcast.
|
|
Anyway, so my first chist had a lot of counter measurements because of this not moving enough
|
|
to trigger motion sensor.
|
|
The motion sensor also is interesting if not the motion sensor, sorry, the illuminance
|
|
is interesting because if there is a thunderstorm coming, a really dark one, and you sit in your
|
|
office during the day and the light goes below a certain threshold, then your bulb will
|
|
turn on and bright up your office.
|
|
And once the thunderstorm is over and it gets bright outside again, the light switches
|
|
itself off, and it's just nice to have, right, when somebody is serving you.
|
|
So much about my automation, so motion, illuminance, light source, sun, brightness.
|
|
And I had that created around, I don't know, autumn of 2023, somewhere there.
|
|
And or even it's no, no, wait, no, this was later, this was in spring 24.
|
|
And so I had that for almost a year and this spring now I got a little bit tired of it.
|
|
And so I started the enhancement that finally leads to this podcast, but that's in the next
|
|
section.
|
|
Radiation of Bluetooth, CQP or Wi-Fi.
|
|
As I'm talking here about devices that make use of some of the services, I would also
|
|
like to make you aware about some things about it.
|
|
Well, first of all, if you use these tools or these connection, it is good as long
|
|
as you have no interference.
|
|
So before you start to really integrate Bluetooth, CQP or Wi-Fi, a lot, make sure that you
|
|
learn about the Wi-Fi channels that you learn about, collision and interference that you
|
|
can have between CQP and Wi-Fi and how you choose the right channel, like if you are on
|
|
channel one and channel two, they are so close to each other that they will have interference.
|
|
Usually these numbers about the channel are, you have to learn about it and then place
|
|
and choose your channel wisely based on your surrounding and others.
|
|
Maybe if you are in a single family home in a house, maybe easier than when you live
|
|
in a block in a city.
|
|
So Bluetooth uses the lowest power which can be easily understood by its very small
|
|
range and it is not a contagious transmission as well, continuous transmission as well.
|
|
It is very energy, its energy impact is very minimal unless you have many Bluetooth devices
|
|
around your body.
|
|
So it is about the radiation and how it is going on, how it is the effect on your body.
|
|
The Bluetooth is maybe quite little, then there is CQP, CQP is a mesh network so one bulb
|
|
can talk to the next one and the next one and the next one.
|
|
But on the other hand CQP doesn't transfer a lot of information but it is good to be
|
|
aware that it builds up a mesh network.
|
|
Next is Wi-Fi, this is quite stronger than Bluetooth and CQP.
|
|
A Wi-Fi router sits in your house and is constantly emitting beacon signals and uses the maximum
|
|
bandwidth of the ISM, 2.4 and 5 GHz.
|
|
Energy impact on your body is maximum since there can be a lot of Wi-Fi access points
|
|
around and you may constantly using Wi-Fi to connect devices at home.
|
|
Now the next in the level this is 4G, so mobile phones versus Wi-Fi.
|
|
In terms of potential harm there is no clear evidence that one technology is significantly
|
|
more harmful than the other, especially learn about the baseband.
|
|
What I mean, how does your mobile phone know about the strength of the connection to
|
|
do your mobile tower or Wi-Fi hotspot?
|
|
Because the station does constantly send a baseband signal, why?
|
|
Because it gets power from the wall in opposite to your mobile phone or CQ.
|
|
So I wasn't aware of that until 2008 when on the next house an antenna was mounted and
|
|
I started when I got interested in how this thing with the radiation works and then
|
|
first they come and tell you yeah no problem with the mobile phone because it will just
|
|
emit data and such if a mobile phone is connected.
|
|
They didn't mention the baseband which is constantly sending a signal and your Wi-Fi hotspot
|
|
may as well.
|
|
So some people believe their government and health industry with shareholders and put all
|
|
this stuff in their body.
|
|
I don't, I'm a scrutinizer, what suits me and what not.
|
|
Why should I stop when it is my body?
|
|
So my approach is I reduced the emitting power to 60% of my Wi-Fi router.
|
|
I use Wi-Fi when I need it.
|
|
I turn it off afterwards.
|
|
In any case I turn it off while I am sleeping.
|
|
Yes, it would make my life easier to let it run all the time.
|
|
But what are the side effects in the long run?
|
|
I leave you a couple of links here if you want to look a bit deeper and now back to the
|
|
main topic.
|
|
So let's talk about how I wanted to enhance my automation.
|
|
There are the things in place that I needed and map was in place.
|
|
I was playing a little bit around with this device tracker.
|
|
This is either not home or not null.
|
|
I had a sensor with its illuminance.
|
|
I had a sunrise sunset that I could take over as well as the illuminance before.
|
|
So I had my blueprint, my YAML from my previous settings and thought it was the easiest way
|
|
to adjust this YAML to my new configuration.
|
|
I have the modem with the DHCP server on it.
|
|
I have a nook Intel nook computer where everything is running and I have a switch in between
|
|
the modem and the tower PC.
|
|
Always connected via Ethernet cable, so at least no struggling with Wi-Fi.
|
|
Well I had to find out it was not so easy for me to simply go ahead and adjust the code.
|
|
I had, I stumbled and stumbled and so I decided to delete as much out of it that I just
|
|
have the base functionality.
|
|
And then from then, write it again, build it up again and see step by step how that works.
|
|
And to support you in this process, if you go to home assistant on your web interface,
|
|
you have on the left hand, you have the developer tools and if you go inside there, you have
|
|
on top a couple of topics and one is called states and there you can change this design.
|
|
So I had to find out since the last time I opened it, please it feels like.
|
|
Then you can go there and set a current entity state of a sensor or whatever.
|
|
So this can be helpful.
|
|
And I was doing that and then I opened the second tab with home assistant as well and there
|
|
I opened the history of the sensor, the light and the device tracker.
|
|
And so I could on one on one tab play with the state and on the other tabs, see what
|
|
the history of the thing was doing of the sensor and so on and how the light was reacting
|
|
to it.
|
|
Well, okay, I would see the light.
|
|
But anyway, you have then all this thing very nicely lined up.
|
|
And then it was an evening, I was somewhere, can't remember the month, maybe July or so.
|
|
And there was a fun storm coming in and then it got very dark or so, it was around six
|
|
o'clock or whatever.
|
|
And my value of the illuminant sensor went below 37, that meant I wouldn't have to take
|
|
care of it because it would tell to my light to switch on because it is below 37.
|
|
Now while I was testing, this fun storm went over.
|
|
And as I said, it was around July, so the sun was quite high and it got bright again.
|
|
And if it is more than 37 illuminants, my trigger wouldn't trigger.
|
|
I found it out after a while, but of course, it took a bit, just to make you aware if you
|
|
are working in the developer tools, playing with the states of the entities and switch
|
|
them manually and they come back sometimes automatically after a certain amount of time
|
|
or such.
|
|
So make sure you refresh your web interface from time to time so you're not missing
|
|
that.
|
|
Any state in the device tracker is equal to null as I found out.
|
|
And while I was working with the whole thing, you have the graphical things with what you
|
|
can play in the YAML or you can play in the graphical user interface on the website.
|
|
And I did a little bit of both to see how it changes when I add this or that.
|
|
And I was at the point where I wanted to have an end function.
|
|
But the trigger is always an OR.
|
|
It does trigger this or that.
|
|
So I needed an end and the end is called a condition in the YAML.
|
|
On the web interface, it is called end if.
|
|
So when my desktop changes its states from null to home, so it is running.
|
|
And if the motion sensor and the illuminance is triggered, then turn on the light based
|
|
on the sun.
|
|
And you are just as I'm telling you now that it is on the one interface, it is a condition
|
|
at least on my screen job.
|
|
And on the other, it is an end if.
|
|
So it's an if statement or it's a condition statement, YAML versus graphical interface.
|
|
So yeah.
|
|
Now you know, I had to learn it.
|
|
Maybe you all know then what else did I find out?
|
|
Yeah, this was basically it.
|
|
So the developer tools the states, the second tab for the history in the web browser,
|
|
in Firefox preferably.
|
|
And that the condition in the YAML is an end.
|
|
So you can have the trigger.
|
|
So the trigger could be a motion sensor.
|
|
And then you have the condition plus it is not this the illuminance is below certain value.
|
|
Now while I was troubleshooting the whole thing, there were, well, it sounds now pretty easy
|
|
on the microphone, but I can tell you it took me a couple of days to get that sorted.
|
|
Well, and well, there was a year in between from one development to the next one.
|
|
And yeah, most of it was last and some new stuff came in.
|
|
So I started to write in the home assistant forum.
|
|
I put the link in the show notes.
|
|
So if you like, you can go and see, see there.
|
|
And I put in a description what I was trying to do and that I had no success.
|
|
And I was waiting a couple days, unfortunately, nobody came in and told me what I would have to do.
|
|
So I started to write down what my problem is.
|
|
So I started to reply to myself.
|
|
So I kind of documented in this forum post my next changes the code I put in.
|
|
And then after a while, somebody started to answer me.
|
|
And so it was already felt a little bit better than just being by yourself.
|
|
And yeah, you can follow up finally, I found a solution.
|
|
And it worked.
|
|
I tested it for a couple of days to make sure that it works.
|
|
And then it was actually time to build the blueprint from this one, as I mentioned before.
|
|
The co-pilot while I spent way, way, way more time to get this automation up and running the way I had it in my mind.
|
|
I heard someone in a podcast mentioning co-pilot.
|
|
I was going to solve my problem with co-pilot because that's a no-no.
|
|
Of course, many people do that.
|
|
But for me it was, I wanted to understand what I do and I wanted to do it in the most efficient way.
|
|
But as it was running now, I thought I have some comments in my YAML.
|
|
I have an introduction text to my YAML.
|
|
Why not open, where did I go to do that?
|
|
Yeah, I simply went on Bing.com, as far as I remember, with my Firefox.
|
|
And I was looking there for co-pilot, put in my complete YAML,
|
|
copied my YAML stuff and paste it on the comment prompt.
|
|
This one in and then co-pilot asked me, do you want a quick answer or a long answer?
|
|
And I'm waiting for the long, not do you want a quick think about it or a longer thinking about it, more like that.
|
|
I go for the longer one and I was hoping to get the better result.
|
|
And so it came back after, I don't know how long,
|
|
30 seconds or a minute, I don't remember.
|
|
And I was looking at the code and on the first side, it looked quite good.
|
|
So I copied the code given from co-pilot and I have to admit that
|
|
the text it generated to explain what it is actually doing was quite well.
|
|
So for example, well, okay, I guess I already adjusted this one a little bit, but he says like
|
|
triggers and conditions. The blueprint uses both a state change from not home to home
|
|
for your PC tracker and the motion sensor activation.
|
|
A numeric state condition ensures that the automation only runs when the ambient lighting
|
|
from your illuminant sensor is below the defined threshold, default 37 locks.
|
|
This minimizes unnecessary operations when the area is already well lit.
|
|
So the wording itself and so on came over quite nicely.
|
|
And so then it was time to test the code.
|
|
So I copied the code as it is and put it in the home assistant and it wouldn't work.
|
|
So I was a little bit disappointed as I thought everything was done.
|
|
I mean, with such a nice text in the intro.
|
|
So the co-pilot didn't add a device class.
|
|
So I had to, when I used this KDIF, I'm using KDE, I used this KDIF to compare the
|
|
the code I had with the blueprint and then I saw some differences.
|
|
Well, several differences, some are relevant and some are because it is a blueprint and not a
|
|
pure yellow. And also missing was a minimum and maximum value per input.
|
|
And therefore, the list showed useless items in the graphical user interface.
|
|
Instead, the one with necessary capabilities.
|
|
The device class does define whether it should show up with a bulb with a light
|
|
or whether it should show up with motion sensor or such.
|
|
So I added, for example, device class motion or the device class illuminance.
|
|
And so when I added that, I tried it again and it worked.
|
|
And I was almost happy, but just almost.
|
|
Because co-pilot changed my terminology of some of the entities or the input devices.
|
|
And I wanted to have the same entities or text as I used in my previous
|
|
blueprint. Because, well, you do that once and the next time you look at it and you compare it,
|
|
you're much faster up to speed and understand what is going on.
|
|
So anyway, with KDE, with the text editor in KDE, it was kind of easy to search for this pattern.
|
|
And replace it with that one. And so he did, this was quite quick and without any error.
|
|
And finally, I had my blueprint.
|
|
I hope this was a lot of motivation for you to go ahead and try to do another
|
|
automation on your home assistant. By the way, with Enmap, you can, of course,
|
|
detect several things. For example, if you have your TV on a cable or on your Wi-Fi or if you have
|
|
your TV box connected to it, you can base on that presence. Think about you want to change the
|
|
light, you want to change anything in based on this TV on or off or the box, whatever.
|
|
So if you like, leave a comment, send me a message or record your thoughts on that topic,
|
|
what I've done wrong, what I should have done better. Oh, and before I forget it,
|
|
where is the squirrel? I haven't heard it for a long time. Have a nice one.
|
|
You have been listening to Hacker Public Radio at Hacker Public Radio.
|
|
Today's show was contributed by a HBR listener like yourself. If you ever thought of recording
|
|
a podcast, you click on our contribute link to find out how easy it really is.
|
|
Hosting for HBR has been kindly provided by an honesthost.com, the internet archive and our
|
|
things.net. On this otherwise status, today's show is released under Creative Commons,
|
|
Attribution 4.0 International License.
|