parent
6a7e87f1c3
commit
b9bc6ca070
|
@ -35,7 +35,7 @@ class V2CUpdateCoordinator(DataUpdateCoordinator[TrydanData]):
|
|||
"""Fetch sensor data from api."""
|
||||
try:
|
||||
data: TrydanData = await self.evse.get_data()
|
||||
_LOGGER.debug("Received data: %s", data)
|
||||
return data
|
||||
except TrydanError as err:
|
||||
raise UpdateFailed(f"Error communicating with API: {err}") from err
|
||||
_LOGGER.debug("Received data: %s", data)
|
||||
return data
|
||||
|
|
|
@ -26,7 +26,7 @@ class V2CBaseEntity(CoordinatorEntity[V2CUpdateCoordinator]):
|
|||
super().__init__(coordinator)
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, coordinator.evse.host)},
|
||||
identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
|
||||
manufacturer="V2C",
|
||||
model="Trydan",
|
||||
name=coordinator.name,
|
||||
|
|
|
@ -60,11 +60,10 @@ async def async_setup_entry(
|
|||
"""Set up V2C Trydan number platform."""
|
||||
coordinator: V2CUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
entities: list[NumberEntity] = [
|
||||
async_add_entities(
|
||||
V2CSettingsNumberEntity(coordinator, description, config_entry.entry_id)
|
||||
for description in TRYDAN_NUMBER_SETTINGS
|
||||
]
|
||||
async_add_entities(entities)
|
||||
)
|
||||
|
||||
|
||||
class V2CSettingsNumberEntity(V2CBaseEntity, NumberEntity):
|
||||
|
|
|
@ -16,7 +16,6 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -90,11 +89,10 @@ async def async_setup_entry(
|
|||
"""Set up V2C sensor platform."""
|
||||
coordinator: V2CUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
entities: list[Entity] = [
|
||||
async_add_entities(
|
||||
V2CSensorBaseEntity(coordinator, description, config_entry.entry_id)
|
||||
for description in TRYDAN_SENSORS
|
||||
]
|
||||
async_add_entities(entities)
|
||||
)
|
||||
|
||||
|
||||
class V2CSensorBaseEntity(V2CBaseEntity, SensorEntity):
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
"error": {
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
|
|
|
@ -55,11 +55,10 @@ async def async_setup_entry(
|
|||
"""Set up V2C switch platform."""
|
||||
coordinator: V2CUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
entities: list[SwitchEntity] = [
|
||||
async_add_entities(
|
||||
V2CSwitchEntity(coordinator, description, config_entry.entry_id)
|
||||
for description in TRYDAN_SWITCHES
|
||||
]
|
||||
async_add_entities(entities)
|
||||
)
|
||||
|
||||
|
||||
class V2CSwitchEntity(V2CBaseEntity, SwitchEntity):
|
||||
|
|
|
@ -46,7 +46,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
|||
],
|
||||
)
|
||||
async def test_form_cannot_connect(
|
||||
hass: HomeAssistant, side_effect: Exception, error: str
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, side_effect: Exception, error: str
|
||||
) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
Loading…
Reference in New Issue