address code comments / tidy ups ()

pull/97722/head
Michael Arthur 2023-08-04 09:09:14 +12:00 committed by GitHub
parent 83af2f5b8b
commit bfa394d399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 12 deletions
homeassistant/components/electric_kiwi

View File

@ -29,9 +29,8 @@ async def async_setup_entry(
"""Electric Kiwi select setup."""
hop_coordinator: ElectricKiwiHOPDataCoordinator = hass.data[DOMAIN][entry.entry_id]
_LOGGER.debug("Setting up HOP entity")
entities = [ElectricKiwiSelectHOPEntity(hop_coordinator, HOP_SELECT)]
async_add_entities(entities)
_LOGGER.debug("Setting up select entity")
async_add_entities([ElectricKiwiSelectHOPEntity(hop_coordinator, HOP_SELECT)])
class ElectricKiwiSelectHOPEntity(
@ -46,16 +45,15 @@ class ElectricKiwiSelectHOPEntity(
def __init__(
self,
hop_coordinator: ElectricKiwiHOPDataCoordinator,
coordinator: ElectricKiwiHOPDataCoordinator,
description: SelectEntityDescription,
) -> None:
"""Initialise the HOP selection entity."""
super().__init__(hop_coordinator)
self._attr_unique_id = f"{self.coordinator._ek_api.customer_number}_{self.coordinator._ek_api.connection_id}_{description.key}"
super().__init__(coordinator)
self._attr_unique_id = f"{coordinator._ek_api.customer_number}_{coordinator._ek_api.connection_id}_{description.key}"
self.entity_description = description
self._state = None
self.values_dict = self.coordinator.get_hop_options()
self._attr_options = list(self.values_dict.keys())
self.values_dict = coordinator.get_hop_options()
self._attr_options = list(self.values_dict)
@property
def current_option(self) -> str | None:

View File

@ -99,13 +99,13 @@ class ElectricKiwiHOPEntity(
def __init__(
self,
hop_coordinator: ElectricKiwiHOPDataCoordinator,
coordinator: ElectricKiwiHOPDataCoordinator,
description: ElectricKiwiHOPSensorEntityDescription,
) -> None:
"""Entity object for Electric Kiwi sensor."""
super().__init__(hop_coordinator)
super().__init__(coordinator)
self._attr_unique_id = f"{self.coordinator._ek_api.customer_number}_{self.coordinator._ek_api.connection_id}_{description.key}"
self._attr_unique_id = f"{coordinator._ek_api.customer_number}_{coordinator._ek_api.connection_id}_{description.key}"
self.entity_description = description
@property