1 """Support for the Netatmo camera lights."""
3 from __future__
import annotations
8 from pyatmo
import modules
as NaModules
20 EVENT_TYPE_LIGHT_MODE,
21 NETATMO_CREATE_CAMERA_LIGHT,
26 from .data_handler
import HOME, SIGNAL_NAME, NetatmoDevice
27 from .entity
import NetatmoModuleEntity
29 _LOGGER = logging.getLogger(__name__)
33 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
35 """Set up the Netatmo camera light platform."""
38 def _create_camera_light_entity(netatmo_device: NetatmoDevice) ->
None:
39 if not hasattr(netatmo_device.device,
"floodlight"):
45 entry.async_on_unload(
47 hass, NETATMO_CREATE_CAMERA_LIGHT, _create_camera_light_entity
52 def _create_entity(netatmo_device: NetatmoDevice) ->
None:
53 if not hasattr(netatmo_device.device,
"brightness"):
57 _LOGGER.debug(
"Adding light %s", entity)
60 entry.async_on_unload(
66 """Representation of a Netatmo Presence camera light."""
71 _attr_configuration_url = CONF_URL_SECURITY
72 _attr_color_mode = ColorMode.ONOFF
73 _attr_has_entity_name =
True
74 _attr_supported_color_modes = {ColorMode.ONOFF}
76 def __init__(self, netatmo_device: NetatmoDevice) ->
None:
77 """Initialize a Netatmo Presence camera light."""
82 self._publishers.extend(
86 "home_id": self.
homehome.entity_id,
99 f
"signal-{DOMAIN}-webhook-{EVENT_TYPE_LIGHT_MODE}",
106 """Handle webhook events."""
109 if not data.get(
"camera_id"):
113 data[
"home_id"] == self.
homehome.entity_id
114 and data[
"camera_id"] == self.
devicedevice.entity_id
115 and data[WEBHOOK_PUSH_TYPE] == WEBHOOK_LIGHT_MODE
124 """If the webhook is not established, mark as unavailable."""
128 """Turn camera floodlight on."""
129 _LOGGER.debug(
"Turn camera '%s' on", self.
namename)
130 await self.
devicedevice.async_floodlight_on()
133 """Turn camera floodlight into auto mode."""
134 _LOGGER.debug(
"Turn camera '%s' to auto mode", self.
namename)
135 await self.
devicedevice.async_floodlight_auto()
139 """Update the entity's state."""
144 """Representation of a dimmable light by Legrand/BTicino."""
147 _attr_configuration_url = CONF_URL_CONTROL
148 _attr_brightness: int |
None = 0
149 device: NaModules.NLFN
151 def __init__(self, netatmo_device: NetatmoDevice) ->
None:
152 """Initialize a Netatmo light."""
156 if self.
devicedevice.brightness
is not None:
163 self._publishers.extend(
167 "home_id": self.
homehome.entity_id,
175 if ATTR_BRIGHTNESS
in kwargs:
176 await self.
devicedevice.async_set_brightness(
177 round(kwargs[ATTR_BRIGHTNESS] / 2.55)
181 await self.
devicedevice.async_on()
187 """Turn light off."""
188 await self.
devicedevice.async_off()
194 """Update the entity's state."""
197 if (brightness := self.
devicedevice.brightness)
is not None:
None async_update_callback(self)
None async_turn_on(self, **Any kwargs)
None __init__(self, NetatmoDevice netatmo_device)
None async_turn_off(self, **Any kwargs)
None async_added_to_hass(self)
None handle_event(self, dict event)
None async_turn_on(self, **Any kwargs)
_attr_supported_color_modes
None __init__(self, NetatmoDevice netatmo_device)
None async_turn_off(self, **Any kwargs)
None async_update_callback(self)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
str|UndefinedType|None name(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)