Last couple of years I have been running mostly a z-wave stack using a vera 1 as the controller and as the event-host. I was writing luup code to get the vera to do things I would like to do with it. I wrote an android app to talk to vera, had a rough version of floorplans up and running, but..... The vera is a piece of cr*p. Debugging is very poor and time consuming experience. A bug in a plugin can take down the entire system, and then either a factory reset or linux hacking to get out of that situation.
So I decided to write my own software stack, which I baptized to SharpControl. The name probably already gives away that its written in c#. It consists out of two parts, a service part and a webfrontend. The webfront end is based on the MVC2 stack, or actually MC stack. Since most of the view part is written in jquery plugins. The webfrontend is talking through WCF to the backend.
The back-end is basically a small piece of launcher code and a contract assembly. It's using MEF as an IOC framework. The most important concepts in the backend are the device repository providers, the storage providers and the event host. The MEF concept allows my to write plugins extending functionality without getting strong coupling. The plugins that are loaded are simply defined in the app.config of the application.
Currently I have the following set of device repositories:
* vera provider, this is using the json interface of the vera to get state from the vera. This allows me to let my software co-exist side-by-side with the vera (currently in use for accessing z-wave devices)
* open-zwave provider provides access to my z-wave devices (at this moment I am only using this in debugging, not production yet)
* plugwise provider
* virtual provider providing
- a sunrise sensor
- various ping sensors, which tell me if computers computers are on / off),
- sabnzbd sensor, which I use to give input when my media center is busy leaching stuff from the newsgroups
- rain sensor, inspired on the plugin from Alexander
All devices notify their changes and these events can be picked up by the other plugins. I have two plugins managing state in my application, one for current state and one for historic state. Both plugins use nhibernate to write the a database. At this moment they both write to sqlite, but other db's are easily possible.
The event host I have only allows coded events at this moment. These events can be defined in an arbitrary assembly and are registered through MEF to the plugin host. The events are written in a fluent dialect, a sample:
Code: Select all
[Export(typeof(ISceneDefinition))]
class SampleScene : ISceneDefinition
{
#region ISceneDefinition Members
public void Define(ISceneConfigurator configurator)
{
configurator.DefineScene(
"bla",
scene => scene
.On(t => t
.Trigger(new RepeatingTimer()
{
Minute = "0/2"
}))
.ExecuteWhenTrue(a => a
.Add(new SwitchLight() { DeviceId = 14, IsOn = true })
));
}
#endregion
}
My domotica system was running in virtualbox on an atom processor (my media centre), but this proved to be very unstable. So two weeks ago I got my ESXI server, which is now running my complete software stack. It's running an windows xp host for the plugwise source software. And for my own software it's running two VM's on ubuntu 11.10, yes I am running code from the evil site on linux. The front-end is using apache and modmono. The backend is running only mono.
Develop time I am running my software on windows7. Running .net code on linux is not always a pleasure, the WCF stack is very partially implemented. So every now and then I have to go back to the drawing board and redesign to get my code in cross-platform shape.
All logging is done using log4net and that is also configured to push it's changes into sqlite. So all various of health monitoring in my software stack can be easily queried.
The ESXI server is something I should have done earlier, this allows me to develop much easier and my code is now running stable since it's on the ESXI server. (Apart from a bug in the webfrontend, forcing apache to use 100% ). The fun thing is that I can easily track this, because my ESXI server goes up 7Watts in usage . Overal the ESXI server is at 42Watts, a bit of a dissappointment I was aiming for less.
I have a huge list of todo's, I am currently working on:
- computer info device provider, providing cpu / disk usage information (possibly also, power on / power off) (a linux variant, windows variant and vmvariant using the API of ESXI)
- implement security
But at this moment it's finally in a state, that it's actually usable. My youngest daughter (3 years) demonstrated that by walking around with the Ipad in the floorplan view and acting like a wizard chanting "simsa-labin" and then turning various lights on / off. She found a new icon on the ipad and found out herself that now the lights could be controlled using magic