diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 8c83d9ee6e9..85c8879756f 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -37,13 +37,18 @@ async def async_setup(hass: HomeAssistant, config: dict): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Shelly from a config entry.""" + temperature_unit = "C" if hass.config.units.is_metric else "F" + options = aioshelly.ConnectionOptions( + entry.data[CONF_HOST], + entry.data.get(CONF_USERNAME), + entry.data.get(CONF_PASSWORD), + temperature_unit, + ) try: async with async_timeout.timeout(5): device = await aioshelly.Device.create( - entry.data[CONF_HOST], aiohttp_client.async_get_clientsession(hass), - entry.data.get(CONF_USERNAME), - entry.data.get(CONF_PASSWORD), + options, ) except (asyncio.TimeoutError, OSError) as err: raise ConfigEntryNotReady from err diff --git a/homeassistant/components/shelly/config_flow.py b/homeassistant/components/shelly/config_flow.py index cd35f7d2552..6446d2dd2d2 100644 --- a/homeassistant/components/shelly/config_flow.py +++ b/homeassistant/components/shelly/config_flow.py @@ -25,12 +25,13 @@ async def validate_input(hass: core.HomeAssistant, host, data): Data has the keys from DATA_SCHEMA with values provided by the user. """ + options = aioshelly.ConnectionOptions( + host, data.get(CONF_USERNAME), data.get(CONF_PASSWORD) + ) async with async_timeout.timeout(5): device = await aioshelly.Device.create( - host, aiohttp_client.async_get_clientsession(hass), - data.get(CONF_USERNAME), - data.get(CONF_PASSWORD), + options, ) await device.shutdown() diff --git a/homeassistant/components/shelly/manifest.json b/homeassistant/components/shelly/manifest.json index f15c4fb3f0d..010ecf16a56 100644 --- a/homeassistant/components/shelly/manifest.json +++ b/homeassistant/components/shelly/manifest.json @@ -3,7 +3,7 @@ "name": "Shelly", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/shelly2", - "requirements": ["aioshelly==0.2.1"], + "requirements": ["aioshelly==0.3.0"], "zeroconf": ["_http._tcp.local."], "codeowners": ["@balloob", "@bieniu"] } diff --git a/requirements_all.txt b/requirements_all.txt index 8f1e71e141a..2ecbe135cae 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -221,7 +221,7 @@ aiopvpc==2.0.2 aiopylgtv==0.3.3 # homeassistant.components.shelly -aioshelly==0.2.1 +aioshelly==0.3.0 # homeassistant.components.switcher_kis aioswitcher==1.2.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index eb76f07a6ac..ab27fae3caa 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -131,7 +131,7 @@ aiopvpc==2.0.2 aiopylgtv==0.3.3 # homeassistant.components.shelly -aioshelly==0.2.1 +aioshelly==0.3.0 # homeassistant.components.switcher_kis aioswitcher==1.2.1