Skip to content

Commit

Permalink
Bump api to fix for multiple systems. Fix prioritized attribute repor…
Browse files Browse the repository at this point in the history
…ting incorrectly.
  • Loading branch information
djtimca committed Dec 4, 2020
1 parent 72536c7 commit a2c8f77
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/googlewifi/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
DEV_MANUFACTURER = "Google"
DEV_CLIENT_MODEL = "Connected Client"
DEFAULT_ICON = "mdi:wifi"
PAUSE_UPDATE = 10
PAUSE_UPDATE = 15
ADD_DISABLED = "add_disabled"
CONF_SPEEDTEST = "auto_speedtest"
DEFAULT_SPEEDTEST = True
Expand Down
2 changes: 1 addition & 1 deletion custom_components/googlewifi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://github.com/djtimca/hagooglewifi",
"requirements": [
"googlewifi==0.0.15"
"googlewifi==0.0.16"
],
"issue_tracker": "https://github.com/djtimca/hagooglewifi/issues",
"ssdp": [],
Expand Down
8 changes: 6 additions & 2 deletions custom_components/googlewifi/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import entity_platform
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.util.dt import as_local, parse_datetime
from homeassistant.util.dt import as_local, parse_datetime, as_timestamp
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC

from . import GoogleWifiEntity, GoogleWiFiUpdater
Expand Down Expand Up @@ -115,14 +115,16 @@ def is_on(self):
]["prioritizedStation"]["stationId"]
== self._item_id
):
is_prioritized = True
end_time = self.coordinator.data[self._system_id][
"groupSettings"
]["lanSettings"]["prioritizedStation"]["prioritizationEndTime"]
is_prioritized_end = as_local(
parse_datetime(end_time)
).strftime("%d-%b-%y %I:%M %p")

if as_timestamp(parse_datetime(end_time)) > time.time():
is_prioritized = True

self._attrs["prioritized"] = is_prioritized
self._attrs["prioritized_end"] = is_prioritized_end

Expand Down Expand Up @@ -211,12 +213,14 @@ async def async_turn_on(self, **kwargs):
"""Turn on (unpause) internet to the client."""
self._state = True
self._last_change = time.time()
self.async_schedule_update_ha_state()
await self.coordinator.api.pause_device(self._system_id, self._item_id, False)

async def async_turn_off(self, **kwargs):
"""Turn on (pause) internet to the client."""
self._state = False
self._last_change = time.time()
self.async_schedule_update_ha_state()
await self.coordinator.api.pause_device(self._system_id, self._item_id, True)

async def async_prioritize_device(self, duration):
Expand Down

0 comments on commit a2c8f77

Please sign in to comment.