Skip to content

Commit

Permalink
Merge pull request #148 from pavoni/handle_comms_failure_better
Browse files Browse the repository at this point in the history
Handle comms failure better
  • Loading branch information
pavoni authored Feb 6, 2021
2 parents 7cd487d + 573a2f7 commit 941823e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyvera"
version = "0.3.12"
version = "0.3.13"
description = "Python API for talking to Veracontrollers"

license = "GPL2"
Expand Down
14 changes: 12 additions & 2 deletions pyvera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ def color_service(self) -> str:
"""Vera service string for color."""
return "urn:micasaverde-com:serviceId:Color1"

@property
def poll_service(self) -> str:
"""Vera service string for poll."""
return "urn:micasaverde-com:serviceId:HaDevice1"

def vera_request(self, **kwargs: Any) -> requests.Response:
"""Perfom a vera_request for this device."""
request_payload = {"output_format": "json", "DeviceNum": self.device_id}
Expand Down Expand Up @@ -567,12 +572,17 @@ def call_service(self, service_id: str, action: str) -> requests.Response:
"""
result = self.vera_request(id="action", serviceId=service_id, action=action)
LOG.debug(
"call_service: " "result of vera_request with id %s: %s",
"call_service: " "result of vera_request for %s with id %s: %s",
self.name,
service_id,
result.text,
)
return result

def poll_device(self) -> None:
"""Poll the device to try and connect."""
self.call_service(self.poll_service, "Poll")

def set_cache_value(self, name: str, value: Any) -> None:
"""Set a variable in the local state dictionary.
Expand Down Expand Up @@ -785,7 +795,7 @@ def vera_device_id(self) -> int:
@property
def should_poll(self) -> bool:
"""Whether polling is needed if using subscriptions for this device."""
return False
return self.comm_failure


class VeraSwitch(VeraDevice):
Expand Down

0 comments on commit 941823e

Please sign in to comment.