mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Implement late feedback for Bluecurrent (#106918)
* Apply changes * Fix MockClient * Apply feedback * Remove connector tests * Change MockClient to inhert MagicMock * Add reconnect tests and refactor mock client * Refactor mock exception throwing * Add future_fixture * Move mocked client methods into create_client_mock * Remove fixture and separate event from mock_client * Add FutureContainer to store the loop_future
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""Entity representing a Blue Current charge point."""
|
||||
from abc import abstractmethod
|
||||
|
||||
from homeassistant.const import ATTR_NAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
@@ -17,9 +19,9 @@ class BlueCurrentEntity(Entity):
|
||||
|
||||
def __init__(self, connector: Connector, signal: str) -> None:
|
||||
"""Initialize the entity."""
|
||||
self.connector: Connector = connector
|
||||
self.signal: str = signal
|
||||
self.has_value: bool = False
|
||||
self.connector = connector
|
||||
self.signal = signal
|
||||
self.has_value = False
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
@@ -40,9 +42,9 @@ class BlueCurrentEntity(Entity):
|
||||
return self.connector.available and self.has_value
|
||||
|
||||
@callback
|
||||
@abstractmethod
|
||||
def update_from_latest_data(self) -> None:
|
||||
"""Update the entity from the latest data."""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class ChargepointEntity(BlueCurrentEntity):
|
||||
@@ -50,6 +52,8 @@ class ChargepointEntity(BlueCurrentEntity):
|
||||
|
||||
def __init__(self, connector: Connector, evse_id: str) -> None:
|
||||
"""Initialize the entity."""
|
||||
super().__init__(connector, f"{DOMAIN}_value_update_{evse_id}")
|
||||
|
||||
chargepoint_name = connector.charge_points[evse_id][ATTR_NAME]
|
||||
|
||||
self.evse_id = evse_id
|
||||
@@ -59,5 +63,3 @@ class ChargepointEntity(BlueCurrentEntity):
|
||||
manufacturer="Blue Current",
|
||||
model=connector.charge_points[evse_id][MODEL_TYPE],
|
||||
)
|
||||
|
||||
super().__init__(connector, f"{DOMAIN}_value_update_{self.evse_id}")
|
||||
|
||||
Reference in New Issue
Block a user