I spent the better part of today going in the bowels of the Indigo plugin architecture and trying to come out with something useful.
My ultimate goal is to create an Indigo plugin that will talk to an Arduino to get alarm state, AND talk to HomeKit via the HomeKit Bridge plug-in.
For now, I'm just trying to get a custom plug-in created. The plug-in needs to handle four states:
0- Stay Armed
1- Away Armed
2- Night Armed
3- Disarmed
In my Devices.xml file, I have:
- Code: Select all
-->
<Device type="custom" id="myCustomAlarmType">
<Name>Custom Alarm State</Name>
<ConfigUI>
<Field id="address" type="textfield" defaultValue="192.168.0.30">
<Label>IP Address:</Label>
</Field>
<Field id="SupportsSensorValue" type="checkbox" hidden="false" defaultValue="true">
<Label>Supports sensor value</Label>
</Field>
<Field id="initialValueObtained" type="checkbox" hidden="true" defaultValue="true">
<Label>Has the initial value been obtained?</Label>
</Field>
<Field id="tag" type="textfield" defaultValue="a">
<Label>Tag:</Label>
</Field>
</ConfigUI>
<States>
<State id="sensorValue">
<ValueType>
<List>
<Option value="stay">Stay Arm</Option>
<Option value="away">Away Arm</Option>
<Option value="night">Night Arm</Option>
<Option value="disarm">Disarm</Option>
</List>
</ValueType>
<TriggerLabel>Alarm State Changed</TriggerLabel>
<TriggerLabelPrefix>Alarm Changed to</TriggerLabelPrefix>
<ControlPageLabel>Alarm State</ControlPageLabel>
<ControlPageLabelPrefix>Alarm state is</ControlPageLabelPrefix>
</State>
</States>
</Device>
My Actions.xml file looks like this:
- Code: Select all
<Action id="setCustomAlarmState" deviceFilter="self">
<Name>Set Custom Alarm State</Name>
<CallbackMethod>setCustomAlarmState</CallbackMethod>
<ConfigUI>
<Field id="description" type="textfield" hidden="true">
<Label>runtime calculated</Label>
</Field>
<Field type="menu" id="sensorValue" defaultValue="0">
<Label>Alarm State:</Label>
<List>
<Option value="stay">Stay Arm</Option>
<Option value="away">Away Arm</Option>
<Option value="night">Night Arm</Option>
<Option value="disarm">Disarm</Option>
</List>
</Field>
</ConfigUI>
</Action>
</Actions>
I create a device of type "Custom Alarm State" and it shows up in my device list. I also created a control page and tied four controls to each of the actions.
One thing that doesn't appear to be working is the device state and icon aren't updating in the device list. I'm still trying to troubleshoot that.
My main question is: am I taking the correct approach here by creating a custom device? I don't see an "alarm" device in the Indigo Object Model.