diff --git a/CHANGELOG.md b/CHANGELOG.md index f2db3e0..69bf344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.2 (2024-02-25) + +* use default Home Assistant icons where possible +* remove gateway serial number/site id from gateway name + ## 0.4.1 (2024-02-24) * bump pyadtpulse to 1.2.7. diff --git a/custom_components/adtpulse/alarm_control_panel.py b/custom_components/adtpulse/alarm_control_panel.py index f2494db..f49008f 100644 --- a/custom_components/adtpulse/alarm_control_panel.py +++ b/custom_components/adtpulse/alarm_control_panel.py @@ -58,14 +58,6 @@ ADT_ALARM_UNKNOWN: STATE_UNAVAILABLE, } -ALARM_ICON_MAP = { - ADT_ALARM_ARMING: "mdi:shield-refresh", - ADT_ALARM_AWAY: "mdi:shield-lock", - ADT_ALARM_DISARMING: "mdi-shield-sync", - ADT_ALARM_HOME: "mdi:shield-home", - ADT_ALARM_OFF: "mdi:shield-off", - ADT_ALARM_UNKNOWN: "mdi:shield-bug", -} FORCE_ARM = "force arm" ARM_ERROR_MESSAGE = ( @@ -129,13 +121,6 @@ def state(self) -> str: def assumed_state(self) -> bool: return self._assumed_state is None - @property - def icon(self) -> str: - """Return the icon.""" - if self._alarm.status not in ALARM_ICON_MAP: - return "mdi:shield-alert" - return ALARM_ICON_MAP[self._alarm.status] - @property def supported_features(self) -> AlarmControlPanelEntityFeature: """Return the list of supported features.""" @@ -261,11 +246,6 @@ def available(self) -> bool: """Alarm panel is always available even if gateway isn't.""" return True - @property - def name(self) -> str | None: - """Return the name of the sensor.""" - return None - @property def code_arm_required(self) -> bool: """Whether the code is required for arm actions.""" diff --git a/custom_components/adtpulse/base_entity.py b/custom_components/adtpulse/base_entity.py index 8e997ee..9f95a30 100644 --- a/custom_components/adtpulse/base_entity.py +++ b/custom_components/adtpulse/base_entity.py @@ -47,15 +47,6 @@ def has_entity_name(self) -> bool: """Returns has_entity_name. Should generally be true.""" return True - @property - def icon(self) -> str | None: - """Return the mdi icon. - - Returns: - str: mdi icon name - """ - return "mdi:gauge" - @property def extra_state_attributes(self) -> Mapping[str, Any] | None: """Return the device state attributes.""" diff --git a/custom_components/adtpulse/binary_sensor.py b/custom_components/adtpulse/binary_sensor.py index 117cff9..6cc6d01 100644 --- a/custom_components/adtpulse/binary_sensor.py +++ b/custom_components/adtpulse/binary_sensor.py @@ -54,25 +54,6 @@ "glass": BinarySensorDeviceClass.TAMPER, } -ADT_SENSOR_ICON_MAP = { - BinarySensorDeviceClass.CO: ("mdi:molecule-co", "mdi:checkbox-marked-circle"), - BinarySensorDeviceClass.DOOR: ("mdi:door-open", "mdi:door"), - BinarySensorDeviceClass.GARAGE_DOOR: ( - "mdi:garage-open-variant", - "mdi:garage-variant", - ), - BinarySensorDeviceClass.HEAT: ("mdi:fire", "mdi:smoke-detector-variant"), - BinarySensorDeviceClass.MOISTURE: ("mdi:home-flood", "mdi:heat-wave"), - BinarySensorDeviceClass.MOTION: ("mdi:run-fast", "mdi:motion-sensor"), - BinarySensorDeviceClass.PROBLEM: ("mdi:alert-circle", "mdi:hand-okay"), - BinarySensorDeviceClass.SMOKE: ("mdi:fire", "mdi:smoke-detector-variant"), - BinarySensorDeviceClass.TAMPER: ("mdi:window-open", "mdi:window-closed"), - BinarySensorDeviceClass.WINDOW: ( - "mdi:window-open-variant", - "mdi:window-closed-variant", - ), -} - async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback @@ -206,22 +187,6 @@ def unique_id(self) -> str: return f"adt_pulse_trouble_sensor_{self._site.id}_{self._my_zone.id_}" return f"adt_pulse_sensor_{self._site.id}_{self._my_zone.id_}" - @property - def icon(self) -> str: - """Get icon. - - Returns: - str: returns mdi:icon corresponding to current state - """ - if self.device_class not in ADT_SENSOR_ICON_MAP: - LOG.error( - "Unknown ADT Pulse binary sensor device type %s", self.device_class - ) - return "mdi:alert-octogram" - if self.is_on: - return ADT_SENSOR_ICON_MAP[self.device_class][0] - return ADT_SENSOR_ICON_MAP[self.device_class][1] - @property def is_on(self) -> bool: """Return True if the binary sensor is on.""" @@ -290,30 +255,18 @@ def __init__(self, coordinator: ADTPulseDataUpdateCoordinator, site: ADTPulseSit "%s: adding gateway status sensor for site %s", ADTPULSE_DOMAIN, site.name ) self._device_class = BinarySensorDeviceClass.CONNECTIVITY - self._name = "Connection" - super().__init__(coordinator, self._name) + super().__init__(coordinator, "Gateway") @property def is_on(self) -> bool: """Return if gateway is online.""" return self._gateway.is_online - @property - def name(self) -> str | None: - """Return the name of the sensor.""" - return None - @property def unique_id(self) -> str: """Return HA unique id.""" return get_gateway_unique_id(self._site) - @property - def icon(self) -> str: - if self.is_on: - return "mdi:lan-connect" - return "mdi:lan-disconnect" - @property def extra_state_attributes(self) -> Mapping[str, Any]: """Return the device state attributes.""" @@ -321,8 +274,7 @@ def extra_state_attributes(self) -> Mapping[str, Any]: "primary_connection_type": self._gateway.primary_connection_type, "broadband_connection_status": self._gateway.broadband_connection_status, "cellular_connection_status": self._gateway.cellular_connection_status, - "cellular_connection" - "_signal_strength": self._gateway.cellular_connection_signal_strength, + "signal_strength": self._gateway.cellular_connection_signal_strength, "broadband_lan_ip_address": str(self._gateway.broadband_lan_ip_address), "device_lan_ip_address": str(self._gateway.device_lan_ip_address), "router_lan_ip_address": str(self._gateway.router_lan_ip_address), @@ -339,18 +291,20 @@ def device_info(self) -> DeviceInfo: for i in ("broadband_lan_mac", "device_lan_mac"): if getattr(self._gateway, i) is not None: mac_addresses.add((CONNECTION_NETWORK_MAC, getattr(self._gateway, i))) + identifiers = set() + if self._gateway.serial_number is not None: + identifiers.add((ADTPULSE_DOMAIN, self._gateway.serial_number)) + if self._site.id is not None: + identifiers.add((ADTPULSE_DOMAIN, get_gateway_unique_id(self._site))) di = DeviceInfo( connections=mac_addresses, model=self._gateway.model, manufacturer=self._gateway.manufacturer, hw_version=self._gateway.hardware_version, sw_version=self._gateway.firmware_version, + name="ADT Pulse Gateway", + identifiers=identifiers, ) - if self._gateway.serial_number is not None: - di["identifiers"] = {(ADTPULSE_DOMAIN, self._gateway.serial_number)} - di["name"] = f"ADT Pulse Gateway {self._gateway.serial_number}" - else: - di["name"] = f"ADT Pulse Gateway {self._site.id}" return di @callback diff --git a/custom_components/adtpulse/manifest.json b/custom_components/adtpulse/manifest.json index 50bb131..a31f75d 100644 --- a/custom_components/adtpulse/manifest.json +++ b/custom_components/adtpulse/manifest.json @@ -11,5 +11,5 @@ "requirements": [ "pyadtpulse==1.2.7" ], - "version": "0.4.1" + "version": "0.4.2" } diff --git a/custom_components/adtpulse/sensor.py b/custom_components/adtpulse/sensor.py index 13c6515..cfab5f2 100644 --- a/custom_components/adtpulse/sensor.py +++ b/custom_components/adtpulse/sensor.py @@ -177,13 +177,6 @@ def device_class(self) -> str | None: """Return the class of this sensor.""" return SensorDeviceClass.TIMESTAMP - @property - def icon(self) -> str | None: - """Return the icon of this sensor.""" - if self.native_value: - return "mdi:timer-pause" - return None - @property def native_value(self) -> datetime | None: """Return the state of the sensor."""