1 """Support for Motionblinds sensors."""
3 from motionblinds
import DEVICE_TYPES_WIFI
4 from motionblinds.motion_blinds
import DEVICE_TYPE_TDBU
14 SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
20 from .const
import DOMAIN, KEY_COORDINATOR, KEY_GATEWAY
21 from .entity
import MotionCoordinatorEntity
23 ATTR_BATTERY_VOLTAGE =
"battery_voltage"
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Perform the setup for Motionblinds."""
32 entities: list[SensorEntity] = []
33 motion_gateway = hass.data[DOMAIN][config_entry.entry_id][KEY_GATEWAY]
34 coordinator = hass.data[DOMAIN][config_entry.entry_id][KEY_COORDINATOR]
36 for blind
in motion_gateway.device_list.values():
38 if blind.device_type == DEVICE_TYPE_TDBU:
41 elif blind.battery_voltage
is not None and blind.battery_voltage > 0:
46 if motion_gateway.device_type
not in DEVICE_TYPES_WIFI:
53 """Representation of a Motion Battery Sensor."""
55 _attr_device_class = SensorDeviceClass.BATTERY
56 _attr_native_unit_of_measurement = PERCENTAGE
57 _attr_entity_category = EntityCategory.DIAGNOSTIC
58 _attr_state_class = SensorStateClass.MEASUREMENT
61 """Initialize the Motion Battery Sensor."""
67 """Return the state of the sensor."""
68 return self.
_blind_blind.battery_level
72 """Return device specific state attributes."""
73 return {ATTR_BATTERY_VOLTAGE: self.
_blind_blind.battery_voltage}
77 """Representation of a Motion Battery Sensor for a Top Down Bottom Up blind."""
80 """Initialize the Motion Battery Sensor."""
89 """Return the state of the sensor."""
90 if self.
_blind_blind.battery_level
is None:
92 return self.
_blind_blind.battery_level[self.
_motor_motor[0]]
96 """Return device specific state attributes."""
98 if self.
_blind_blind.battery_voltage
is not None:
99 attributes[ATTR_BATTERY_VOLTAGE] = self.
_blind_blind.battery_voltage[
106 """Representation of a Motion Signal Strength Sensor."""
108 _attr_device_class = SensorDeviceClass.SIGNAL_STRENGTH
109 _attr_entity_registry_enabled_default =
False
110 _attr_native_unit_of_measurement = SIGNAL_STRENGTH_DECIBELS_MILLIWATT
111 _attr_entity_category = EntityCategory.DIAGNOSTIC
114 """Initialize the Motion Signal Strength Sensor."""
115 super().
__init__(coordinator, blind)
120 """Return the state of the sensor."""
121 return self.
_blind_blind.RSSI
def extra_state_attributes(self)
def __init__(self, coordinator, blind)
def __init__(self, coordinator, blind)
def __init__(self, coordinator, blind, motor)
def extra_state_attributes(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)