mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 23:57:06 +00:00
Add exception translations for Fronius (#132830)
* Add exception translations for Fronius * Update sensor.py
This commit is contained in:
parent
416a4c02b4
commit
9551a12c9c
@ -226,7 +226,14 @@ class FroniusSolarNet:
|
|||||||
_LOGGER.debug("Re-scan failed for %s", self.host)
|
_LOGGER.debug("Re-scan failed for %s", self.host)
|
||||||
return inverter_infos
|
return inverter_infos
|
||||||
|
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="entry_cannot_connect",
|
||||||
|
translation_placeholders={
|
||||||
|
"host": self.host,
|
||||||
|
"fronius_error": str(err),
|
||||||
|
},
|
||||||
|
) from err
|
||||||
|
|
||||||
for inverter in _inverter_info["inverters"]:
|
for inverter in _inverter_info["inverters"]:
|
||||||
solar_net_id = inverter["device_id"]["value"]
|
solar_net_id = inverter["device_id"]["value"]
|
||||||
|
@ -56,7 +56,10 @@ async def validate_host(
|
|||||||
_LOGGER.debug(err)
|
_LOGGER.debug(err)
|
||||||
raise CannotConnect from err
|
raise CannotConnect from err
|
||||||
except StopIteration as err:
|
except StopIteration as err:
|
||||||
raise CannotConnect("No supported Fronius SolarNet device found.") from err
|
raise CannotConnect(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="no_supported_device_found",
|
||||||
|
) from err
|
||||||
first_inverter_uid: str = first_inverter["unique_id"]["value"]
|
first_inverter_uid: str = first_inverter["unique_id"]["value"]
|
||||||
return first_inverter_uid, FroniusConfigEntryData(
|
return first_inverter_uid, FroniusConfigEntryData(
|
||||||
host=host,
|
host=host,
|
||||||
|
@ -13,6 +13,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
DOMAIN,
|
||||||
SOLAR_NET_ID_POWER_FLOW,
|
SOLAR_NET_ID_POWER_FLOW,
|
||||||
SOLAR_NET_ID_SYSTEM,
|
SOLAR_NET_ID_SYSTEM,
|
||||||
FroniusDeviceInfo,
|
FroniusDeviceInfo,
|
||||||
@ -67,7 +68,11 @@ class FroniusCoordinatorBase(
|
|||||||
self._failed_update_count += 1
|
self._failed_update_count += 1
|
||||||
if self._failed_update_count == self.MAX_FAILED_UPDATES:
|
if self._failed_update_count == self.MAX_FAILED_UPDATES:
|
||||||
self.update_interval = self.error_interval
|
self.update_interval = self.error_interval
|
||||||
raise UpdateFailed(err) from err
|
raise UpdateFailed(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="update_failed",
|
||||||
|
translation_placeholders={"fronius_error": str(err)},
|
||||||
|
) from err
|
||||||
|
|
||||||
if self._failed_update_count != 0:
|
if self._failed_update_count != 0:
|
||||||
self._failed_update_count = 0
|
self._failed_update_count = 0
|
||||||
|
@ -54,6 +54,9 @@ if TYPE_CHECKING:
|
|||||||
FroniusStorageUpdateCoordinator,
|
FroniusStorageUpdateCoordinator,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
ENERGY_VOLT_AMPERE_REACTIVE_HOUR: Final = "varh"
|
ENERGY_VOLT_AMPERE_REACTIVE_HOUR: Final = "varh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,5 +294,16 @@
|
|||||||
"name": "[%key:component::sensor::entity_component::temperature::name%]"
|
"name": "[%key:component::sensor::entity_component::temperature::name%]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"no_supported_device_found": {
|
||||||
|
"message": "No supported Fronius SolarNet device found."
|
||||||
|
},
|
||||||
|
"entry_cannot_connect": {
|
||||||
|
"message": "Failed to connect to Fronius device at {host}: {fronius_error}"
|
||||||
|
},
|
||||||
|
"update_failed": {
|
||||||
|
"message": "An error occurred while attempting to fetch data: {fronius_error}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user