mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +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],
|
"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
|
service_data["elevation"] = elevation
|
||||||
|
|
||||||
await hass.config.async_update(**service_data)
|
await hass.config.async_update(**service_data)
|
||||||
|
@ -242,7 +242,7 @@ async def test_setting_location(hass: HomeAssistant) -> None:
|
|||||||
assert elevation != 50
|
assert elevation != 50
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
"set_location",
|
SERVICE_SET_LOCATION,
|
||||||
{"latitude": 30, "longitude": 40},
|
{"latitude": 30, "longitude": 40},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
@ -253,12 +253,24 @@ async def test_setting_location(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
"set_location",
|
SERVICE_SET_LOCATION,
|
||||||
{"latitude": 30, "longitude": 40, "elevation": 50},
|
{"latitude": 30, "longitude": 40, "elevation": 50},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
assert hass.config.latitude == 30
|
||||||
|
assert hass.config.longitude == 40
|
||||||
assert hass.config.elevation == 50
|
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(
|
async def test_require_admin(
|
||||||
hass: HomeAssistant, hass_read_only_user: MockUser
|
hass: HomeAssistant, hass_read_only_user: MockUser
|
||||||
|
Loading…
x
Reference in New Issue
Block a user