Smartest Smart Home On Twitter
The objective of this project is primarily to educate people on what a smart home is capable of using real-life examples and automated statements about our smart home. In addition, it is a learning exercise for us, to see what events and information can be usefully exposed via Twitter. Some of it is simply to show the world how smart our home really is. We are aiming to makes it the world's smartest home!
There is not a fixed set of things being tweeted by our smart home. We try out stuff and add and remove things often. Our smart home also has a 'demo mode' where it sends many more things to Twitter.
What To Tweet?
Once a day our smart home makes an automated statement about its capabilities. These are taken randomly form a long list of statements that we have created over time. Most of these refer to things that our smart home can currently do but a few of them refer to developments in progress.
Privacy & Security
The main thing limiting what we connect to our Twitter account is the privacy and security implications. A lot of the information and events collected are very sensitive and could be used to infer things such as when our home is empty. For this reason we are very careful about what we expose via this channel. We have also added a degree of randomness to the things we tweet, so that it is much harder to infer things reliably for the tweets exposed.
Warnings & Alarms
We currently tweet various alarms:
- Air pressure is falling rapidly.
- Letterbox has been left open longer than 180s.
- Mains power failure and power restoration.
- Our wormery internal temperature is too low.
- Our wormery moisture tray is full.
At random intervals our smart home exposes a randomly chosen sensor within our smart home and its current value. This is to help expose the huge number and type of sensors we have deployed and networked. This doesn't include the PIR sensors in each room as these generate too many events and expose too much real-time occupancy data.
At random intervals our smart home also exposes a randomly chosen device within our smart home and its current status. This is also to help expose the number and type of devices we have deployed and networked.
We are currently exposing status changes of some devices in real-time as an experiment. An example of this is my wife's hair straighteners, which have been networked using Z-Wave technology. This is an excellent example of how the smart home can be used to provide assisted living and telecare features.
Weather & Environment
Our smart home includes a local weather station and a lot of sensors measuring environmental conditions and air quality. In addition it is connected to a number of IoT sources and also extracts and analyses on-line data feeds. Part of our smart home is a 'weather service' that collates all this data and analyses it, identifying significant elements.
Each morning our smart home delivers a daily weather outlook and this is exposed via Twitter.
If the atmospheric air pressure changes significantly, then the latest value is tweeted. We are currently working on modelling this over time and spotting trends in the data to provide useful insight. These may result in warnings if for example, the air pressure is dropping rapidly, indicating that a storm is coming.
All events and alerts from our networked wormery are tweeted.
Our Home Control System (HCS) is written in Java, so we have used the Twitter4J library to enable our smart home to sends tweets. We have set up a Twitter account specifically for our smart home: @smartest_home
We have written this functionality as a simple queuing system. We could have used a more complex library like JMS but our code is simple and does the job.
The TwitterService runs as a separate thread and is started by our main Home Control System (HCS) process. The code to start it looks like this:
TwitterService twitterservice = new TwitterService()
It basically polls the Tweet queue every second looking to see if there are any tweets to be sent. Polling isn't ideal but the processor load is negligible when done like this.
Source code: TwitterService.java
This class implements a simple queue of tweets to be sent by the TwitterService. The class has static methods that can be called without a class instance. The methods are therefore synchronized to enforce queue discipline.
Source code: Tweet.java
We have found it quite useful to connect our home to Twitter. In particular it has proved useful to know when mail and parcels have been delivered and it is also a nice way to check changing weather conditions without explicit notifications.
This is a project in progress! We plan to try out many more data feeds and connect many more smart home sensors to our smart home's Twitter account.
This is a widget showing some recent tweets by our smart home: