OH3, HomeKit, and OmniLink - Security Control/status

Good evening, all.

Running OH3 on OpenHabian, and it seems that HomeKit functionality has grown quite a bit since OH2, but I still have a hard time understanding some of the concepts around the channels, things, items, etc and their linkage into HomeKit. I’ve been able to fumble my way through lighting and contact sensors, which has worked for my purposes, and I basically created some Omni automation rules to create the “integration” between OH (if this flag is on, system arms for Away, etc). A poor way to do it, as there’s no code validation, but it was a work-around.

My question is, now with OmniLink 3 and HomeKit 3 inside of OH3, has someone been able to set up control of the Omni-series hardware from within HomeKit?

To be able to read and change security status is a major item for me, but in an ideal world, HomeKit would prompt me for a code. In an even more ideal world, if the alarm is armed and a zone opens (triggering the entry delay), is it possible to have HomeKit pop up a keypad wanting the alarm code to be entered for disarming. That’s the holy grail, but to at least be able to see status and change status in the actual HomeKit security framework would make me just as happy.

Has anyone done this, and if so, willing to share sort of a step-by-step on how to achieve said integration?

Thanks!!!

Hallo Kristian,

currently homekit binding supports only

  • see and change status of security system (OFF, AWAY, HOME, NIGHT)
  • trigger alarm, which pops in home app

the code is not supported and i have not seen it in apple homekit specification. so, we need first apple to add support for it in home app and then we can add to homekit binding.

That added piece with a user-enterable code was more wishful thinking, but not the key to what I’m looking to do (especially if it’s just not supported yet). I’d love to just incorporate the supported “set mode” components (Off, Away, Home, & Night) and the alarm trigger, but don’t know how because I suspect I need to tell it some sort of translation from a status code to status word Homekit would understand (just a guess).

I use the security system meta data for HomeKit, too.

You can map the modes to your needs.
Use a string item with the SecuritySystem.CurrentSecuritySystemState and SecuritySystem.TargetSecuritySystemState .

Within the code you can map the HomeKit status to your own security system status to „synchronize“ it.

Should look like this:


value: SecuritySystem.CurrentSecuritySystemState,SecuritySystem.TargetSecuritySystemState
config:
  STAY_ARM: Your_Status1
  NIGHT_ARM: Your_Status2

An idea for your code to disarm… you can do it with an iOS device and Shortcuts. You should be able to send the disarm code as a sting value to openhab.

Edit:
Would look something like this:

OH, DOOD! You may have just made my week. I used to have like 6 flags mapped for status and 6 flags mapped for sending control. it was nasty.

OK so if I’m understanding what you have here. I’ve imported an HAI Area (1 - Main House). That area, I’ve created several channels:
Security Mode:
Security Command: Away
Security Command: Disarm
Security Command: Night
Area Alarm: Burglary

Unfortunately they’re all showing as “NULL”

The Metadata for that area is what you show above (though I added DISARMED as well). I’m trying to find a document that references what the Omni would expect to send for those statuses, and what it would expect to see for sending. The fact the Security Mode is listed as a number, suggests the Omni will be sending a single-digit for the status (0=OFF, 1=AWAY, 2=NIGHT, etc).

Sadly, they’re all show

I don’t use an Omnilink, so I can’t investigate how to exactly link your channels to the HomeKit binding.

Have you read this thread? Maybe there are some helpful information:

Thanks, I’ll check that out. Right now I was trying to find Leviton/HAI’s OmniLink/ProLink protocol doc on the inter-webs, as that should have the command structure and syntax (in theory).

I actually have not tried this with Homekit, but it should work exactly the same way as i have it setup with Alexa, but i’ll try it out tomorrow just to be sure. Below is a snip-it of my omnilink configuration (minus a whole bunch of zones and other items). The trick is to use a virtual item, so an item that is not bound to any channel and is only there to talk to Homekit, and is controlled via a openHAB rule, which i have also pasted here. In your case the AlexaAlarmMode would map the Homekit values to the omnilink number values used in the rules. More can be found on the binding documentation page HAI by Leviton OmniLink - Bindings | openHAB

omnilink.items

Number    AlarmMode     "Alarm [%s]"    {channel="omnilink:area:omni:1:mode"}

Group:Contact:OR(OPEN, CLOSED)    Zones     "All Zones [%s]"

//one of many contacts in the Zones group.......
Contact   ZoneGarageRollup  "Garage Rollup [%s]"    (Zones)    {channel="omnilink:zone:omni:4:contact"}

//virtual item controlled by rules and exposed to Alexa, homekit, etc....
Number    AlexaAlarmMode    "Alarm Mode"     (AlexaSecuritySystem) 
   {alexa="SecurityPanelController.armState" [DISARMED=0, ARMED_STAY=1, ARMED_AWAY=3, ARMED_NIGHT=2, NOT_READY=4, exitDelay=60]}

String     AlarmModeDisarm {channel="omnilink:area:omni:1:disarm"}
String     AlarmModeDay      {channel="omnilink:area:omni:1:day"}
String     AlarmModeNight     {channel="omnilink:area:omni:1:night"}
String     AlarmModeAway    {channel="omnilink:area:omni:1:away"}
String     AlarmModeVacation  {channel="omnilink:area:omni:1:vacation"}
String     AlarmModeDayInstant  {channel="omnilink:area:omni:1:day_instant"}
String     AlarmModeNightDelayed {channel="omnilink:area:omni:1:night_delayed"}

omnilink.rules

rule "AlexaAlarmModeProxy"
when Item AlexaAlarmMode received command
then
    logInfo("Alarm", "received cmd " + receivedCommand)

    if(Zones.state === OPEN) {
        logInfo("Alarm", "A zone is open, not arming")
        return
    }
    var alarmItem = ""
    switch(receivedCommand) {
        case 0: {
            logInfo("Alarm", "received DISARMED")
            alarmItem = "AlarmModeDisarm"
        }
        case 1: {
            logInfo("Alarm", "received ARMED_STAY")
            alarmItem = "AlarmModeDay"
        }
        case 2: {
            logInfo("Alarm", "received ARMED_NIGHT")
             alarmItem = "AlarmModeNight"
        }
        case 3: {
            logInfo("Alarm", "received ARMED_AWAY")
             alarmItem = "AlarmModeAway"
        }
        case 4: {
            logInfo("Alarm", "received NOT_READY")
        }
    }
    logInfo("Alarm", "AlexaAlarmMode before: " + AlexaAlarmMode.state)
    sendCommand(alarmItem, "1234")
end


/*
0=Off
1=Day
2=Night
3=Away
4=Vacation
5=Day instant
6=Night delayed
9=Arming day
10=Arming night
11=Arming away
12=Arming vacation
13=Arming day instant
14=Arming night delayed
*/
rule "AlarmMode to AlexaAlarmMode"
when Item AlarmMode received update 
then
    var value = (AlarmMode.state as Number)
    switch(AlarmMode.state){
        case 5: {
            value = 1
        }
        case 6: {
            value = 2
        }
        case 9: {
            value = 1
        }
        case 10: {
            value = 2
        }
        case 11: {
            value = 3
        }
        case 14: {
            value = 2
        }
    }
    AlexaAlarmMode.postUpdate(value)
end 

Oh my. This one’s over my head a bit, but thought I’d give it a shot anyway.

I went to create a new item, and based on what I’m seeing above, I set it’s Type to Number, but then I’m seeing a tie-in on your top line to the existing area status and that’s what threw me (because you had said to create this virtual item not bound to any channel).

I mean, I think I get what you’re saying - that because both status and setting the state are done in different commands on Omni, you need the virtual item to sort of bridge them together into a single Item, and that’s what then gets exposed to HomeKit.

So, assuming my interpretation of that was correct, I removed all the old linkages to the area’s status and commands and created this new virtual item (the “AlexaAlarmMode”) then linked it to the 7 SecurityCommand channels under that area.

I’m not sure where you’re looking to see the omnilink items in the raw text list (as I only use the GUI for my skill level).

For ease, I even kept the names of stuff how you had them, so the scripting didn’t need to be changed.

So, now the channel for Security Mode, I can actually see status words (Off, Away, Arming away, etc), but can’t seem to get the rule to mirror to the virtual item, nor am I sure where to then put the HomeKit linages (I’m assuming those would also go on the virtual item named “AlexaAlarmMode”).

I guess I’m just not quite getting it.
THING: Area (1): Main House (the Area I’m wanting to track/control security status for)
Channel: Security Mode
Item: Number-Point “AlexaAlarmMode”

Channel: SecurityCommand (all of them)
Item: Number-Point “AlarmMode”

Rule’s Code (kept password generic for now):

triggers:

  • id: “1”
    configuration:
    itemName: AlarmMode
    type: core.ItemCommandTrigger
    conditions: []
    actions:

  • inputs: {}
    id: “2”
    configuration:
    type: application/javascript
    script: |-
    rule “AlexaAlarmModeProxy”
    when Item AlexaAlarmMode received command
    then
    logInfo(“Alarm”, "received cmd " + receivedCommand)

        if(Zones.state === OPEN) {
            logInfo("Alarm", "A zone is open, not arming")
            return
        }
        var alarmItem = ""
        switch(receivedCommand) {
            case 0: {
                logInfo("Alarm", "received DISARMED")
                alarmItem = "AlarmModeDisarm"
            }
            case 1: {
                logInfo("Alarm", "received ARMED_STAY")
                alarmItem = "AlarmModeDay"
            }
            case 2: {
                logInfo("Alarm", "received ARMED_NIGHT")
                 alarmItem = "AlarmModeNight"
            }
            case 3: {
                logInfo("Alarm", "received ARMED_AWAY")
                 alarmItem = "AlarmModeAway"
            }
            case 4: {
                logInfo("Alarm", "received NOT_READY")
            }
        }
        logInfo("Alarm", "AlexaAlarmMode before: " + AlexaAlarmMode.state)
        sendCommand(alarmItem, "1234")
    end
    
    
    /*
    0=Off
    1=Day
    2=Night
    3=Away
    4=Vacation
    5=Day instant
    6=Night delayed
    9=Arming day
    10=Arming night
    11=Arming away
    12=Arming vacation
    13=Arming day instant
    14=Arming night delayed
    */
    rule "AlarmMode to AlexaAlarmMode"
    when Item AlarmMode received update 
    then
        var value = (AlarmMode.state as Number)
        switch(AlarmMode.state){
            case 5: {
                value = 1
            }
            case 6: {
                value = 2
            }
            case 9: {
                value = 1
            }
            case 10: {
                value = 2
            }
            case 11: {
                value = 3
            }
            case 14: {
                value = 2
            }
        }
        AlexaAlarmMode.postUpdate(value)
    end
    

    type: script.ScriptAction

Any possibility I could pay you for an hour or two of time to deploy this on one of our customer’s homes (which then, hopefully I could then duplicate at one of their other homes)?