mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Handle empty energy sites in Tesla integrations (#122355)
This commit is contained in:
parent
ea94cdb668
commit
31d3b3b675
@ -26,7 +26,7 @@ from homeassistant.helpers.config_entry_oauth2_flow import (
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
|
|
||||||
from .const import DOMAIN, MODELS
|
from .const import DOMAIN, LOGGER, MODELS
|
||||||
from .coordinator import (
|
from .coordinator import (
|
||||||
TeslaFleetEnergySiteInfoCoordinator,
|
TeslaFleetEnergySiteInfoCoordinator,
|
||||||
TeslaFleetEnergySiteLiveCoordinator,
|
TeslaFleetEnergySiteLiveCoordinator,
|
||||||
@ -113,6 +113,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -
|
|||||||
)
|
)
|
||||||
elif "energy_site_id" in product and tesla.energy:
|
elif "energy_site_id" in product and tesla.energy:
|
||||||
site_id = product["energy_site_id"]
|
site_id = product["energy_site_id"]
|
||||||
|
if not (
|
||||||
|
product["components"]["battery"]
|
||||||
|
or product["components"]["solar"]
|
||||||
|
or "wall_connectors" in product["components"]
|
||||||
|
):
|
||||||
|
LOGGER.debug(
|
||||||
|
"Skipping Energy Site %s as it has no components",
|
||||||
|
site_id,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
api = EnergySpecific(tesla.energy, site_id)
|
api = EnergySpecific(tesla.energy, site_id)
|
||||||
|
|
||||||
live_coordinator = TeslaFleetEnergySiteLiveCoordinator(hass, api)
|
live_coordinator = TeslaFleetEnergySiteLiveCoordinator(hass, api)
|
||||||
|
@ -108,6 +108,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslemetryConfigEntry) -
|
|||||||
)
|
)
|
||||||
elif "energy_site_id" in product and Scope.ENERGY_DEVICE_DATA in scopes:
|
elif "energy_site_id" in product and Scope.ENERGY_DEVICE_DATA in scopes:
|
||||||
site_id = product["energy_site_id"]
|
site_id = product["energy_site_id"]
|
||||||
|
if not (
|
||||||
|
product["components"]["battery"]
|
||||||
|
or product["components"]["solar"]
|
||||||
|
or "wall_connectors" in product["components"]
|
||||||
|
):
|
||||||
|
LOGGER.debug(
|
||||||
|
"Skipping Energy Site %s as it has no components",
|
||||||
|
site_id,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
api = EnergySpecific(teslemetry.energy, site_id)
|
api = EnergySpecific(teslemetry.energy, site_id)
|
||||||
live_coordinator = TeslemetryEnergySiteLiveCoordinator(hass, api)
|
live_coordinator = TeslemetryEnergySiteLiveCoordinator(hass, api)
|
||||||
info_coordinator = TeslemetryEnergySiteInfoCoordinator(hass, api, product)
|
info_coordinator = TeslemetryEnergySiteInfoCoordinator(hass, api, product)
|
||||||
|
@ -111,6 +111,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: TessieConfigEntry) -> bo
|
|||||||
for product in products:
|
for product in products:
|
||||||
if "energy_site_id" in product:
|
if "energy_site_id" in product:
|
||||||
site_id = product["energy_site_id"]
|
site_id = product["energy_site_id"]
|
||||||
|
if not (
|
||||||
|
product["components"]["battery"]
|
||||||
|
or product["components"]["solar"]
|
||||||
|
or "wall_connectors" in product["components"]
|
||||||
|
):
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Skipping Energy Site %s as it has no components",
|
||||||
|
site_id,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
api = EnergySpecific(tessie.energy, site_id)
|
api = EnergySpecific(tessie.energy, site_id)
|
||||||
energysites.append(
|
energysites.append(
|
||||||
TessieEnergyData(
|
TessieEnergyData(
|
||||||
|
@ -115,7 +115,17 @@
|
|||||||
"features": {
|
"features": {
|
||||||
"rate_plan_manager_no_pricing_constraint": true
|
"rate_plan_manager_no_pricing_constraint": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"energy_site_id": 98765,
|
||||||
|
"components": {
|
||||||
|
"battery": false,
|
||||||
|
"solar": false,
|
||||||
|
"grid": false,
|
||||||
|
"load_meter": false,
|
||||||
|
"market_type": "residential"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"count": 2
|
"count": 3
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,17 @@
|
|||||||
"features": {
|
"features": {
|
||||||
"rate_plan_manager_no_pricing_constraint": true
|
"rate_plan_manager_no_pricing_constraint": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"energy_site_id": 98765,
|
||||||
|
"components": {
|
||||||
|
"battery": false,
|
||||||
|
"solar": false,
|
||||||
|
"grid": false,
|
||||||
|
"load_meter": false,
|
||||||
|
"market_type": "residential"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"count": 2
|
"count": 3
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,17 @@
|
|||||||
"features": {
|
"features": {
|
||||||
"rate_plan_manager_no_pricing_constraint": true
|
"rate_plan_manager_no_pricing_constraint": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"energy_site_id": 98765,
|
||||||
|
"components": {
|
||||||
|
"battery": false,
|
||||||
|
"solar": false,
|
||||||
|
"grid": false,
|
||||||
|
"load_meter": false,
|
||||||
|
"market_type": "residential"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"count": 2
|
"count": 3
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user