mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Fix bad falsy-check in homeassistant.set_location service (#129389)
This commit is contained in:
parent
505a4bfc34
commit
cce925c06c
@ -282,7 +282,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
|
||||
"longitude": call.data[ATTR_LONGITUDE],
|
||||
}
|
||||
|
||||
if elevation := call.data.get(ATTR_ELEVATION):
|
||||
if (elevation := call.data.get(ATTR_ELEVATION)) is not None:
|
||||
service_data["elevation"] = elevation
|
||||
|
||||
await hass.config.async_update(**service_data)
|
||||
|
@ -242,7 +242,7 @@ async def test_setting_location(hass: HomeAssistant) -> None:
|
||||
assert elevation != 50
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
"set_location",
|
||||
SERVICE_SET_LOCATION,
|
||||
{"latitude": 30, "longitude": 40},
|
||||
blocking=True,
|
||||
)
|
||||
@ -253,12 +253,24 @@ async def test_setting_location(hass: HomeAssistant) -> None:
|
||||
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
"set_location",
|
||||
SERVICE_SET_LOCATION,
|
||||
{"latitude": 30, "longitude": 40, "elevation": 50},
|
||||
blocking=True,
|
||||
)
|
||||
assert hass.config.latitude == 30
|
||||
assert hass.config.longitude == 40
|
||||
assert hass.config.elevation == 50
|
||||
|
||||
await hass.services.async_call(
|
||||
"homeassistant",
|
||||
SERVICE_SET_LOCATION,
|
||||
{"latitude": 30, "longitude": 40, "elevation": 0},
|
||||
blocking=True,
|
||||
)
|
||||
assert hass.config.latitude == 30
|
||||
assert hass.config.longitude == 40
|
||||
assert hass.config.elevation == 0
|
||||
|
||||
|
||||
async def test_require_admin(
|
||||
hass: HomeAssistant, hass_read_only_user: MockUser
|
||||
|
Loading…
x
Reference in New Issue
Block a user