Line 60: Line 60:
</pre>
</pre>
=== Proximity @ Entryway ===
=== Proximity @ Entryway ===
Triggers a light on motion and then deactivates after 3 minutes.
<pre>
<pre>
var Timer timer = null
var Timer timer = null

Revision as of 00:02, 3 January 2019

Install Openhab

Just do it..

Allow Openhab to access Serial Devices by Adding 'openhab' to the Dialout Group

sudo vi /etc/group
dialout:x:20:openhab


Install Z Wave Bindings

PaperUI > Add Ons > Bindings > Z-wave Binding > install

Once the Binding is installed, add the Z-wave binding as a Thing and verify that the serial port is correct. If the serial port is missing or will not be accepted, make sure you added openhab to the dialup group in the previous step.

Add Items

  • Within PaperUI, Things should begin showing up in the Inbox.
  • Add each thing using the naming convention : Location_Type_Target (ie. LivingRoom_Dimmer_AccentLights)
  • Click each thing and add the appropriate items for each channel

Rules

Accent Lighting Control

// turn accent lights on at dusk
rule "Accent Lights on @ Sunset"
when
    Channel 'astro:sun:local:astroDusk#event' triggered START
then
    logInfo("accent.rules", "Turning Lights On @ Sunset")
    Group_AccentLighting.sendCommand(ON)
end

rule "Accent Lights Off @ 10"
when   
    Time cron "0 0 22 ? * *"
then
    logInfo("accent.rules", "Turning Lights Off @ 10")
    Group_AccentLighting.sendCommand(OFF)
end

// turn accent lights on at dusk
rule "Accent Lights on @ Sunset"
when
    Channel 'astro:sun:local:nauticDawn#event' triggered START
then
    logInfo("accent.rules", "Turning Lights On @ Early Morning")
    Group_AccentLighting.sendCommand(ON)
end

// turn accent lights on at dusk
rule "Accent Lights on @ Sunset"
when
    Channel 'astro:sun:local:daylight#event' triggered START
then
    logInfo("accent.rules", "Turning Lights Off @ Daylight")
    Group_AccentLighting.sendCommand(OFF)
end

Proximity @ Entryway

Triggers a light on motion and then deactivates after 3 minutes.

var Timer timer = null

rule "Handle PIR Events"
when
    Item Entry_Proximity_BinarySensor received update
then
    if (Entry_Proximity_BinarySensor.state == ON) 
    {
        if ( timer !== null )
        {
            timer.cancel
            timer = null;
        }

        Entry_Switch_EntryLights.sendCommand(ON)

        logInfo("entry.rules", "Starting a timer for 3 minutes")
        timer = createTimer( now.plusMinutes(3), [
            logInfo("entry.rules", "Turnign entry proxmity off")
            Entry_Switch_EntryLights.sendCommand(OFF)
            Entry_Proximity_BinarySensor.sendCommand(OFF)
            timer = null
        ])
    }
end