1 """Support for QVR Pro streams."""
3 from __future__
import annotations
7 from pyqvrpro.client
import QVRResponseError
14 from .const
import DOMAIN, SHORT_NAME
16 _LOGGER = logging.getLogger(__name__)
22 add_entities: AddEntitiesCallback,
23 discovery_info: DiscoveryInfoType |
None =
None,
25 """Set up the QVR Pro camera platform."""
26 if discovery_info
is None:
29 client = hass.data[DOMAIN][
"client"]
33 for channel
in hass.data[DOMAIN][
"channels"]:
36 QVRProCamera(**channel, stream_source=stream_source, client=client)
43 """Get channel stream source."""
45 resp = client.get_channel_live_stream(guid, protocol=
"rtsp")
46 except QVRResponseError
as ex:
50 full_url = resp[
"resourceUris"]
52 protocol = full_url[:7]
53 auth = f
"{client.get_auth_string()}@"
56 return f
"{protocol}{auth}{url}"
60 """Representation of a QVR Pro camera."""
62 def __init__(self, name, model, brand, channel_index, guid, stream_source, client):
63 """Init QVR Pro camera."""
65 self.
_name_name = f
"{SHORT_NAME} {name}"
77 """Return the name of the entity."""
78 return self.
_name_name
82 """Return the model of the entity."""
87 """Return the brand of the entity."""
92 """Get the state attributes."""
93 return {
"qvr_guid": self.
guidguid}
96 self, width: int |
None =
None, height: int |
None =
None
98 """Get image bytes from camera."""
100 return self.
_client_client.get_snapshot(self.
guidguid)
102 except QVRResponseError
as ex:
103 _LOGGER.error(
"Error getting image: %s", ex)
106 return self.
_client_client.get_snapshot(self.
guidguid)
109 """Get stream source."""
def extra_state_attributes(self)
bytes|None camera_image(self, int|None width=None, int|None height=None)
def __init__(self, name, model, brand, channel_index, guid, stream_source, client)
None add_entities(HomeAssistant hass, FreeboxRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
def get_stream_source(guid, client)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)