Computing Magazine

Let There Be Light! …when There’s Motion

Posted on the 20 January 2016 by Iqjar @iqjar

Razberry on Raspberry Pi + Milight + Fibaro motion sensor + Domoticz

The usual way of operating the lights in your home today is that when you step into a room you turn the lights on by pressing a switch (usually a wall switch) and you turn them off when you leave the room by pressing the switch again. But wouldn’t it be awesome if all this happened automagically, without the need to go to the switch and press it? Well, it can be done if you have some lights which are capable of being automated. But even if you have such lights, how can you automate them exactly and how can it be decided when to turn them on or off? There are many approaches to this problem. The one that we’ll discuss here is using a motion sensor to detect presence in the room and to switch the lights based on the presence. Detecting presence is a complex topic in its own because even if you’re not moving, you can still be in the room (maybe sleeping or sitting inactive). Also it’s not easy distinguishing between human and animal presence and large moving objects (curtains blown by the wind, moving pendulums, etc.) can also be a problem. But in the first step we’re going to take the easy approach and assume that there are no complications. In this context we only need to worry about two things:

  1. Turning on the lights when movement is detected
  2. Turning off the lights if no movement is sensed for a while

Components

Razberry on Raspberry Pi + Domoticz + Fibaro motion sensor + Milight bulb

So let’s see what we need exactly in order to achieve the above goal: turning the lights on or off based on motion (or the lack of it) in the room.

  1. First of all we obviously need some kind of smart lights or smart light bulb sockets, which can be operated remotely by some signal.
  2. The second thing that we need is a motion sensor, which sends a signal when movement is detected and stops the signal when the motion disappears.
  3. Finally we need some kind of home automation server which is running all the time and is processing events, making sure that when the motion appears or disappears, the light is switched accordingly. Note that this component is not absolutely necessary in the case when the motion sensor can communicate with the lights directly. The usual case, however, is that they can’t interact directly and that a home automation server needs to mediate between them.

Let us examine each component in detail. For the sake of easier understanding we’ll start with the home automation server and continue with the smart lights and the motion sensor.

The home automation server software

Domoticz logo

The home automation server software that we will be using for this project is the free and absolutely marvelous Domoticz software. To discover how to set it up and configure it on a Raspberry Pi, read this article.

The home automation server hardware

Razberry on Raspberry Pi
The home automation server that we’re going to discuss here will be a Z-Wave server. To learn about Z-Wave and find out how to put together a nice and cost effective Z-Wave server based on the Raspberry Pi, read this article.

The motion sensor

Fibaro motion sensor

The motion sensor used for this project will be the Fibaro motion sensor. One of the most important features that make it a good choice for automating the lights in a room is that it contains a built in light sensor too (along with the motion sensor, a temperature sensor and an acceleration sensor). Since we don’t want to mess with our lights (trying to turn them on or off) during day time, when there’s enough natural light in the target location, it’s important to be able to measure the level of light intensity. It is also convenient because it helps us avoid trying to turn the light on after it has already been turned on or off after it’s already switched off. Obviously, we could use a regular motion sensor and a separate light sensor instead, but filling the room with sensors might look ugly. The Fibaro motion sensor, on the other hand, is very discrete and quite beautiful in its own way. Another important capability of the Fibaro motion sensor which makes it a good choice for this project is being able to change the length of the time period for which it keeps reporting its state as “on” after motion is detected. This is also useful, by the way, if you wish to use it in a home alarm system because this time frame can be used to define the duration of the alarm. Last but not least it is a good fit for our purposes because it can automatically filter out minor movement (like animal movement).

To find out more about this device, read this article.

The smart lights

MiLight Bulb E27

We could use any kind of smart light bulbs in order to turn them on/off automatically, or even regular bulbs in remote-controlled sockets, but in this example we will be using the Milight/LimitlessLED/EasyBulb smart LED lights that we have examined in the past in this article. Learn about configuring the Milight LED bulbs in Domoticz in this article.

Turning the lights on automatically

To turn the lights on automatically when motion is detected in the room we are going to start using an advanced function of Domoticz: Events. You can access this function from the menu, by going to Setup -> More Options -> Events.

The idea behind this feature is that you can tell Domoticz how to react to certain changes in the system (events). It can intercept the state changes of some sensors and it can change the states of other devices in response. It can also send email, SMS, etc to notify you about the changes. It’s a fairly versatile mechanism for defining what should happen in the system when certain events occur. The funky part of it is that you, as the user, can define the automation rules graphically! Yepp, that’s right. The event editor in Domoticz, called Blockly, is a visual programming interface which basically makes it possible to create simple functions of how devices should interact to each other’s state changes by using graphical blocks. To be more exact, Blockly is an open-source web-based visual programming editor made by Google. It’s amazingness lies in the fact that people who are not well versed in software development can still create simple programming rules. And that is what Domoticz events are all about!

Let’s take an example:

Simple kitchen light automation event

The rule in the image is as simple as it looks. It tells Domoticz that if the motion sensor in the kitchen is on (it detects movement) and the light intensity in the kitchen (measured by the light intensity sensor) is below 10 lux, then it should set the state of the kitchen lights to on. And it was all dragged together in just a few seconds using the Blockly visual programming editor. Note that you see 4 main puzzle-like blocks in the image:

  • Kitchen MS Motion is the name of the motion sensor Domoticz device
  • Kitchen MS Light is the name of the light intensity sensor Domoticz device
  • Kitchen Lights is the name of the kitchen lights device in Domoticz
  • 10 is a user constant which could have any value you like

And of course you could change the names of your Domoticz devices to anything you want, even if they are already participating in event rules. Just go to the devices and rename them in the Switches, Temperature, Weather or Utility main menus.

To create an event rule of your own in Domoticz, open up the visual editor (Setup -> More Options -> Events) and start dragging in the different pieces of the puzzle from the left side menu:

  • Control – conditions
  • Logic – value comparisons, complex conditions, setters, user constants
  • Time – time constants and comparisons
  • Messages – strings, URLs, emails, SMS messages
  • Security – related to the built in home alarm system of Domoticz
  • User variables – Domoticz user variables and constants
  • Debug/log – writing to the log of Domoticz
  • Devices – the list of your Domoticz devices (switches, sensors, lights, meters, etc.)

The pieces of the puzzle can be combined into ever more complex larger pieces and this way some really intricate automation rules can be defined.

When you’re done, give the event a name in the upper right corner of the page, check the “Event active” check box and Save it.

That’s it! If you set up everything right, your lights will now turn on automatically whenever the motion sensor detects movement.

Turning the lights off automatically

So now that your lights turn on automatically, it’s time to make them also turn off automatically and forget that you ever had to switch them on/off manually. This, however is more tricky then turning them on, because when motion is detected in the room it’s obvious that there is presence and the lights should be turned on, but the length of period of inactivity after which they can be turned off depends on your preference, on the type of the room, etc. For example you know that you move around a lot in the kitchen and that means that if there was no movement for 2 minutes, it’s safe to assume that the lights can be switched off. But you may be sitting or lying down in the living room frequently and there you may wish to turn them off only after 15 minutes of inactivity. This way if the lights turn off but you did not want that (you’re still in the room and still need the light), you can wave your hand to turn them back on and you only have to take this corrective action every 15 minutes, not every 2 minutes.

If you have a versatile motion sensor like the %20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20

%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20

%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20

%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20

The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20%C2%A0%20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
    %20
  1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
  2. %20
  3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
  4. %20
%20%20

Components

%20%20

So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

%20
    %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20

      The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

      %20
        %20
      1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
      2. %20
      3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
      4. %20
      %20%20

      Components

      %20%20

      So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

      %20
        %20
      1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
      2. %20
      3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
      4. %20
      5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
      6. %20
      %20

      Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

      %20%20

      The%20home%20automation%20server%20software

      %20%5BDomoticz%20pic%5D%20

      The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

      %20%C2%A0%20

      The%20home%20automation%20server%20hardware

      %20

      The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

      %20%20

      The%20motion%20sensor

      %20%5BFibaro%20motion%20sensor%20pic%5D%20

      The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

      %20

      To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

      %20%20

      The%20smart%20lights

      %20%20

      We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

      %20%20

      Turning%20the%20lights%20on%20automatically

      %20

      To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

      %20

      The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

      %20Let's%20take%20an%20example:%20%20

      The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

      %20
        %20
      • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
      • %20
      • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
      • %20
      %20

      And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

      %20

      To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

      %20
        %20
      • Control%20-%20conditions
      • %20
      • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
      • %20
      • Time%20-%20time%20constants%20and%20comparisons
      • %20
      • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
      • %20
      • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
      • %20
      • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
      • %20
      • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
      • %20
      • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
      • %20
      %20

      The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

      %20

      When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

      %20

      That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

      %20%20

      Turning%20the%20lights%20off%20automatically

      %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. %20

      The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

      %20
        %20
      1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
      2. %20
      3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
      4. %20
      %20%20

      Components

      %20%20

      So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

      %20
        %20
      1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
      2. %20
      3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
      4. %20
      5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
      6. %20
      %20

      Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

      %20%20

      The%20home%20automation%20server%20software

      %20%5BDomoticz%20pic%5D%20

      The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

      %20%C2%A0%20

      The%20home%20automation%20server%20hardware

      %20

      The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

      %20%20

      The%20motion%20sensor

      %20%5BFibaro%20motion%20sensor%20pic%5D%20

      The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

      %20

      To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

      %20%20

      The%20smart%20lights

      %20%20

      We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

      %20%20

      Turning%20the%20lights%20on%20automatically

      %20

      To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

      %20

      The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

      %20Let's%20take%20an%20example:%20%20

      The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

      %20
        %20
      • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
      • %20
      • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
      • %20
      %20

      And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

      %20

      To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

      %20
        %20
      • Control%20-%20conditions
      • %20
      • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
      • %20
      • Time%20-%20time%20constants%20and%20comparisons
      • %20
      • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
      • %20
      • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
      • %20
      • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
      • %20
      • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
      • %20
      • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
      • %20
      %20

      The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

      %20

      When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

      %20

      That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

      %20%20

      Turning%20the%20lights%20off%20automatically

      %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
  1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
  2. %20
  3. %20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20

    The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

    %20
      %20
    1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
    2. %20
    3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
    4. %20
    %20%20

    Components

    %20%20

    So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

    %20
      %20

      The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

      %20
        %20
      1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
      2. %20
      3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
      4. %20
      %20%20

      Components

      %20%20

      So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

      %20
        %20
      1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
      2. %20
      3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
      4. %20
      5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
      6. %20
      %20

      Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

      %20%20

      The%20home%20automation%20server%20software

      %20%5BDomoticz%20pic%5D%20

      The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

      %20%C2%A0%20

      The%20home%20automation%20server%20hardware

      %20

      The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

      %20%20

      The%20motion%20sensor

      %20%5BFibaro%20motion%20sensor%20pic%5D%20

      The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

      %20

      To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

      %20%20

      The%20smart%20lights

      %20%20

      We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

      %20%20

      Turning%20the%20lights%20on%20automatically

      %20

      To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

      %20

      The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

      %20Let's%20take%20an%20example:%20%20

      The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

      %20
        %20
      • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
      • %20
      • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
      • %20
      %20

      And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

      %20

      To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

      %20
        %20
      • Control%20-%20conditions
      • %20
      • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
      • %20
      • Time%20-%20time%20constants%20and%20comparisons
      • %20
      • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
      • %20
      • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
      • %20
      • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
      • %20
      • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
      • %20
      • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
      • %20
      %20

      The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

      %20

      When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

      %20

      That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

      %20%20

      Turning%20the%20lights%20off%20automatically

      %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">%20
    1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
    2. %20
    3. %20

      The%20usual%20way%20of%20operating%20the%20lights%20in%20your%20home%20today%20is%20that%20when%20you%20step%20into%20a%20room%20you%20turn%20the%20lights%20on%20by%20pressing%20a%20switch%20(usually%20a%20wall%20switch)%20and%20you%20turn%20them%20off%20when%20you%20leave%20the%20room%20by%20pressing%20the%20switch%20again.%20But%20wouldn't%20it%20be%20awesome%20if%20all%20this%20happened%20automagically,%20without%20the%20need%20to%20go%20to%20the%20switch%20and%20press%20it?%20Well,%20it%20can%20be%20done%20if%20you%20have%20some%20lights%20which%20are%20capable%20of%20being%20automated.%20But%20even%20if%20you%20have%20such%20lights,%20how%20can%20you%20automate%20them%20exactly%20and%20how%20can%20it%20be%20decided%20when%20to%20turn%20them%20on%20or%20off?%20There%20are%20many%20approaches%20to%20this%20problem.%20The%20one%20that%20we'll%20discuss%20here%20is%20using%20a%20motion%20sensor%20to%20detect%20presence%20in%20the%20room%20and%20to%20switch%20the%20lights%20based%20on%20the%20presence.%20Detecting%20presence%20is%20a%20complex%20topic%20in%20its%20own%20because%20even%20if%20you're%20not%20moving,%20you%20can%20still%20be%20in%20the%20room%20(maybe%20sleeping%20or%20sitting%20inactive).%20Also%20it's%20not%20easy%20distinguishing%20between%20human%20and%20animal%20presence%20and%20large%20moving%20objects%20(curtains%20blown%20by%20the%20wind,%20moving%20pendulums,%20etc.)%20can%20also%20be%20a%20problem.%20But%20in%20the%20first%20step%20we're%20going%20to%20take%20the%20easy%20approach%20and%20assume%20that%20there%20are%20no%20complications.%20In%20this%20context%20we%20only%20need%20to%20worry%20about%20two%20things:

      %20
        %20
      1. Turning%20on%20the%20lights%20when%20movement%20is%20detected
      2. %20
      3. Turning%20off%20the%20lights%20if%20no%20movement%20is%20sensed%20for%20a%20while
      4. %20
      %20%20

      Components

      %20%20

      So%20let's%20see%20what%20we%20need%20exactly%20in%20order%20to%20achieve%20the%20above%20goal:%20turning%20the%20lights%20on%20or%20off%20based%20on%20motion%20in%20the%20room.

      %20
        %20
      1. First%20of%20all%20we%20obviously%20need%20some%20kind%20of%20smart%20lights%20or%20smart%20light%20bulb%20sockets,%20which%20can%20be%20operated%20remotely%20by%20some%20signal.
      2. %20
      3. The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
      4. %20
      5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
      6. %20
      %20

      Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

      %20%20

      The%20home%20automation%20server%20software

      %20%5BDomoticz%20pic%5D%20

      The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

      %20%C2%A0%20

      The%20home%20automation%20server%20hardware

      %20

      The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

      %20%20

      The%20motion%20sensor

      %20%5BFibaro%20motion%20sensor%20pic%5D%20

      The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

      %20

      To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

      %20%20

      The%20smart%20lights

      %20%20

      We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

      %20%20

      Turning%20the%20lights%20on%20automatically

      %20

      To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

      %20

      The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

      %20Let's%20take%20an%20example:%20%20

      The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

      %20
        %20
      • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
      • %20
      • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
      • %20
      • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
      • %20
      %20

      And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

      %20

      To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

      %20
        %20
      • Control%20-%20conditions
      • %20
      • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
      • %20
      • Time%20-%20time%20constants%20and%20comparisons
      • %20
      • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
      • %20
      • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
      • %20
      • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
      • %20
      • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
      • %20
      • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
      • %20
      %20

      The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

      %20

      When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

      %20

      That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

      %20%20

      Turning%20the%20lights%20off%20automatically

      %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
    4. %20
    5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
    6. %20
    %20

    Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

    %20%20

    The%20home%20automation%20server%20software

    %20%5BDomoticz%20pic%5D%20

    The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

    %20%C2%A0%20

    The%20home%20automation%20server%20hardware

    %20

    The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

    %20%20

    The%20motion%20sensor

    %20%5BFibaro%20motion%20sensor%20pic%5D%20

    The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

    %20

    To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

    %20%20

    The%20smart%20lights

    %20%20

    We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

    %20%20

    Turning%20the%20lights%20on%20automatically

    %20

    To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

    %20

    The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

    %20Let's%20take%20an%20example:%20%20

    The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

    %20
      %20
    • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
    • %20
    • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
    • %20
    • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
    • %20
    %20

    And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

    %20

    To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

    %20
      %20
    • Control%20-%20conditions
    • %20
    • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
    • %20
    • Time%20-%20time%20constants%20and%20comparisons
    • %20
    • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
    • %20
    • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
    • %20
    • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
    • %20
    • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
    • %20
    • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
    • %20
    %20

    The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

    %20

    When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

    %20

    That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

    %20%20

    Turning%20the%20lights%20off%20automatically

    %20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1">The%20second%20thing%20that%20we%20need%20is%20a%20motion%20sensor,%20which%20sends%20a%20signal%20when%20motion%20is%20detected%20and%20stops%20the%20signal%20when%20the%20motion%20stops.
  4. %20
  5. Finally%20we%20need%20some%20kind%20of%20home%20automation%20server%20which%20is%20running%20all%20the%20time%20and%20processing%20events,%20making%20sure%20that%20when%20the%20motion%20appears%20or%20disappears,%20the%20light%20is%20switched%20accordingly.%20Note%20that%20this%20component%20is%20not%20absolutely%20necessary%20in%20the%20case%20when%20the%20motion%20sensor%20can%20communicate%20with%20the%20lights%20directly.%20The%20usual%20case,%20however,%20is%20that%20they%20can't%20interact%20directly%20and%20that%20a%20home%20automation%20server%20needs%20to%20mediate%20between%20them.
  6. %20
%20

Let%20us%20examine%20each%20component%20in%20detail.%20For%20the%20sake%20of%20easier%20understanding%20we'll%20start%20with%20the%20home%20automation%20server%20and%20continue%20with%20the%20smart%20lights%20and%20the%20motion%20sensor.

%20%20

The%20home%20automation%20server%20software

%20%5BDomoticz%20pic%5D%20

The%20home%20automation%20server%20software%20that%20we%20will%20be%20using%20for%20this%20project%20is%20the%20free%20and%20absolutely%20marvelous%20Domoticz%20software.%20To%20discover%20how%20to%20set%20it%20up%20and%20configure%20it%20on%20a%20Raspberry%20Pi,%20read%20this%20article.

%20 %20

The%20home%20automation%20server%20hardware

%20

The%20home%20automation%20server%20that%20we're%20going%20to%20discuss%20here%20will%20be%20a%20Z-Wave%20server.%20To%20learn%20about%20Z-Wave%20and%20find%20out%20how%20to%20put%20together%20a%20nice%20and%20cost%20effective%20Z-Wave%20server%20based%20on%20the%20Raspberry%20Pi,%20read%20the%20article%20about%20this%20article.

%20%20

The%20motion%20sensor

%20%5BFibaro%20motion%20sensor%20pic%5D%20

The%20motion%20sensor%20used%20for%20this%20project%20will%20be%20the%20Fibaro%20motion%20sensor.%20One%20of%20the%20most%20important%20features%20that%20make%20it%20a%20good%20choice%20for%20automating%20the%20lights%20in%20a%20room%20is%20that%20it%20contains%20a%20built%20in%20light%20sensor%20too%20(along%20with%20the%20motion%20sensor,%20a%20temperature%20sensor%20and%20an%20acceleration%20sensor).%20Since%20we%20don't%20want%20to%20mess%20with%20our%20lights%20(trying%20to%20turn%20them%20on%20or%20off)%20during%20day%20time,%20when%20there's%20enough%20natural%20light%20in%20the%20target%20location,%20it's%20important%20to%20be%20able%20to%20measure%20the%20level%20of%20light%20intensity.%20It%20is%20also%20convenient%20because%20it%20helps%20us%20avoid%20trying%20to%20turn%20the%20light%20on%20after%20it%20has%20already%20been%20turned%20on%20or%20off%20after%20it's%20already%20switched%20off.%20Obviously,%20we%20could%20use%20a%20regular%20motion%20sensor%20and%20a%20separate%20light%20sensor%20instead,%20but%20filling%20the%20room%20with%20sensors%20might%20look%20ugly.%20The%20Fibaro%20motion%20sensor,%20on%20the%20other%20hand,%20is%20very%20discrete%20and%20quite%20beautiful%20in%20its%20own%20way.%20Another%20important%20capability%20of%20the%20Fibaro%20motion%20sensor%20which%20makes%20it%20a%20good%20choice%20for%20this%20project%20is%20being%20able%20to%20change%20the%20length%20of%20the%20time%20period%20for%20which%20it%20keeps%20reporting%20its%20state%20as%20%22on%22%20after%20motion%20is%20detected.%20This%20is%20also%20useful,%20by%20the%20way,%20if%20you%20wish%20to%20use%20it%20in%20a%20home%20alarm%20system%20because%20this%20time%20frame%20can%20be%20used%20to%20define%20the%20duration%20of%20the%20alarm.

%20

To%20find%20out%20more%20about%20this%20device,%20read%20%5Bthis%20article%5D.

%20%20

The%20smart%20lights

%20%20

We%20could%20use%20any%20kind%20of%20smart%20light%20bulbs%20in%20order%20to%20turn%20them%20on/off%20automatically,%20or%20even%20regular%20bulbs%20with%20smart%20sockets,%20but%20in%20this%20example%20we%20will%20be%20using%20the%20Milight/LimitlessLED/EasyBulb%20smart%20LED%20lights%20that%20we%20have%20examined%20in%20the%20past%20in%20this%20article.

%20%20

Turning%20the%20lights%20on%20automatically

%20

To%20turn%20the%20lights%20on%20automatically%20when%20motion%20is%20detected%20in%20the%20room%20we%20are%20going%20to%20start%20using%20an%20advanced%20function%20of%20Domoticz:%20Events.%20You%20can%20access%20this%20function%20from%20the%20menu,%20by%20going%20to%20Setup%20->%20More%20Options%20->%20Events.

%20

The%20idea%20behind%20this%20feature%20is%20that%20you%20can%20tell%20Domoticz%20how%20to%20react%20to%20certain%20changes%20in%20the%20system%20(events).%20It%20can%20intercept%20the%20state%20changes%20of%20some%20sensors%20and%20it%20can%20change%20the%20states%20of%20other%20devices%20in%20response.%20It%20can%20also%20send%20email,%20SMS,%20etc.%20It's%20a%20fairly%20versatile%20mechanism%20for%20defining%20what%20should%20happen%20in%20the%20system%20when%20certain%20events%20occur.%20The%20funky%20part%20of%20it%20is%20that%20you,%20as%20the%20user,%20can%20define%20the%20automation%20rules%20graphically!%20Yepp,%20that's%20right.%20The%20event%20editor%20in%20Domoticz,%20called%20Blockly,%20is%20a%20visual%20programming%20interface%20which%20basically%20makes%20it%20possible%20to%20create%20simple%20functions%20of%20how%20devices%20should%20interact%20to%20each%20other's%20state%20changes%20by%20using%20graphical%20blocks.%20To%20be%20more%20exact,%20Blockly%20is%20an%20open-source%20web-based%20visual%20programming%20editor%20made%20by%20Google.%20It's%20amazingness%20lies%20in%20the%20fact%20that%20people%20who%20are%20not%20well%20versed%20in%20software%20development%20can%20still%20create%20simple%20programming%20rules.%20And%20that%20is%20what%20Domoticz%20events%20are%20all%20about!

%20Let's%20take%20an%20example:%20%20

The%20rule%20in%20the%20image%20is%20as%20simple%20as%20it%20looks.%20It%20tells%20Domoticz%20that%20if%20the%20motion%20sensor%20in%20the%20kitchen%20is%20on%20(it%20detects%20movement)%20and%20the%20light%20intensity%20in%20the%20kitchen%20(measured%20by%20the%20light%20intensity%20sensor)%20is%20below%2010%20lux,%20then%20it%20should%20set%20the%20state%20of%20the%20kitchen%20lights%20to%20on.%20And%20it%20was%20all%20dragged%20together%20in%20just%20a%20few%20seconds%20using%20the%20Blockly%20visual%20programming%20editor.%20Note%20that%20you%20see%204%20main%20puzzle-like%20blocks%20in%20the%20image:

%20
    %20
  • Kitchen%20MS%20Motion%20is%20the%20name%20of%20the%20motion%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20MS%20Light%20is%20the%20name%20of%20the%20light%20intensity%20sensor%20Domoticz%20device
  • %20
  • Kitchen%20Lights%20is%20the%20name%20of%20the%20kitchen%20lights%20device%20in%20Domoticz
  • %20
  • 10%20is%20a%20user%20constant%20which%20could%20have%20any%20value%20you%20like
  • %20
%20

And%20of%20course%20you%20could%20change%20the%20names%20of%20your%20Domoticz%20devices%20to%20anything%20you%20want,%20even%20if%20they%20are%20already%20participating%20in%20event%20rules.%20Just%20go%20to%20the%20devices%20and%20rename%20them%20in%20the%20Switches,%20Temperature,%20Weather%20or%20Utility%20main%20menus.

%20

To%20create%20an%20event%20rule%20of%20your%20own%20in%20Domoticz,%20open%20up%20the%20visual%20editor%20(Setup%20->%20More%20Options%20->%20Events)%20and%20start%20dragging%20in%20the%20pieces%20of%20the%20puzzle%20from%20the%20left%20side%20menu:

%20
    %20
  • Control%20-%20conditions
  • %20
  • Logic%20-%20value%20comparisons,%20complex%20conditions,%20setters,%20user%20constants
  • %20
  • Time%20-%20time%20constants%20and%20comparisons
  • %20
  • Messages%20-%20strings,%20URLs,%20emails,%20SMS%20messages
  • %20
  • Security%20-%20related%20to%20the%20built%20in%20home%20alarm%20system%20of%20Domoticz
  • %20
  • User%20variables%20-%20Domoticz%20user%20variables%20and%20constants
  • %20
  • Debug/log%20-%20Writing%20to%20the%20log%20of%20Domoticz
  • %20
  • Devices%20-%20The%20list%20of%20your%20Domoticz%20devices%20(switches,%20sensors,%20lights,%20meters,%20etc.)
  • %20
%20

The%20pieces%20of%20the%20puzzle%20can%20be%20combined%20into%20ever%20more%20complex%20larger%20pieces%20and%20this%20way%20some%20really%20intricate%20automation%20rules%20can%20be%20made.

%20

When%20you're%20done,%20give%20the%20event%20a%20name%20in%20the%20upper%20right%20corner%20of%20the%20page,%20check%20the%20%22Event%20active%22%20check%20box%20and%20Save%20it.

%20

That's%20it!%20If%20you%20set%20up%20everything%20right,%20your%20lights%20will%20now%20turn%20on%20automatically%20whenever%20the%20motion%20sensor%20detects%20movement.

%20%20

Turning%20the%20lights%20off%20automatically

%20So%20now%20Word%20count:%201377%20Saving%20Draft%E2%80%A6%20Last%20edited%20by%20iqjar%20on%20January%2014,%202016%20at%2019:47%20Toggle%20panel:%20Publish%20Publish%20Save%20Draft%20Preview%20Status:%20Draft%20Edit%20Edit%20status%20Visibility:%20Public%20Edit%20Edit%20visibility%20Revisions:%2010%20Browse%20Browse%20revisions%20Publish%20immediately%20Edit%20Edit%20date%20and%20time%20Move%20to%20TrashPublish%20Toggle%20panel:%20Format%20Format%20Post%20Formats%20Standard%20Aside%20Audio%20Chat%20Gallery%20Image%20Link%20Quote%20Status%20Video%20Toggle%20panel:%20Categories%20Categories%20All%20Categories%20Most%20Used%20Article%20Domoticz%20Home%20automation%20How%20to%20Project%20Raspberry%20Pi%20Tutorial%20Arduino%20DIY%20General%20Hardware%20LED%20Cube%20Micro%20computers%20Microcontrollers%20Software%20Uncategorized%20+%20Add%20New%20Category%20Toggle%20panel:%20Tags%20Tags%20Add%20New%20Tag%20Add%20Separate%20tags%20with%20commas%20X%20advancedX%20articleX%20automaticX%20automaticallyX%20automationX%20BlocklyX%20bulbX%20cheapX%20configureX%20cost%20effectiveX%20detectX%20detectionX%20DomoticzX%20EasyBulbX%20eventsX%20FibaroX%20guideX%20home%20automationX%20how%20toX%20LEDX%20lightX%20light%20sensorX%20lightsX%20LimitlessLEDX%20luaX%20MiLightX%20motion%20sensorX%20movementX%20open%20sourceX%20presenceX%20Raspberry%20PiX%20RazberryX%20rulesX%20scriptX%20sensorX%20serverX%20set%20upX%20smart%20homeX%20smart%20houseX%20softwareX%20tamperingX%20tutorialX%20visual%20programmingX%20WiFiX%20wirelessX%20Z-Wave%20Choose%20from%20the%20most%20used%20tags%20Toggle%20panel:%20Disable%20sociable%20Disable%20sociable%20Check%20This%20To%20Disable%20Sociable%202%20On%20This%20Post%20Only.%20Toggle%20panel:%20Featured%20Image%20Featured%20Image%20Set%20featured%20image%20Featured%20Images%20at%20least%20as%20wide%20as%20default%20header%20image%20will%20be%20used%20as%20a%20replacement%20for%20default%20image%20for%20this%20page%20or%20post.%20Smaller%20images%20used%20as%20%22thumbnail%22%20at%20beginning%20of%20Page/Post.%20Toggle%20panel:%20Weaver%20II%20Options%20For%20This%20Post%20Weaver%20II%20Options%20For%20This%20Post%20Per%20Post%20OptionsClick%20for%20help(This%20Post's%20ID:%20962)%20These%20settings%20let%20you%20control%20display%20of%20this%20individual%20post.%20Many%20of%20these%20options%20override%20global%20options%20set%20on%20the%20Weaver%20II%20admin%20tabs.%20Display%20as%20full%20post%20where%20normally%20excerpted.%20Display%20post%20as%20excerpt%20Show%20Featured%20Image%20with%20post%20Show%20author%20avatar%20with%20post%20Mark%20as%20a%20favorite%20post%20(adds%20star%20to%20title)%20Hide%20Post%20Format%20label%20Hide%20post%20title%20Show%20link%20to%20single%20page%20icon%20at%20bottom%20of%20post%20Hide%20top%20post%20info%20line%20Hide%20bottom%20post%20info%20line%20Hide%20the%20comment%20bubble%20Hide%20Sidebars%20when%20this%20post%20displayed%20on%20Single%20Post%20page.%20For%20Masonry%20multi-columns:%20make%20this%20post%20span%20two%20columns.%20(%E2%97%8FPro%20only)%20Disable%20Visual%20Editor%20for%20this%20page.%20Useful%20if%20you%20enter%20simple%20HTML%20or%20other%20code.%20Allow%20Raw%20HTML%20and%20scripts.%20Disables%20auto%20paragraph,%20texturize,%20and%20other%20processing.%20The%20above%20settings%20are%20not%20used%20by%20the%20%5Bweaver_show_posts%5D%20shortcode.%20Per%20Post%20StyleClick%20for%20help%20Enter%20optional%20per%20post%20CSS%20style%20rules.%20Do%20not%20include%20the%20%20tags.%20Include%20the%20%7B%7D's.%20Don't%20use%20class%20names%20if%20rules%20apply%20to%20whole%20post,%20but%20do%20include%20class%20names%20(e.g.,%20.entry-title%20a)%20for%20specific%20elements.%20Custom%20styles%20will%20not%20be%20displayed%20by%20the%20Post%20Editor.%20Define%20a%20Custom%20Field%20called%20postclass%20to%20add%20a%20custom%20class%20name%20to%20the%20%20section%20that%20wraps%20this%20post.%20Post%20FormatClick%20for%20help%20Weaver%20II%20supports%20Post%20Formats%20as%20shown%20in%20the%20%22Format%22%20option%20box%20to%20the%20right.%20Click%20the%20?%20for%20more%20info.%20Note:%20when%20you%20add%20settings%20for%20the%20post%20here,%20values%20will%20be%20created%20and%20displayed%20in%20the%20%22Custom%20Fields%22%20box.%20Toggle%20panel:%20Custom%20Fields%20Custom%20Fields%20Add%20New%20Custom%20Field:%20Name%20Value%20Add%20Custom%20Field%20Custom%20fields%20can%20be%20used%20to%20add%20extra%20metadata%20to%20a%20post%20that%20you%20can%20use%20in%20your%20theme.%20Toggle%20panel:%20Discussion%20Discussion%20Allow%20comments.%20Allow%20trackbacks%20and%20pingbacks%20on%20this%20page.%20Toggle%20panel:%20Subscribe2%20Notification%20Override%20Subscribe2%20Notification%20Override%20Check%20here%20to%20disable%20sending%20of%20an%20email%20notification%20for%20this%20post/page%20Thank%20you%20for%20creating%20with%20WordPress.%20Version%204.4.1" target="_blank">Fibaro motion sensor, for which you can change the duration of the time frame for which it reports its state as “on” after it senses motion, you’re lucky. In this case you can simply configure the duration in the sensor settings and add one more Domoticz event rule, which does the opposite of the one we have examined earlier: it turns the lights off when the sensor reports an “off” state (regardless of the light intensity levels). For this specific sensor you can configure the motion alarm duration parameter like this:
  1. Go to Setup->Hardware in Domoticz
  2. Select the Razberry Z-Wave controller from the hardware list and click Setup next to it.
  3. Now select the Fibaro motion sensor in the device list, find the parameter named “Motion alarm cancellation delay” and change it to the desired value.
  4. Finally click “Apply configuration for this device” at the bottom of the page.

If you want to set a value which the sensor will not accept or if you have a less configurable sensor, then it’s time to take out the big guns and start using one of the most advanced home automation features of Domoticz: lua scripts.

Writing a script in the lua programming language is considerably harder than creating a graphical event using Blockly, but no reason to start getting scared, it’s not extremely complex either. However you do need some minimum programming skills and Linux command line knowledge, because the first thing that needs to be done is to create a new text file for the script in the correct sub-directory of the Domoticz installation folder. So find the folder where you have installed Domoticz (for example: /home/pi/domoticz) and enter the scripts/lua sub-directory. Here you need to create a new text file with the appropriate name. By appropriate I mean that the file name of the lua scripts executed by Domoticz determines when and how they are executed. In our case the intent is to create a script which is executed once every minute and checks the state of the motion sensor. This is needed because the script will count the minutes elapsed since there was no movement and it will turn off the lights when enough minutes have passed. The file name of such a script must have 3 components separated by underscore:

  1. script (fixed!)
  2. time (fixed!)
  3. any name you like

So the file name must look something like this: script_time_TurnOffKitchenLightsIfNoMotion.lua

Let’s go ahead and create (or open) this script:

nano script_time_TurnOffKitchenLightsIfNoMotion.lua

Now let’s see an example of such a script and try to understand how it works:

-- script_time_TurnOffKitchenLightsIfNoMotion.lua

local deviceName_MotionSensor = 'Kitchen MS Motion'
local deviceName_Lights = 'Kitchen Lights'
local userVariableName_NoMotionCounter = 'KitchenNoMotionCounter'
local userVariableName_NoMotionMaxMinutes = 'KitchenNoMotionMinutesMax'

commandArray = {}

currentMinutesWithoutMotion = tonumber(uservariables[userVariableName_NoMotionCounter])
maxMinutesWithoutMotion = tonumber(uservariables[userVariableName_NoMotionMaxMinutes])

if (otherdevices[deviceName_MotionSensor] == 'Off') then
 currentMinutesWithoutMotion = currentMinutesWithoutMotion + 1
else
 currentMinutesWithoutMotion = 0
end

commandArray['Variable:' .. userVariableName_NoMotionCounter] = tostring(currentMinutesWithoutMotion)

if (currentMinutesWithoutMotion >= maxMinutesWithoutMotion) then
 print('<font color="blue">Turning OFF ..deviceName_Lights.. due to no motion.</font>')
 commandArray[deviceName_Lights]='Off'
end

return commandArray

At the beginning of the script we need to specify the name of two Domoticz devices: the name of the motion sensor device and that of the lights device. There are two additional names that we must customize, two user variable names. These are the names of the two Domoticz user variables that we will set up a bit later (see below). The first one (userVariable_NoMotionCounter) is a temporary variable which is used by the script to count the elapsed minutes since there was no motion sensed and the second one (userVariable_NoMotionMaxMinutes) is a user defined constant which tells the script how many minutes must elapse before the lights are turned off. Basically this second variable is how you define the length of the period after which it turns off the lights.

The rest of the script only needs to be changed if you want to do some very heavy customization to how it works, but if you’re set out to do that, then there’s no need to explain to you how it works, because you already understand 😉

The final step to making the bulbs switch off automatically is to create the two user variables that the lua script needs. Go to Setup->More Options->User Variables in Domoticz and add two variables:

  • name = userVariable_NoMotionCounter, type = Integer, value = 0
  • name = userVariable_NoMotionMaxMinutes, type = Integer, value = 2

Note that for the second variable you should add your own desired value instead of 2. This will control the duration (in minutes) of the time frame after which the lights turn off.

Domoticz - Adding user variables

If everything was set up correctly, your lights should now automatically turn off after the specified amount of minutes of no movement. If it does not work, go to Setup->Log in Domoticz and try to find out what is happening. You may add debug messages to the lua script using the print statement. You can find an example of this in the script itself.

Final word

The methods discussed above to turn on and off the lights automatically are likely to be suitable for many needs. However there may be situations where you would not want this kind of automation. For example it would not be a good thing if the lights turned on by themselves in your bedroom whenever you made a small movement in the bed at night. Also, you might not like the lights to turn off too often in a room where you stay a lot but make little movement. Otherwise, it should be fun to play with this. Enjoy!

  • Let there be light! …when there’s motion
Let there be light! …when there’s motion

Back to Featured Articles on Logo Paperblog