1 """Support for Freebox cameras."""
3 from __future__
import annotations
22 from .const
import ATTR_DETECTION, DOMAIN, FreeboxHomeCategory
23 from .entity
import FreeboxHomeEntity
24 from .router
import FreeboxRouter
26 _LOGGER = logging.getLogger(__name__)
30 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
33 router: FreeboxRouter = hass.data[DOMAIN][entry.unique_id]
34 tracked: set[str] = set()
37 def update_callback() -> None:
40 router.listeners.append(
45 entity_platform.async_get_current_platform()
51 router: FreeboxRouter,
52 async_add_entities: AddEntitiesCallback,
55 """Add new cameras from the router."""
56 new_tracked: list[FreeboxCamera] = []
58 for nodeid, node
in router.home_devices.items():
59 if (node[
"category"] != FreeboxHomeCategory.CAMERA)
or (nodeid
in tracked):
69 """Representation of a Freebox camera."""
72 self, hass: HomeAssistant, router: FreeboxRouter, node: dict[str, Any]
74 """Initialize a camera."""
78 CONF_NAME: node[
"label"].strip(),
79 CONF_INPUT: node[
"props"][
"Stream"],
80 CONF_EXTRA_ARGUMENTS: DEFAULT_ARGUMENTS,
82 FFmpegCamera.__init__(self, hass, device_info)
85 CameraEntityFeature.ON_OFF | CameraEntityFeature.STREAM
89 node[
"type"][
"endpoints"],
"slot", ATTR_DETECTION
95 """Enable motion detection in the camera."""
100 """Disable motion detection in camera."""
105 """Update the camera node."""
111 self.
_name_name = node[
"label"].strip()
114 if self.
_node_node[
"status"] ==
"active":
120 for endpoint
in filter(
121 lambda x: (x[
"ep_type"] ==
"signal"), node[
"show_endpoints"]
None async_write_ha_state(self)
None async_update_signal(self)
_command_motion_detection
None async_enable_motion_detection(self)
_attr_motion_detection_enabled
None update_node(self, dict[str, Any] node)
None __init__(self, HomeAssistant hass, FreeboxRouter router, dict[str, Any] node)
_attr_extra_state_attributes
None async_disable_motion_detection(self)
int|None get_command_id(self, nodes, str ep_type, str name)
bool set_home_endpoint_value(self, int|None command_id, bool|None value=None)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
None add_entities(HomeAssistant hass, FreeboxRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)