Skip to content

Commit

Permalink
Allow location to be changed from the settings config
Browse files Browse the repository at this point in the history
  • Loading branch information
cloneofghosts committed Nov 16, 2024
1 parent 9b2d4d9 commit 207fe76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions custom_components/pirateweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Pirate Weather as config entry."""
name = entry.data[CONF_NAME]
api_key = entry.data[CONF_API_KEY]
latitude = entry.data.get(CONF_LATITUDE, hass.config.latitude)
longitude = entry.data.get(CONF_LONGITUDE, hass.config.longitude)
latitude = _get_config_value(entry, CONF_LATITUDE)
longitude = _get_config_value(entry, CONF_LONGITUDE)
forecast_mode = "daily"
conditions = _get_config_value(entry, CONF_MONITORED_CONDITIONS)
units = _get_config_value(entry, CONF_UNITS)
Expand All @@ -55,9 +55,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
pw_entity_rounding = _get_config_value(entry, PW_ROUND)
pw_scan_Int = _get_config_value(entry, CONF_SCAN_INTERVAL)

# If scan_interval config value is not configured fall back to the entry data config value
if not pw_scan_Int:
pw_scan_Int = entry.data[CONF_SCAN_INTERVAL]

# If latitude or longitude is not configured fall back to the HA location
if not latitude:
latitude = hass.config.latitude
if not longitude:
longitude = hass.config.longitude

pw_scan_Int = max(pw_scan_Int, 60)

# Extract list of int from forecast days/ hours string if present
Expand Down
4 changes: 2 additions & 2 deletions custom_components/pirateweather/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"documentation": "https://github.com/alexander0042/pirate-weather-ha",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
"version": "1.6.1.1"
}
"version": "1.6.2b1"
}

0 comments on commit 207fe76

Please sign in to comment.