From 927446304ee5aef46c1eec298ac5f9adf96611ab Mon Sep 17 00:00:00 2001 From: Jordan H Date: Fri, 1 Mar 2024 14:42:39 +0000 Subject: [PATCH] implement #8 --- custom_components/fuel_prices/__init__.py | 6 ++++++ custom_components/fuel_prices/manifest.json | 2 +- requirements.txt | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/custom_components/fuel_prices/__init__.py b/custom_components/fuel_prices/__init__.py index cf27b84..15109ac 100644 --- a/custom_components/fuel_prices/__init__.py +++ b/custom_components/fuel_prices/__init__.py @@ -116,6 +116,10 @@ async def handle_fuel_location_lookup(call: ServiceCall) -> ServiceResponse: return {"items": locations, "sources": entry.data.get("sources", [])} + async def handle_force_update(call: ServiceCall): + """Handle a request to force update.""" + await fuel_prices.update(force=True) + hass.services.async_register( DOMAIN, "find_fuel_station", @@ -130,6 +134,8 @@ async def handle_fuel_location_lookup(call: ServiceCall) -> ServiceResponse: supports_response=SupportsResponse.ONLY, ) + hass.services.async_register(DOMAIN, "force_update", handle_force_update) + return True diff --git a/custom_components/fuel_prices/manifest.json b/custom_components/fuel_prices/manifest.json index b387257..cbd42a3 100644 --- a/custom_components/fuel_prices/manifest.json +++ b/custom_components/fuel_prices/manifest.json @@ -12,7 +12,7 @@ "requirements": [ "reverse-geocode==1.4.1", "these-united-states==1.1.0.21", - "pyfuelprices==2.2.8" + "pyfuelprices==2.2.9" ], "ssdp": [], "version": "0.0.0", diff --git a/requirements.txt b/requirements.txt index a33645e..18e3cbd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ colorlog==6.7.0 homeassistant==2023.8.0 pip>=21.0,<23.2 ruff==0.0.292 -pyfuelprices==2.2.8 \ No newline at end of file +pyfuelprices==2.2.9 \ No newline at end of file