Use updated powerwall client API library (#34139)

* Use updated powerwall client API library

* Increase instant_power precision to 3

* Add @jrester as code owner for powerwall
This commit is contained in:
jrester authored and GitHub committed 2020-04-13 21:59:50 +02:00
1 parent 7bd6f5413d
commit 6924192523
13 files changed
+104 -117

No files matched your search

@@ -1,14 +1,13 @@
"""Config flow for Tesla Powerwall integration."""
import logging
from tesla_powerwall import ApiError, PowerWall, PowerWallUnreachableError
from tesla_powerwall import ApiError, Powerwall, PowerwallUnreachableError
import voluptuous as vol
from homeassistant import config_entries, core, exceptions
from homeassistant.const import CONF_IP_ADDRESS
from .const import DOMAIN # pylint:disable=unused-import
from .const import POWERWALL_SITE_NAME
_LOGGER = logging.getLogger(__name__)
@@ -21,20 +20,15 @@ async def validate_input(hass: core.HomeAssistant, data):
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
power_wall = PowerWall(data[CONF_IP_ADDRESS])
power_wall = Powerwall(data[CONF_IP_ADDRESS])
try:
site_info = await hass.async_add_executor_job(call_site_info, power_wall)
except (PowerWallUnreachableError, ApiError, ConnectionError):
site_info = await hass.async_add_executor_job(power_wall.get_site_info)
except (PowerwallUnreachableError, ApiError, ConnectionError):
raise CannotConnect
# Return info that you want to store in the config entry.
return {"title": site_info[POWERWALL_SITE_NAME]}
def call_site_info(power_wall):
"""Wrap site_info to be a callable."""
return power_wall.site_info
return {"title": site_info.site_name}
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):