Skip to content

Commit

Permalink
Fix switch toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr committed Jan 15, 2020
1 parent 07e3c59 commit 761b75c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/bhyve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(
self, bhyve, device, name, icon, device_class=None,
):
"""Initialize the sensor."""
self._bhyve: BHyve = bhyve
self._bhyve: Client = bhyve
self._device_class = device_class
self._async_unsub_dispatcher_connect = None

Expand Down
8 changes: 4 additions & 4 deletions custom_components/bhyve/pybhyve/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def _request(self, method: str, endpoint: str, params: dict = None) -> lis
try:
resp.raise_for_status()
return await resp.json(content_type=None)
except ClientError as err:
except Exception as err:
raise RequestError(f"Error requesting data from {url}: {err}")

async def _refresh_devices(self):
Expand Down Expand Up @@ -96,7 +96,7 @@ async def login(self) -> bool:
_LOGGER.debug("Logged in")
self._token = response["orbit_session_token"]

except ClientError as err:
except Exception as err:
raise RequestError(f"Error requesting data from {url}: {err}")

if self._token is None:
Expand Down Expand Up @@ -130,5 +130,5 @@ async def get_device(self, device_id):
return device
return None

def send_message(self, payload):
self._websocket.send(payload)
async def send_message(self, payload):
await self._websocket.send(payload)
4 changes: 2 additions & 2 deletions custom_components/bhyve/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ async def _send_station_message(self, station_payload):
await self._bhyve.send_message(payload)

except BHyveError as err:
_LOGGER.warning("Failed to connect to BHyve servers. %s", err)
_LOGGER.warning("Failed to send to BHyve websocket message %s", err)
raise (err)

async def async_turn_on(self, **kwargs):
"""Turn the switch on."""
station_payload = [{"station": self._zone_id, "run_time": 1.0}]
station_payload = [{"station": self._zone_id, "run_time": 10.0}]
await self._send_station_message(station_payload)

async def async_turn_off(self, **kwargs):
Expand Down

0 comments on commit 761b75c

Please sign in to comment.