Skip to content

Commit

Permalink
Merge pull request #48 from rsnodgrass:0.4.2
Browse files Browse the repository at this point in the history
0.4.2
  • Loading branch information
rlippmann authored Feb 25, 2024
2 parents e04c807 + 4741521 commit b18f79f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 92 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 0 additions & 20 deletions custom_components/adtpulse/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down
9 changes: 0 additions & 9 deletions custom_components/adtpulse/base_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
64 changes: 9 additions & 55 deletions custom_components/adtpulse/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -290,39 +255,26 @@ 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."""
return {
"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),
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion custom_components/adtpulse/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"requirements": [
"pyadtpulse==1.2.7"
],
"version": "0.4.1"
"version": "0.4.2"
}
7 changes: 0 additions & 7 deletions custom_components/adtpulse/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit b18f79f

Please sign in to comment.