The JeeNodes are running perfectly these days. One jeenode per room (hallway, livingroom, kitchen, shed, outside, hallway upstairs and bathroom). Stable and not missing a thing
One thing I focused on was how to define rules. It was done in the database completely. So you edited your rules through the web interface. This was all nice but adding a new type of rule or an action took a bit of work. I added an intermediate layer in the code. So one can define rule providers. One being events defined in the database. I also made file based rule provider. Which just add rules to the ruleengine. Some simple examples to define rules through the file based rule provider:
Code: Select all
$rules[] = Rule::create(Rule::TYPE_MANUAL, 'Er is beweging buiten terwijl beveiliging aan is')
->addTrigger(new Rule_Trigger_ValueBased(OUTSIDE_MOTION, '1'))
->addCondition(new Rule_Statement_FlagBased(FLAG_SECURITY, 'aan'))
->addActionOnTrue(new Rule_Action_Xtify('Er is beweging buiten'))
->addActionOnTrue(new Rule_Action_StartScene(SCENE_LOG_PICS));
$rules[] = Rule::create(Rule::TYPE_MANUAL, 'Voordeur is lang open')
->addCondition(new Rule_Statement_WatchExpressionHoldTime('dooropen', 180,Rule_Statement_WatchExpressionHoldTime::GREATER))
->addCondition(new Rule_Statement_WatchExpressionHoldTime('dooropen', 245,Rule_Statement_WatchExpressionHoldTime::LESS))
->addActionOnTrue(new Rule_Action_SayWithGoogle('The frontdoor is still open, don\'t you need to close it?
$rules[] = Rule::create(Rule::TYPE_MANUAL,'Er is post')
->addTrigger(new Rule_Trigger_ValueBased(129,'1'))
->addActionOnTrue(new Rule_Action_Xtify('Er is post!'))
->addActionOnTrue(new Rule_Action_PlaySound('mailmanbeenhere.wav'))
->addActionOnTrue(new Rule_Action_StartScene(SCENE_LOG_PICS));'));
This is far more flexible and allowed me to add a whole bunch of rule types without the need of updating all the web parts on it. This can be done later on. This whole refactoring of the code all began when I was thinking about the next step. I wanted a simple rule expression language for defining the rules. Why? Because when I got my voice recognition software in place I wanted to add a rule by just saying it. Stuff like this:
- Add a reminder on 6 o'clock saying "Please visit the grocery shop"
- Remind me when a tv show begins with the name Friends
So I decided to built a third rule provider. The domain specific language provider. It makes rules expressed as text runnable:
- If the hal and the woonkamer or the tuin has motion then take picture from "Camera tuin"
- If woonkamer button is pressed then turn off all lights except salontafel-lamp
- If spraakmodus is equal to off then brighten keuken keukentafel-lampen to 50% and keuken keukentafel-lampen
The same rule provider will hookup in the voice recognition someday. This is all working great. Some other small things during this code refactoring:
- Added support for delayed actions. Actions which will execute X seconds from when the rule was triggered.
- Trigger a rule when the distance between two mobile/location trackers is in some condition (near each other for example so I can let my GF know I'm heading towards her).
- Added support for when a certain value has a certain condition for some time (the frontdoor is open for too long).
And finally I bought myself a touchscreen PC! With zero moving parts in it (Passive cooled Atom processors and a SSD hard disk).
http://fotoboek.vandulmen.net/domotica/IMAG0308.jpg
I installed windows 7 on it and Google Chrome. The touch interface I'm still developing. It runs inside a google chrome fullscreen session. Which works perfectly. I also was amazed at how good the speech recognition is in Windows 7. I also found this neat little program called VoxCommando. It uses the speech recognition of windows 7 and enables you to configure custom commands to a certain command. Turning on and off my living room lights with this took my only 15 minutes of configuration! So I can now turn on/off lights just by saying it!!! In the next period I will add loads of commands to make it more valueable.
Greetings from the Netherlands, Arnhem!
Gijs