1 """Support for Fibaro binary sensors."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
6 from typing
import Any, cast
8 from pyfibaro.fibaro_device
import DeviceModel
12 BinarySensorDeviceClass,
20 from .
import FibaroController
21 from .const
import DOMAIN
22 from .entity
import FibaroEntity
25 "com.fibaro.floodSensor": [
"Flood",
"mdi:water", BinarySensorDeviceClass.MOISTURE],
26 "com.fibaro.motionSensor": [
"Motion",
"mdi:run", BinarySensorDeviceClass.MOTION],
27 "com.fibaro.doorSensor": [
"Door",
"mdi:window-open", BinarySensorDeviceClass.DOOR],
28 "com.fibaro.windowSensor": [
31 BinarySensorDeviceClass.WINDOW,
33 "com.fibaro.smokeSensor": [
"Smoke",
"mdi:smoking", BinarySensorDeviceClass.SMOKE],
34 "com.fibaro.FGMS001": [
"Motion",
"mdi:run", BinarySensorDeviceClass.MOTION],
35 "com.fibaro.heatDetector": [
"Heat",
"mdi:fire", BinarySensorDeviceClass.HEAT],
36 "com.fibaro.accelerometer": [
39 BinarySensorDeviceClass.MOVING,
47 async_add_entities: AddEntitiesCallback,
49 """Perform the setup for Fibaro controller devices."""
50 controller: FibaroController = hass.data[DOMAIN][entry.entry_id]
54 for device
in controller.fibaro_devices[Platform.BINARY_SENSOR]
61 """Representation of a Fibaro Binary Sensor."""
63 def __init__(self, fibaro_device: DeviceModel) ->
None:
64 """Initialize the binary_sensor."""
69 if fibaro_device.type
in SENSOR_TYPES:
71 elif fibaro_device.base_type
in SENSOR_TYPES:
81 """Return the extra state attributes of the device."""
85 """Get the latest data and update the state."""
96 """Return x y z values of the accelerator sensor value."""
98 for axis_name
in (
"x",
"y",
"z"):
99 attrs[axis_name] =
float(moving_values[axis_name])
102 def _is_moving(self, moving_values: Mapping[str, Any]) -> bool:
103 """Return that a moving is detected when one axis reports a value."""
104 for axis_name
in (
"x",
"y",
"z"):
105 if float(moving_values[axis_name]) != 0:
110 """Get the moving values of the accelerator sensor in a dict."""
None __init__(self, DeviceModel fibaro_device)
Mapping[str, Any] _get_xyz_moving(self, Mapping[str, Any] moving_values)
_own_extra_state_attributes
bool _is_moving(self, Mapping[str, Any] moving_values)
Mapping[str, Any] extra_state_attributes(self)
Mapping[str, Any] _get_moving_values(self)
bool current_binary_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)