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