mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
If no Reolink HTTP api available, do not set configuration_url (#146684)
* If no http api available, do not set configuration_url * Add tests
This commit is contained in:
parent
ba2aac4614
commit
07110e288d
@ -75,7 +75,10 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None]
|
||||
)
|
||||
|
||||
http_s = "https" if self._host.api.use_https else "http"
|
||||
self._conf_url = f"{http_s}://{self._host.api.host}:{self._host.api.port}"
|
||||
if self._host.api.baichuan_only:
|
||||
self._conf_url = None
|
||||
else:
|
||||
self._conf_url = f"{http_s}://{self._host.api.host}:{self._host.api.port}"
|
||||
self._dev_id = self._host.unique_id
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._dev_id)},
|
||||
@ -184,6 +187,11 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
||||
if mac := self._host.api.baichuan.mac_address(dev_ch):
|
||||
connections.add((CONNECTION_NETWORK_MAC, mac))
|
||||
|
||||
if self._conf_url is None:
|
||||
conf_url = None
|
||||
else:
|
||||
conf_url = f"{self._conf_url}/?ch={dev_ch}"
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._dev_id)},
|
||||
connections=connections,
|
||||
@ -195,7 +203,7 @@ class ReolinkChannelCoordinatorEntity(ReolinkHostCoordinatorEntity):
|
||||
hw_version=self._host.api.camera_hardware_version(dev_ch),
|
||||
sw_version=self._host.api.camera_sw_version(dev_ch),
|
||||
serial_number=self._host.api.camera_uid(dev_ch),
|
||||
configuration_url=f"{self._conf_url}/?ch={dev_ch}",
|
||||
configuration_url=conf_url,
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -1186,6 +1186,19 @@ async def test_camera_wake_callback(
|
||||
assert hass.states.get(entity_id).state == STATE_OFF
|
||||
|
||||
|
||||
async def test_baichaun_only(
|
||||
hass: HomeAssistant,
|
||||
reolink_connect: MagicMock,
|
||||
config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test initializing a baichuan only device."""
|
||||
reolink_connect.baichuan_only = True
|
||||
|
||||
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.SWITCH]):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_remove(
|
||||
hass: HomeAssistant,
|
||||
reolink_connect: MagicMock,
|
||||
|
Loading…
x
Reference in New Issue
Block a user