Skip to content

Commit

Permalink
Added methods to purge states
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingDiver committed Jan 27, 2020
1 parent 5b02a15 commit edda21f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HTTPd2.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>2.0.1</string>
<string>2.0.2</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
10 changes: 10 additions & 0 deletions HTTPd2.indigoPlugin/Contents/Server Plugin/Actions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?xml version="1.0"?>
<Actions>
<SupportURL>http://forums.indigodomo.com/viewforum.php?f=216</SupportURL>
<Action id="resetDeviceStates">
<Name>Reset Device States</Name>
<CallbackMethod>resetDeviceStatesAction</CallbackMethod>
<ConfigUI>
<Field id="targetDevice" type="menu">
<Label>Select device to reset:</Label>
<List class="indigo.devices" filter="self.serverDevice"/>
</Field> </ConfigUI>
</Action>

<Action id="getWebhookInfo" uiPath="hidden">
<Name>Get Webhook Info</Name>
<CallbackMethod>getWebhookInfoAction</CallbackMethod>
Expand Down
6 changes: 0 additions & 6 deletions HTTPd2.indigoPlugin/Contents/Server Plugin/Devices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@
</Field>
</ConfigUI>
<States>
<State id="status">
<ValueType>String</ValueType>
<TriggerLabel>UI Status</TriggerLabel>
<ControlPageLabel>UI Status</ControlPageLabel>
</State>
</States>
<UiDisplayStateId>status</UiDisplayStateId>
</Device>

<Device type="custom" id="proxyDevice">
Expand Down
11 changes: 11 additions & 0 deletions HTTPd2.indigoPlugin/Contents/Server Plugin/MenuItems.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@
back to the user you can post information into the Event Log.
-->
<MenuItems>
<MenuItem id="menu1">
<Name>Reset Device States</Name>
<CallbackMethod>resetDeviceStatesMenu</CallbackMethod>
<ButtonTitle>Reset States</ButtonTitle>
<ConfigUI>
<Field id="targetDevice" type="menu">
<Label>Select device to reset:</Label>
<List class="indigo.devices" filter="self.serverDevice"/>
</Field>
</ConfigUI>
</MenuItem>
</MenuItems>
21 changes: 21 additions & 0 deletions HTTPd2.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,27 @@ def CallbackNOP(self, hook_data):
pass


def resetDeviceStatesAction(self, pluginAction):
deviceId = int(pluginAction.props["targetDevice"])
self.resetDeviceStates(indigo.devices[deviceId])

def resetDeviceStatesMenu(self, valuesDict, typeId):
try:
deviceId = int(valuesDict["targetDevice"])
except:
self.logger.error(u"Bad Device specified for Reset Device operation")
return False

self.resetDeviceStates(indigo.devices[deviceId])
return True

def resetDeviceStates(self, device):
newProps = device.pluginProps
newProps["saved_states"] = "{}"
device.replacePluginPropsOnServer(newProps)
device.stateListOrDisplayStateIdChanged()


########################################
# Actions
########################################
Expand Down

3 comments on commit edda21f

@JaceJenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well. Is it intentional to get an Event Log message every time a webhook is posted to the interface?

HTTPd - Jace's Interface: Stopping serverDevice Device 183155032
HTTPd - Jace's Interface: Starting serverDevice Device 183155032

@FlyingDiver
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. Turn on Debug logging, do that same thing, then post in an issue.
Commenting on the commits is not the right way to do things on GitHub.

@JaceJenkins
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, happy to make an issue. Just didn't actually know if it was an issue. Sorry bout that.

Please sign in to comment.