So flexible that it's not easy to start to do cool automation things for RaZberry newbies.
You can do a lot of automation tasks in different ways and manner - via different HTTP APIs, modules or scripts(need some learning) or you can do simple logic with some modules (too basic and not well documented though).
I'd like to present an intermediate solution(between full featured scripts and simple module rules) - eaZyLogic module . You can start writing your logic rules in a couple of minutes (you need just basic knowlege of JavaScript).
I also plan to use it for my simple automation scenes.
it's still in developement, so comments are welcome.
Tested on - 2.0.1rc-24 Current version 1.0.2
Update 1.0.2
Chain logic rewritten
Added support for IR remote controls - onRemote()
Update 1.0.21
Added support for IR remote controls - remoteSendKey()
Basic Usage
Device basic control
The name for device for _z function can be ID or title of device from your HomeAutomation UI
You can use any javascript code to program logic inside functions.
Code: Select all
//Set dimmer light level
_z('dimmerBedroom').setLevel(50);
// Switch dimmer on/off
_z('DimmerBedroom').on();
//Switch wall plug off
_z('wallPlug').off();
//Get Temperature
var temp = _z('motion sensor temp').getLevel();
//select two dimmers from different fooms and set level to 50
_z('lamp on desk in cabinet, dimmer2 in kitchen').setLevel(50)
// switch 'lamp at entrance' device in room 'hall'
_z('lamp at entrance in hall').on()
//select all devices with 'lights' tag
_z('all lights')
//select all devices with 'lights' tag in room 'hall'
_z('all lights in hall')
//select all devices with 'lights' tag in room 'hall' (force tag use if you have 'all lights' device)
_z('all with tag lights in hall'')
// Select all devices with 'always armed alarms' tag (flood seensor, etc.), arm it and send notification
// if breached (you can use Javascript functions instead notifications
_z('all Always Armed alarms').arm().onBreach('Alarm!)
// disarm so that you do not recieve notifications
_z('all general alarms').disarm()
// The next device selection patterns exist (also can be passed as array)
_z('dimmer1, 'dimmer2, dimmer3', 'wallplug at basement')
Add delays between commands in chain
Code: Select all
//Switch on dimmer after 3 sec
_z('DimmerBedroom').delay(3).switchOn();
//Switch on and after 4 sec switch it off
_z('DimmerBedroom').switchOn().delay(4).switchOff();
Do some control on device group
Code: Select all
//Switch off all 3 devices at the same time
_z(['dimmerBedroom', 'dimmerHall', 'wallPlug']).switchOff();
Activating scenes. Before use you must create 'Dummy Device'(binary switch) from module of 'Devices' section to control scene activation.
Code: Select all
var scene1 = function(){
_z('dimmer1').setLevel(50);
_z('rgbw R').setLevel(10); _z('rgbw G').setLevel(20); _z('rgbw B').setLevel(30);
_z('blinds').setLevel(0);
};
_z('scene1 dummy switch').onSwitchOn( scene1 );
Handling events from devices
Code: Select all
//Create and send notification. You can use SMS module to send notification to your phone
_z('Motion sensor').onSwitchOn('Motion!');
_z('Motion sensor').onSwitchOff('No motion!');
_z('Flood sensor').onTrigger('Flood!');
_z('Door sensor').onBreach('Breached!');
_z('Motion sensor').onIdle('Idle!');
//or do some more spohisitcated stuff
_z('Motion sensor').onSwitchOn( function() {
if(_z('Light sensor 1').getLevel() < 400){
_z('dimmer2').switchOn();
}
});
Create alarm zones and recieve a notifications when breached. Before use you must create 'Dummy Device'(binary switch) from module of 'Devices' section to control arm/disarm.
Code: Select all
// Create alarm zone with device list
var alarmZone1 = ['Door senosr Entrance', 'Door senosr Backyard', 'Motion Sensor1', 'Motion Sensor2'];
// Set Arm or Disarm state with dummy switch
_z('dummy arm/disarm switch')
.onSwitchOn( function() { _z(alarmZone1).setKey({isArmed:true}); })
.onSwitchOff( function(){ _z(alarmZone1).setKey({isArmed:false});});
// Send just notification in case of breach (you can setup SMS module to recieve SMS on your phone)
_z(alarmZone1).onBreach('Alarm!');
// Or more sophisticated example with some logic
_z(alarmZone1).onBreach(function() {
_z('switch1').switchOff();
_z.notify('alert', 'Hey!!!', 'core', 'eaZyLogic');
});
Copy and unpack the attached file to your 'userModules' directory of Razberry.
Restart z-way server form command prompt - 'sudo /etc/init.d/z-way-server restart'
How to start use
Go to 'preferences' menu in your Home Automation UI.
Select 'modules', then 'Automation' section.
Select 'EaZyLogic' module, put title and some description, got next page and enter your code in textarea.
Example (replace 'my dimmer' with your device name from HA UI)
Code: Select all
_z('my dimmer').switchOn().delay(2).switchOff().delay(3).switchOn();
You can then edit code for your created module in Preference->Automation menu later.