Fix GoGoGate2 configuration URL when remote access is disabled (#98387)

This commit is contained in:
Øyvind Matheson Wergeland 2023-08-17 15:12:35 +02:00 committed by GitHub
parent d6a7127b84
commit cb4917f880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -113,9 +113,10 @@ class GoGoGate2Entity(CoordinatorEntity[DeviceDataUpdateCoordinator]):
def device_info(self) -> DeviceInfo:
"""Device info for the controller."""
data = self.coordinator.data
configuration_url = (
f"https://{data.remoteaccess}" if data.remoteaccess else None
)
if data.remoteaccessenabled:
configuration_url = f"https://{data.remoteaccess}"
else:
configuration_url = f"http://{self._config_entry.data[CONF_IP_ADDRESS]}"
return DeviceInfo(
configuration_url=configuration_url,
identifiers={(DOMAIN, str(self._config_entry.unique_id))},

View file

@ -77,7 +77,7 @@ def _mocked_ismartgate_closed_door_response():
ismartgatename="ismartgatename0",
model="ismartgatePRO",
apiversion="",
remoteaccessenabled=False,
remoteaccessenabled=True,
remoteaccess="abc321.blah.blah",
firmwareversion="555",
pin=123,

View file

@ -340,6 +340,7 @@ async def test_device_info_ismartgate(
assert device.name == "mycontroller"
assert device.model == "ismartgatePRO"
assert device.sw_version == "555"
assert device.configuration_url == "https://abc321.blah.blah"
@patch("homeassistant.components.gogogate2.common.GogoGate2Api")
@ -375,3 +376,4 @@ async def test_device_info_gogogate2(
assert device.name == "mycontroller"
assert device.model == "gogogate2"
assert device.sw_version == "222"
assert device.configuration_url == "http://127.0.0.1"