Bump pyefergy to 22.1.1 (#65156)

* Bump pyefergy to 22.1.0

* uno mas

* uno mas

* uno mas
This commit is contained in:
Robert Hillis 2022-01-29 09:01:00 -05:00 committed by GitHub
parent c25431750e
commit 4a042e7d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 21 deletions

View File

@ -3,7 +3,7 @@
"name": "Efergy",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/efergy",
"requirements": ["pyefergy==0.1.5"],
"requirements": ["pyefergy==22.1.1"],
"codeowners": ["@tkdrob"],
"iot_class": "cloud_polling",
"loggers": ["iso4217", "pyefergy"]

View File

@ -3,8 +3,10 @@ from __future__ import annotations
import logging
from re import sub
from typing import cast
from pyefergy import Efergy, exceptions
from pyefergy import Efergy
from pyefergy.exceptions import ConnectError, DataError, ServiceError
from homeassistant.components.sensor import (
SensorDeviceClass,
@ -16,6 +18,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
from homeassistant.helpers.typing import StateType
from . import EfergyEntity
from .const import CONF_CURRENT_VALUES, DATA_KEY_API, DOMAIN
@ -123,8 +126,8 @@ async def async_setup_entry(
)
)
else:
description.entity_registry_enabled_default = len(api.info["sids"]) > 1
for sid in api.info["sids"]:
description.entity_registry_enabled_default = len(api.sids) > 1
for sid in api.sids:
sensors.append(
EfergySensor(
api,
@ -146,14 +149,16 @@ class EfergySensor(EfergyEntity, SensorEntity):
server_unique_id: str,
period: str | None = None,
currency: str | None = None,
sid: str = "",
sid: int | None = None,
) -> None:
"""Initialize the sensor."""
super().__init__(api, server_unique_id)
self.entity_description = description
if description.key == CONF_CURRENT_VALUES:
self._attr_name = f"{description.name}_{sid}"
self._attr_unique_id = f"{server_unique_id}/{description.key}_{sid}"
self._attr_name = f"{description.name}_{'' if sid is None else sid}"
self._attr_unique_id = (
f"{server_unique_id}/{description.key}_{'' if sid is None else sid}"
)
if "cost" in description.key:
self._attr_native_unit_of_measurement = currency
self.sid = sid
@ -162,10 +167,11 @@ class EfergySensor(EfergyEntity, SensorEntity):
async def async_update(self) -> None:
"""Get the Efergy monitor data from the web service."""
try:
self._attr_native_value = await self.api.async_get_reading(
data = await self.api.async_get_reading(
self.entity_description.key, period=self.period, sid=self.sid
)
except (exceptions.DataError, exceptions.ConnectError) as ex:
self._attr_native_value = cast(StateType, data)
except (ConnectError, DataError, ServiceError) as ex:
if self._attr_available:
self._attr_available = False
_LOGGER.error("Error getting data: %s", ex)

View File

@ -1491,7 +1491,7 @@ pyeconet==0.1.14
pyedimax==0.2.1
# homeassistant.components.efergy
pyefergy==0.1.5
pyefergy==22.1.1
# homeassistant.components.eight_sleep
pyeight==0.2.0

View File

@ -920,7 +920,7 @@ pydispatcher==2.0.5
pyeconet==0.1.14
# homeassistant.components.efergy
pyefergy==0.1.5
pyefergy==22.1.1
# homeassistant.components.everlights
pyeverlights==0.1.0

View File

@ -57,9 +57,9 @@ async def mock_responses(
"""Mock responses from Efergy."""
base_url = "https://engage.efergy.com/mobile_proxy/"
api = Efergy(
token, session=async_get_clientsession(hass), utc_offset=hass.config.time_zone
token, session=async_get_clientsession(hass), utc_offset="America/New_York"
)
offset = api._utc_offset # pylint: disable=protected-access
assert api._utc_offset == 300
if error:
aioclient_mock.get(
f"{base_url}getInstant?token={token}",
@ -75,19 +75,19 @@ async def mock_responses(
text=load_fixture("efergy/instant.json"),
)
aioclient_mock.get(
f"{base_url}getEnergy?token={token}&offset={offset}&period=day",
f"{base_url}getEnergy?period=day",
text=load_fixture("efergy/daily_energy.json"),
)
aioclient_mock.get(
f"{base_url}getEnergy?token={token}&offset={offset}&period=week",
f"{base_url}getEnergy?period=week",
text=load_fixture("efergy/weekly_energy.json"),
)
aioclient_mock.get(
f"{base_url}getEnergy?token={token}&offset={offset}&period=month",
f"{base_url}getEnergy?period=month",
text=load_fixture("efergy/monthly_energy.json"),
)
aioclient_mock.get(
f"{base_url}getEnergy?token={token}&offset={offset}&period=year",
f"{base_url}getEnergy?period=year",
text=load_fixture("efergy/yearly_energy.json"),
)
aioclient_mock.get(
@ -95,19 +95,19 @@ async def mock_responses(
text=load_fixture("efergy/budget.json"),
)
aioclient_mock.get(
f"{base_url}getCost?token={token}&offset={offset}&period=day",
f"{base_url}getCost?period=day",
text=load_fixture("efergy/daily_cost.json"),
)
aioclient_mock.get(
f"{base_url}getCost?token={token}&offset={offset}&period=week",
f"{base_url}getCost?period=week",
text=load_fixture("efergy/weekly_cost.json"),
)
aioclient_mock.get(
f"{base_url}getCost?token={token}&offset={offset}&period=month",
f"{base_url}getCost?period=month",
text=load_fixture("efergy/monthly_cost.json"),
)
aioclient_mock.get(
f"{base_url}getCost?token={token}&offset={offset}&period=year",
f"{base_url}getCost?period=year",
text=load_fixture("efergy/yearly_cost.json"),
)
if token == TOKEN: