1 """Support for Gogogate2 garage Doors."""
3 from __future__
import annotations
5 from itertools
import chain
7 from ismartgate.common
import AbstractDoor, get_configured_doors
19 from .common
import get_data_update_coordinator, sensor_unique_id
20 from .coordinator
import DeviceDataUpdateCoordinator
21 from .entity
import GoGoGate2Entity
23 SENSOR_ID_WIRED =
"WIRE"
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up the config entry."""
37 for door
in get_configured_doors(data_update_coordinator.data)
38 if door.sensorid
and door.sensorid != SENSOR_ID_WIRED
42 for door
in get_configured_doors(data_update_coordinator.data)
43 if door.sensorid
and door.sensorid != SENSOR_ID_WIRED
50 """Base class for door sensor entities."""
54 """Return the state attributes."""
55 attrs = super().extra_state_attributes
57 if door.sensorid
is not None:
58 attrs[
"sensor_id"] = door.sensorid
63 """Battery sensor entity for gogogate2 door sensor."""
65 _attr_entity_category = EntityCategory.DIAGNOSTIC
66 _attr_device_class = SensorDeviceClass.BATTERY
67 _attr_state_class = SensorStateClass.MEASUREMENT
68 _attr_native_unit_of_measurement = PERCENTAGE
72 config_entry: ConfigEntry,
73 data_update_coordinator: DeviceDataUpdateCoordinator,
76 """Initialize the object."""
78 super().
__init__(config_entry, data_update_coordinator, door, unique_id)
82 """Return the name of the door."""
83 return f
"{self.door.name} battery"
87 """Return the state of the entity."""
88 return self.
doordoor.voltage
92 """Temperature sensor entity for gogogate2 door sensor."""
94 _attr_device_class = SensorDeviceClass.TEMPERATURE
95 _attr_state_class = SensorStateClass.MEASUREMENT
96 _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
100 config_entry: ConfigEntry,
101 data_update_coordinator: DeviceDataUpdateCoordinator,
104 """Initialize the object."""
106 super().
__init__(config_entry, data_update_coordinator, door, unique_id)
110 """Return the name of the door."""
111 return f
"{self.door.name} temperature"
115 """Return the state of the entity."""
116 return self.
doordoor.temperature
None __init__(self, ConfigEntry config_entry, DeviceDataUpdateCoordinator data_update_coordinator, AbstractDoor door)
def extra_state_attributes(self)
None __init__(self, ConfigEntry config_entry, DeviceDataUpdateCoordinator data_update_coordinator, AbstractDoor door)
str sensor_unique_id(ConfigEntry config_entry, AbstractDoor door, str sensor_type)
DeviceDataUpdateCoordinator get_data_update_coordinator(HomeAssistant hass, ConfigEntry config_entry)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)