Current State of presence detection

You do not need to use two different network cards. All you have to do is a little subnetting.
Right now you are using up address space for more than 500 thingies. Do you really have that much equipment?

If not then use a subnet calculator, and devide up the 192.168.1.0 to more /25, /26, /27 subnets
Try this: http://www.subnet-calculator.com/cidr.php

But the easiest is to set your computer (rpi) to a 192.168.1.0/23 subnet, or 255.255.254.0 broadcast (192.168.1.0 - 192.168.2.255). This way it will be “on both subnets”, and set other device to /24 subnet (192.168.1.0/24 and 192.168.2.0/24) so they won’t see each other
But keep in mind the larger the subnet, the longer it takes to do anything (dhcp, nmap, etc.)

Generally speaking using subnets rather then IP from-to is better/faster.

tom

I sure wish that made more sense to me. I tried to read up on it but still do not grasp the concept. I have about 18 devices on the Home Automation/Security subnet and 20 on the ‘family’ subnet.

My primary purpose for even dividing the two was that I seemed to be bogging down the primary network with cameras so I moved them along with the HA to a different router & network/subnet (as far as I understand). I will probably add 2-3 more cameras before it is over with and maybe another Dot.

Ok.
Every network no matter how big or small it is must have a “nomination ip”, a broadcast address, and some ip addresses.
Normally you can have 254 different machines on one home network. That is how all routers and other home iot things are set up in default. That means that you can have ip addresses from say 192.168.1.1 - 192.168.1.254. This means that your network is a /24 network, your broadcast address is 192.168.1.255, and your “nomination ip” is 192.168.1.0.
But you can segment it to almost any portion. The portions are not obvious that is why you need a network calculator.
Lets stick at the default 192.168.1.0/24 network. A /25 network devides the /24 network in two halves, so you will have a network of 192.168.1.0/25 and one of 192.168.1.128/25. A /26 network devides your original /24 network into four subnets, so you will have 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26, 192.168.1.192/26.
A /27 network gives you 8 subnets, and so on until /32, which is a special one ip network.
All you have to remember about this, is that the very first ip of the network is the “nomination ip”, and the very last one is the broadcast address. So you can not use those for any machine on the network. That is why you can not devide a network into 3 segments, only 2, 4, 8, etc.
So in the 192.168.1.64/26 network, you will have ip addresses from 192.168.1.65 - 192.168.1.126, which gives you 62 devices in one network.
According to your post /27 subnets would be enough for you, because a /27 subnet gives you 30 devices per subnet.

But you should keep in mind that after a couple of months you will forget about your subnetting and if you have more then 30 devices in one subnet then you will run out of ip addresses.

Because you actually have two different things you wish to separate (cameras, other devices) you can safely use /26 networks, which means you can have 62 cameras, 62 other devices, and still have 128 ip addresses to spare.
I have made a little drawing for you, for easier understanding.

The ip addresses on the my little diagram, are just examples. If your router has the 192.168.1.254 address, then you can give your computer 192.168.1.253 or anything else until you stay above 192.168.1.128.
Or if your network is built up from the “other way”, so your router has the address of 192.168.1.1, then you switch your other devices (raspberry pis) to the 192.168.1.128/26 network, and the addresses become: cam1: 192.168.1.129, cam2: 192.168.1.130, cam3: 192.168.1.131, cam4: 192.168.1.132 and cam5: 192.168.1.133. Everything else can stay the same as per my diagram.

Of course using subnets you will encouter your next problem, namely “howto give a device an appropriate address automatically?” But first you will need to get a little more comfortable with how a network works.
Hope this helps!

cheers
tom

2 Likes

Sorry for hijacking the thread!

tom

that was actually one of the clearest explanations I have seen yet. Thank you. I am sure I will be rebuilding in the future and will take this into account. I am severely under-utilizing a DL380 G7 server that I want to take advantage of.

ok, let me ask what to the network guru’s on here will be a silly question I am sure, but why not just stay with the /24 subnet and assign the cameras 192.168.1.* and the family devices 192.168.2.*. I a private subnet are we really that concerned about spare addresses?

You could even put an alias on your eth0 with a second IP address in the second subnet…

1 Like

How about this: https://www.happybubbles.tech/
It’s a bit like with beacons, but just the other way around.
If I’m correct it should be possible to have your phone to be detected as a “beacon”

I’ve got a couple of the happybubbles devices. The problem with using your phone as a beacon is that if you have an iPhone, you still have the same problem with it going to sleep occasionally and not talking with the happybubbles sensor. But they are very cool little devices.

First, no we are not concerned about spare addresses, but the bigger network you have the longer everything takes (eg. nmap scan). If you have 8 devices why would you want to scan 256?
If you set your subnet right you can have nmap scan your devices every 5 seconds, so you minimize false home/not home states.
Second in a /24 subnet 192.168.1.* devices will not “see” 192.168.2.* devices, and the other way around because a /24 subnet means ip addresses 192.168.1.1 - 192.168.1.254

If I’m using nmap for presence detection, I am going to scan for specific devices not the whole network. If I’m doing it to see if any rogue devices showed up on the network, I’m going to do that once an hour or so, not ever 5 seconds.
I don’t understand the relevance of your second answer though. Regardless of how you subnet your network, the two subnets aren’t going to talk with each other unless there is a router to handle traffic flow between the networks or you play games with subnetting your PC so that it spans two subnets.
If you are a network professional, subnetting the PC across the two subnets is ok, you know what you are doing and understand what’s going on. But if you aren’t in that part of IT or are not familiar with IP addressing, it’s confusing and asking for problems down the road when you add new devices. I’m also unsure if you could use DHCP in that situation to assign addresses without having a router or DHCP server that can handle multiple subnets.
It just seems like a lot of trouble to go through when the gains on a typical small home network probably aren’t that great.

First of all I did not meant to be rude or a wiseacre, but reading the posts in the forums most of the problems are because people do not know the basics of networking. Because of the plug-and-play style of things today. Most problems would not even arise if they knew what was going on their home network. (and if they knew the difference between public and private ip, and what the hack nat is) So…
If you are doing nmap scans hourly then you can not time automations with it. if you scan at 8:00 and then leave at 8:01, then you will have to wait 59 minutes for HA to realize that you are not home.
Usually you should not have more then 20 devices to watch out for. Setting them to a smaller subnet, and setting your HA server to a bigger, needs only a little planning. And then you can scan the smaller subnet, because you want to know what devices are active there, and it is the same thing as setting 20 different ips or macs in the config file, and also takes the same time.
If you have three devices you wish to track, it does not make sense to me to set the first to 192.168.1.1, the second to 192.168.1.50 and the third to 192.168.1.250, just because I have a lot of spare adresses.
And as you mention DHCP, it is great example that assigning dhcp addresses for a /26 network takes less time then assigning IP addresses for /23 network. And less leases to keep track of. Of course this does not matter if you have an 8 core server with lots of gigs of RAM and a gigabit network, but if your thinking about using eg. a pi as your HA server, things change.
Not to mention that it is easier to set/update a firewall rule (or any other rule) for 192.168.1.0/26, then to set the same rule for 1.1, 1.50 and 1.250.
And if you are scanning by hosts then you will need to upgrade your configuration any time a new device is added to the network (e.g. you buy your kid a phone, or add a tv in the loo), but if you use subnets all you have to do is assign an ip to the new device from the “subnet to scan”, and woila everything works like magic!

cheers

I didn’t take it that way, we are all passionate about our professions and that’s a good thing.

I completely agree. But that is also the reason that it’s sometimes better to just go with the plug and play nature of things instead of trying to help someone get a technical solution that may be better than the plug and play one, only to end up helping them break their network along the way to where it frustrates them because that’s not the area of life that they have focused their knowledge.

that way more than I watch. I watch 4 IP addresses for presence detection, two printers for toner levels, and one server just because I’ll get complaints if it’s down from my family. The printers and server only scan about every 30 minutes because they aren’t time critical. The 4 iphones, scan much more frequently, about once every 5 minutes.

How are you determining who is who if you aren’t reserving IP addresses for your phones? If DHCP doesn’t assign the same address every time, you have to go in and adjust your config don’t you? What I do is when a new phone comes home, I adjust the DHPC reservation list on my router to assign the IP address of the phone that went away to the MAC for the new phone. Then everything works just as before.

What you are doing is great and is definitely more efficient that the plug and play methods most others are using. But like you said, most of us don’t know enough about our home networks. For that reason, I think most people are better off taking the performance hit and having something relatively easy to support that they are comfortable with than with a high performance network that they don’t understand and can’t support going forward. But with that said, this is a unique group of people that like to fiddle with things and learn about new technologies, otherwise they would have settled for the commercial off the shelf home automation solutions. I guess up to the user how much time they want to put into the network part of the solution.

1 Like

Hi,
I have my eye on this company:

Their bluetooth enabled smart power outlets build a mesh network and presence/location is a feature.

Regards,
David

It took a while, but we - Crownstone - are officially supporting Home Assistant now. The pull request is at https://github.com/home-assistant/core/pull/37005. All feedback on the presence, location functionality is very welcome. At crownstone.rocks/indoor-localization/ we created a list of methods with pros and cons. Currently, we are using fingerprinting, but in-network localization is in the making. If you have questions, feel free to drop them.

Note that the positioning is not perfect. If you run a classifier on the fingerprints that is classifying the right room 99% of the time and you do this every second, there are 86400 decision moments. If you require 5 of the same consecutive decisions you can model this by Bernoulli trials. For a time period of an hour this leads to a chance on a mis-classification of 3.18% (wolfram). That’s a 54% chance per day. Note, that this introduces a latency of 5 seconds. You might need to do voting (rather than requiring 5 consecutive values to be the same) if your classifier becomes worse. In that case you’ll have even more false negatives.

Then you have actual real-world situations in which you accidentally sit on your smartphone which will definitely screw up the propagation of Bluetooth signals. :smile:

What we encounter is that the system is - almost perfect - for slowly tracking position. Think of sitting on the couch and then turning on the lights at sunset. You will need to know that someone is in the living room, but the light can turn on after say 10-20 seconds without you noticing the delay. In contrast, the scenario where you walk into a room and the light immediately has to switch on requires you to have such low latencies that you will suffer from false positives. This must be countered in e.g. having an “off” command responding slower than an “on” command. It also depends on your preferences. If you like to have the lights on in neighboring rooms this will be much less visible to you then if you like to have the light on only exactly there where you are.

I hope this gives some more insight in how such a system works! Enjoy the integration as soon as it will be live!

1 Like

Just found Crownstone, very interesting feature about indoor positioning. Can it use devices other than mobile phone, e.g. wearable fitness tracker (Samsung Galaxy Fit etc.)? Also, do you have any plans to integrate power consumption without usb-doungle?
P.S. I find descriptions on the crownstone site very vague and not to the point/without details. Actually, it is not clear what is the main feature of this product; I would think it is presence/position detection but information is rather about switch/dimmer functionality. Even in Home-assistant it is in Light section which is odd.

Hi!

Apologies about the website being vague. We’ve designed the Crownstone modules to pack multiple functions because you can only install one module behind an outlet. So it can handle 16A as well as dim LEDs as well as performing indoor localization as well as doing energy monitoring.

Currently we support smartphones, but not yet fitness trackers. We’ve done most of the groundwork for this recently though.

You can find more detailed information on the https://github.com/crownstone/crownstone-home-assistant repository if you’re looking for more details pertaining to Home Assistant integrations.

The power consumption data is communicated over Bluetooth mesh towards other nodes in the system. The USB dongle is the way to get the data out of the mesh. If a smartphone would be used for this, you’ll get a very haphazard picture of the power consumption because the phone might not be at home. Also, the fact that the phone is not using Bluetooth mesh itself means that the data flow is severely restricted.

Our first pull requests towards Home Assistant had support for all platforms. The HA maintainers however prefer one platform to be added at a time. We started with light because to be able to control the Crownstones seems to be the most logical first step. You can find more functionality at HACS, see also the link above.

1 Like

Thank you for your explanations. Definitely, the HACS integration contains more useful features and info. Really hope it will be implemented in the main integration in not very distant future.

To me and, hopefully, for some other users here, very uniqe and the main selling point/feature would definitely be indoor positioning, otherwise, there are already so many other switches/dimmers on the market. I understood that there are some precision/latency considerations but still be worth to advertise indoor positioning more prominently. Looking forward to seeing fitness trackers to be implemented!

As for energy monitoring without the USB-dongle, I was thinking if RPi BLE integrated capabilities could be used to communicate with crownstones rather than smartphone or USB-dongle. Necessity of having phone at home seem to me as a limitation while adding one more USB stick to existing Zwave, Zigbee etc. as a burden.

Thanks for your feedback. The indoor positioning feature is indeed our unique selling point. It’s much more complicated than it looks at first sight, so that’s where we can deliver something special.

Regarding the different platforms Home Assistant runs on, the Bluetooth LE stack on them depends on the hardware/chipset that is present. The quality of e.g. the bluez stack has improved over time, but it’s still introducing issues that we don’t have with a dongle. Also the hardware itself can have all kind of issues. The HCI interface might have bugs. There might be dual band WiFi/BLE issues. Etc. etc.

Note that we use lot’s of features of Bluetooth. We’re using Bluetooth Mesh to communicate between nodes. The Crownstones do also scan for incoming Bluetooth LE advertisements to be able to respond with very low-latency towards commands. This means you don’t have the delay that you otherwise would have setting up a connection. If we implement this for HA, it means the hardware has to support broadcasting Bluetooth LE advertisements. Same with scanning, or scan responses.

All these issues we circumvent by providing a dongle that directly taps into the Bluetooth Mesh and delivers a much greater user experience.

1 Like