Skip to content

Commit

Permalink
Merge pull request #249 from itchannel/1.44
Browse files Browse the repository at this point in the history
1.44
  • Loading branch information
itchannel authored Feb 13, 2023
2 parents 52a2862 + 2038bfd commit fd639c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
20 changes: 18 additions & 2 deletions custom_components/fordpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,18 @@ async def async_refresh_status_service(service_call):
async def async_clear_tokens_service(service_call):
await hass.async_add_executor_job(clear_tokens, hass, service_call, coordinator)

async def async_clear_tokens_service(service_call):
await hass.async_add_executor_job(clear_tokens, hass, service_call, coordinator)

async def handle_reload(service):
"""Handle reload service call."""
_LOGGER.debug("Reloading Integration")

current_entries = hass.config_entries.async_entries(DOMAIN)
reload_tasks = [
hass.config_entries.async_reload(entry.entry_id)
for entry in current_entries
]

await asyncio.gather(*reload_tasks)

hass.services.async_register(
DOMAIN,
Expand All @@ -107,6 +117,12 @@ async def async_clear_tokens_service(service_call):
async_clear_tokens_service,
)

hass.services.async_register(
DOMAIN,
"reload",
handle_reload
)

return True


Expand Down
9 changes: 4 additions & 5 deletions custom_components/fordpass/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,11 @@ def get_value(self, ftype):
elif self.sensor == "windowPosition":
if self.coordinator.data[self.sensor] == None:
return "Unsupported"
status = "Closed"
for key, value in self.coordinator.data[self.sensor].items():
if "open" in value["value"].lower():
return "Open"
elif "closed" in value["value"].lower():
return "Closed"
return "Unsupported"
if "open" or "btwn" in value["value"].lower():
status = "Open"
return status
elif self.sensor == "lastRefresh":
return dt.as_local(
datetime.strptime(
Expand Down
3 changes: 3 additions & 0 deletions custom_components/fordpass/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ refresh_status:
text:
clear_tokens:
description: "Clear the cached tokens"
reload:
name: Reload
description: "Reload the Fordpass Integration"

0 comments on commit fd639c3

Please sign in to comment.