In this example, Source1 and Source2 list all Indigo devices. Value1 and Value2 show the device states for the selected Indigo devices and both Value1 and Value2 refer to the same callback, with only the filter being different. By using the filter value, you can return different things to different controls using one callback. So why not use that to tell the callback which value to return to each control? Turns out this works really well. Who knew?
Devices.xml
- Code: Select all
<Field id="Source1" type="menu">
<Label>Source 1:</Label>
<List class="self" filter="" method="some_method" dynamicReload="true"/>
<CallbackMethod>callback_method</CallbackMethod>
</Field>
<Field id="Value1" type="menu">
<Label>Value:</Label>
<List class="self" filter="Source1" method="another_method" dynamicReload="true"/>
</Field>
<Field id="Source2" type="menu">
<Label>Source 1:</Label>
<List class="self" filter="" method="some_method" dynamicReload="true"/>
<CallbackMethod>callback_method</CallbackMethod>
</Field>
<Field id="Value2" type="menu">
<Label>Value:</Label>
<List class="self" filter="Source2" method="another_method" dynamicReload="true"/>
</Field>
- Code: Select all
def some_method(self, filter="", values_dict=None, type_id="", target_id=0):
return [(dev.id, dev.name) for dev in indigo.devices.iter()]
def another_method(self, filter="", values_dict=None, type_id="", target_id=0):
return [(state, state) for state in indigo.devices[values_dict[filter]].states]