Latency In The Smart Home
Latency (Wikipedia definition) is a measure of the time delays experienced in a system such as a smart home. There are many sources of latency in the smart home and this article aims to provide some insight into this latency, where it occurs, the real-world implications and what you can do to minimise its impact. Latency should be a consideration in any smart home design and must be considered when installing structured wiring and any home automation equipment.
Sources Of Latency
This is not an exhaustive list but, provides a view of the main sources of latency in the smart home:
Any 'dumb' sensor from a Dallas DS1920 1-Wire temperature sensor to a HIH-4021 humidity sensor (pictured) has some inherent latency. Sensors like this take time to stabilise and establish a reading that can be extracted from the sensor. Thankfully, these delays are usually very small but, latency should be a consideration when selecting your sensors.
Even a simple digital sensors such as PIR sensors have latency, especially if it uses a internal relay and not solid-state electronics. Relays take a small amount of time to switch their contacts. Most PIR sensors even have jumpers to deliberately configure them so as to introduce more latency. The sensitivity can be adjusted by setting the number of pulses required to trigger the output. These delays can be significant (several seconds) when you want to detect occupancy and then take action based upon it.
The location of a sensor is also a huge factor in its latency. A humidity sensor in the bathroom may be just a few feet away from the shower cubicle but, it will take many seconds (or maybe even minutes) for the moisture from a shower to reach the sensor's location.
PIR sensors used to detect occupancy need to be close to entrances and exits, in order to rapidly detect people moving. A ceiling mounted 360° PIR sensor in the centre of a room will take longer to detect someone walking into it.
The height at which a temperature sensor is mounted, will affect its ability to detect temperature rises from under floor heating. It is for this reason that we have 3 temperature sensors in our conservatory, one at floor level, one and 1.5m above the floor and the third at ceiling level. These can then be used to decide if the ceiling fan should be switched on, to mix the air up in the conservatory and get a much smaller temperature gradient within this room.
The process used to actually collect a measurement from a sensor will also introduce latency. The electrical signal passing down the wires introduces a tiny delay. Analogue sensors such as temperature or humidity sensors require an analogue to digital conversion which also takes a finite amount of 'measurement' time.
We use Dallas 1-Wire for some of our temperature sensors, binary sensor interfacing and also weather sensors. The 1-Wire technology uses polling, which is a source of huge latency. If anything in your design or installation is using polling then take a long hard look at it and ask yourself, is there a better way to do this? Technologies like this must be used wisely and applied to situations where latency will not be an issue. We also tried some PIR sensors connected via 1-Wire devices but they changed state faster than the DS2405 input sensors can detect and report back. We quickly moved to an alternative technology for our wired PIR sensors.
If there latency in requesting a particular state from a device, then there will most likely be a similar delay in getting back an acknowledgement that the requested state has been set.
As an aside - we only use home automation technologies that provide 2-way communications and acknowledgements. Without this, there is no way of knowing that something requested has actually happened. In many home automation applications (security, safety, etc.) this is essential.
Any form of networking is going to introduce latency. Wired networks are generally faster than wireless and have lower latency but this very much depends on the networking technology being used.
Wireless IP networks (Wi-Fi) inherently introduce latency and a large number of external factors (congestion, packet loss, interference, lower speeds, etc.). There are many reasons not to use Wi-Fi for smart home automation and latency is just one of them. That said, it does work well for remote control interfaces (apps) on Smartphone and tablets, where latency is less of an issue.
Wired IP networks are fast, reliable and provide very low latency if used correctly. Typically, this means separating home control and automation traffic from general data flows (web browsing, backups, etc.) and especially from entertainment traffic (e.g. video streaming). Note that this is much harder when using Wi-Fi and other wireless networks. This separation can be done using network switches or physically separate network cables and infrastructure. If your home automation control data is sharing the same network as high-definition video streaming, then latency will increase long before you approach the maximum throughput of the network.
Processing & Analysis
The processing and analysis of sensor and other data is what makes a smart home really smart. It needs to be able to do this in a real-time fashion with very low latency, in order for the people in the smart home to not be frustrated by visible delays in things happening.
We have a centralised Home Control System (HCS) that receives all home automation messages and events. It is written in Java and uses multi-threading to provide excellent performance. It runs on a low power mini-ITX PC and runs the Debian Linux operating system. During a typical weekend day (someone is at home all day), it will handle over 100,000 real-time events (average ~1 per second) and analyse and action them all in less than 1ms. In our next home we expect this to rise to over 500,000 daily events (average ~6 per sec) and are confident our HCS could easily handle many millions of events whilst maintaining this performance and very low latency.
In order for the 'controller' to achieve this, it needs to be situated in the smart home and be connected to a low-latency wired network. We are using 100Mbps Ethernet and Cat5e cable. The overall speed is less of an issue due to the relative low volume of data being sent and its relatively even distribution over the course of a day. Home automation network data is rarely 'peaky' in nature. We keep latency low by keeping home automation data on a separate network. We also do this for resilience and reliability with our home automation network being protected from power outages using a 12V UPS.
A hybrid solution is possible and devices like those used with Z-Wave can support the concept of association, where control signals are passed directly from sensor to device. Whilst this works for simple tasks, it doesn't enable full context and intelligent and learning-based control.
If you have networked actuators and devices, then they too are subject to network latency and the devices themselves may introduce some more latency too. Our preferred approach is to use Ethernet connected I/O or USB connected I/O board I/O as these provide the best performance and reliability.
Where we cannot run physical wires in our current home, we are using Z-Wave mesh networking, which provides fairly low latency as you can see from the examples below.
Internet & Cloud
As soon as you introduce the Internet into the measurement and control loop, you introduce a lot of latency. More of the problem than the actual latency introduced is the lack of predictability and control now present. A cloud service could be down or temporarily unreachable. You local exchange could be highly congested at certain times of the day, resulting in latency of many seconds.
We have deliberately designed our HCS to be autonomous and to operate independently from the Internet if need be. It does use network and cloud services but, makes no assumptions about them being available.
We consider 'smart sensors' to be a source of latency, because anything that sits between a dumb sensor and its ability to provide raw data into the decision making (intelligent) controller will simply slow things down. So called 'smart sensors' provide additional complexity and prevent simple and fast access to the basic raw data by often adding a 'service wrap' or limited and proprietary APIs to gain access to it. Many also try to make complex decisions with a very limited view of the wider smart home context. A collection of smart sensors from a competing group of vendors will not work in harmony and there will be duplicated functionality and many compromises.
Put simply, I want (for example) my smoke detectors to detect smoke and let my home automation controller quickly decide what to do with this information, whilst taking into account all the other information and context available. This is why (to continue the example) we won't be buying the Nest Protect.
Why Does It Matter?
Having covered many of the possible sources of latency in the smart home, you can hopefully see that they might all add up to significant delays, especially when you want a sensor to trigger an action that is highly visible to someone within your smart home.
Latency is also not always consistent. It can have the effect of delaying some 'events' but not others. This could mean that things that happened in a particular order in the real world, could appear to have happened in a different order at the controller (where the decisions are made). Some examples:
- If one of the events was to open the garage door and the other was to close it (e.g. someone quickly changed their mind), then swapping the order of those events would result in an outcome very different to that desired.
- As you walk out of the house, you trigger the PIR in the entrance hall and then shut the door and activate the alarm. If the PIR sensor is wireless and latency delays this message getting back to the controller, the controller will then see the front door shutting, the alarm being activated and then the PIR sensor triggers the set alarm.
- You open the door onto the landing at night to go downstairs. The wireless door contact sensor latency means that you are walking down the stairs in the dark before the controller sees an event that causes the lighting to turned on. Latency in the controller and in sending commands to the lighting also add to the delay.
- When users experience the effects of latency, things can appear not to work, leading to frustration. If the same button on a remote control is used to toggle a lamp on or off but, the first button press is subject to latency, the user will press the button again. Again, the result is a long way from that desired.
So people care about latency. But not as much as machines like smart home controllers!
The following video clip shows a real-world example in our current home. The steps involved and the latency introduced here are:
- A reed switch in a Z-Wave contact sensor is opened as it moved away from the magnet hidden in the door frame. There is a delay due to the range of the magnet and time a reed switch takes to operate.
- The Z-Wave contact sensor is hidden within the door and takes some detect the reed switch change of state.
- It then sends the state change over the Z-Wave mesh network to our Vera Lite Z-Wave gateway.
- This then sends a structured message to our Home Control System (HCS) over a dedicated wired Ethernet network.
- Our HCS then processes the message and decides on appropriate action. Our test and monitoring show that this takes less than 1mS.
- Our HCS then sends an HTTP request over the same IP network back to the Vera Lite.
- The Vera Lite then sends a Z-Wave control message to a Fibaro FGD211 dimmer module to turn on our hall light.
As you can see in the above video, this is a real-world example where the latency between door opening and the entrance hall light coming on is clearly evident but not significant from a user perspective. The annoying thing is that this is not always the case though. Our Z-Wave installation has proven to be variable in this respect. Generally performance is good but, on occasions there are more noticable delays.
If we were to use wired technologies to address the exact same problenm in our home (and we do in other rooms), the latency is consistently undetectable. The light on the other side of the door is much like the light in your fridge. It comes on before you can see it was actually off.
What Can You Do?
- Position sensors wisely, to ensure they are in the best location to detect and measure the thing they were installed for.
- Select sensors and devices (and associated interface and networking technology) carefully, to ensure suitability for your intended application.
- Avoid wireless networks if at all possible.
- Structured wiring is the best option but, make sure the topology is right for the environment and layout of your home.
- Use ducting to support easy installation and upgrade over time.
- Keep IP network traffic types (e.g. home automation, general home usage and entertainment services) apart using switches or physically isolated networks.
- Use a high performance smart home controller.