Ok, here is what I did:
1) I linked a button on a keypad to a switch ("cc"), and the switch to the button, so that without Indigo, both are controlled together.
2) I created an empty virtual switch, "cc virtual"
3) I created a pair of action groups, "cc on" and "cc off". They control the state of the switch, the keypad button and set the device state of "cc virtual" to on/off respectively.
4) I created a variable "cc var"
5) In the virtual switch, I set "cc on" and "cc off" as the action groups for on/off, and "cc var" as the variable.
I left the toggle action empty
6) I created a pair of triggers based on the switch "cc" changing, which sets the virtual switch state on and off.
At this point, the virtual switch matches the state of the light and keypad, and I can send it on and off actions and the light and keypad follow.
7) For my control page, I created the following script to account for the lack of toggle behavior
Code: Select all
lamp = indigo.devices["CC Virtual"]
lightOn = 0
if hasattr(lamp, 'onState'):
lightOn = lamp.onState
if lightOn:
indigo.device.turnOff("CC Virtual")
else:
indigo.device.turnOn("CC Virtual")
8 ) For HomeKit, I just created a new device for "CC Virtual"
At this point, the control page and HomeKit are working.
Any thoughts on changes or improvements?
a) It wasn't obvious that I needed to create "cc var" since I'm using the
Set Virtual On/Off Device State command. I also note that it doesn't change the value as shown in the Variable List window, which seems odd.
b) I decided to not use a PowerLink scene to control the state of the button/light since indigo is involved in HomeKit and the control pages anyway
c) I wasn't sure how to make a toggle ActionGroup, which would have saved having a script on step 7.
d) Speaking of, can I access the virtual switch state / variable instead of querying the lamp onState in the script? Would that be better?