Skip to content

Commit

Permalink
Added force off action
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingDiver committed Mar 23, 2023
1 parent 021e6f7 commit 35145c3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Occupatum.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>2022.1.5</string>
<string>2022.1.6</string>
<key>ServerApiVersion</key>
<string>3.0</string>
<key>IwsApiVersion</key>
Expand Down
4 changes: 4 additions & 0 deletions Occupatum.indigoPlugin/Contents/Server Plugin/Actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
</Field>
</ConfigUI>
</Action>
<Action id="forceZoneOff" deviceFilter="self.area">
<Name>Force Zone Off</Name>
<CallbackMethod>forceZoneOff</CallbackMethod>
</Action>
<Action id="updateActivityZone" deviceFilter="self.activityZone">
<Name>Update Activity Zone</Name>
<CallbackMethod>updateActivityZone</CallbackMethod>
Expand Down
23 changes: 22 additions & 1 deletion Occupatum.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ def validate_cancel_timer_action(self, dev_id, props):
self.logger.debug(f"validate_update_occupancy_zone_action, errors={errors}")
return (not bool(errors)), errors # bool(errors) will return False if empty, True if not)

def validate_force_zone_off_action(self, dev_id):
errors = indigo.Dict()
if dev_id not in indigo.devices:
errors["device"] = "'deviceId' must be included and must represent an existing device"

self.logger.debug(f"validate_force_zone_off_action, errors={errors}")
return (not bool(errors)), errors # bool(errors) will return False if empty, True if not)

def validate_update_activity_zone_action(self, dev_id, props):
errors = indigo.Dict()
if dev_id not in indigo.devices:
Expand Down Expand Up @@ -384,7 +392,7 @@ def validate_update_occupancy_zone_action(self, dev_id, props):
self.logger.debug(f"validate_update_occupancy_zone_action, errors={errors}")
return (not bool(errors)), errors # bool(errors) will return False if empty, True if not)

def cancelTimer(self, action, device, caller_waiting_for_result=None):
def cancelTimer(self, action, device, caller_waiting_for_result=None):
self.logger.debug(f"cancelTimer, zoneDevice={device.id}, pluginAction={action}")
reply_dict = indigo.Dict() # This will hold the status and errors or device details in the appropriate format
is_valid, errors = self.validate_cancel_timer_action(device.id, action.props)
Expand All @@ -407,6 +415,19 @@ def cancelTimer(self, action, device, caller_waiting_for_result=None):
device.updateStateImageOnServer(indigo.kStateImageSel.MotionSensor)
return reply_dict

def forceZoneOff(self, action, device, caller_waiting_for_result=None):
self.logger.debug(f"forceZoneOff, zoneDevice={device.id}")
reply_dict = indigo.Dict() # This will hold the status and errors or device details in the appropriate format
is_valid, errors = self.validate_force_zone_off_action(device.id)
reply_dict["status"] = is_valid
if not is_valid:
self.logger.error(f"Couldn't complete 'forceZoneOff' action because of errors:\n{dict(errors)}")
reply_dict["errors"] = errors
else:
device.updateStateOnServer(key='onOffState', value=False, uiValue="Off")
device.updateStateImageOnServer(indigo.kStateImageSel.MotionSensor)
return reply_dict

def updateActivityZone(self, plugin_action, zone_device, caller_waiting_for_result=None):
self.logger.debug(f"updateActivityZone, zoneDevice={zone_device.id}, pluginAction={plugin_action}")
reply_dict = indigo.Dict() # This will hold the status and errors or device details in the appropriate format
Expand Down

0 comments on commit 35145c3

Please sign in to comment.