Bump pyefergy to 22.1.1 (#65156)
* Bump pyefergy to 22.1.0 * uno mas * uno mas * uno mas
This commit is contained in:
parent
c25431750e
commit
4a042e7d73
5 changed files with 27 additions and 21 deletions
|
@ -3,7 +3,7 @@
|
||||||
"name": "Efergy",
|
"name": "Efergy",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/efergy",
|
"documentation": "https://www.home-assistant.io/integrations/efergy",
|
||||||
"requirements": ["pyefergy==0.1.5"],
|
"requirements": ["pyefergy==22.1.1"],
|
||||||
"codeowners": ["@tkdrob"],
|
"codeowners": ["@tkdrob"],
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["iso4217", "pyefergy"]
|
"loggers": ["iso4217", "pyefergy"]
|
||||||
|
|
|
@ -3,8 +3,10 @@ from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from re import sub
|
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 (
|
from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
|
@ -16,6 +18,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
|
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import EfergyEntity
|
from . import EfergyEntity
|
||||||
from .const import CONF_CURRENT_VALUES, DATA_KEY_API, DOMAIN
|
from .const import CONF_CURRENT_VALUES, DATA_KEY_API, DOMAIN
|
||||||
|
@ -123,8 +126,8 @@ async def async_setup_entry(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
description.entity_registry_enabled_default = len(api.info["sids"]) > 1
|
description.entity_registry_enabled_default = len(api.sids) > 1
|
||||||
for sid in api.info["sids"]:
|
for sid in api.sids:
|
||||||
sensors.append(
|
sensors.append(
|
||||||
EfergySensor(
|
EfergySensor(
|
||||||
api,
|
api,
|
||||||
|
@ -146,14 +149,16 @@ class EfergySensor(EfergyEntity, SensorEntity):
|
||||||
server_unique_id: str,
|
server_unique_id: str,
|
||||||
period: str | None = None,
|
period: str | None = None,
|
||||||
currency: str | None = None,
|
currency: str | None = None,
|
||||||
sid: str = "",
|
sid: int | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(api, server_unique_id)
|
super().__init__(api, server_unique_id)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
if description.key == CONF_CURRENT_VALUES:
|
if description.key == CONF_CURRENT_VALUES:
|
||||||
self._attr_name = f"{description.name}_{sid}"
|
self._attr_name = f"{description.name}_{'' if sid is None else sid}"
|
||||||
self._attr_unique_id = f"{server_unique_id}/{description.key}_{sid}"
|
self._attr_unique_id = (
|
||||||
|
f"{server_unique_id}/{description.key}_{'' if sid is None else sid}"
|
||||||
|
)
|
||||||
if "cost" in description.key:
|
if "cost" in description.key:
|
||||||
self._attr_native_unit_of_measurement = currency
|
self._attr_native_unit_of_measurement = currency
|
||||||
self.sid = sid
|
self.sid = sid
|
||||||
|
@ -162,10 +167,11 @@ class EfergySensor(EfergyEntity, SensorEntity):
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Get the Efergy monitor data from the web service."""
|
"""Get the Efergy monitor data from the web service."""
|
||||||
try:
|
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
|
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:
|
if self._attr_available:
|
||||||
self._attr_available = False
|
self._attr_available = False
|
||||||
_LOGGER.error("Error getting data: %s", ex)
|
_LOGGER.error("Error getting data: %s", ex)
|
||||||
|
|
|
@ -1491,7 +1491,7 @@ pyeconet==0.1.14
|
||||||
pyedimax==0.2.1
|
pyedimax==0.2.1
|
||||||
|
|
||||||
# homeassistant.components.efergy
|
# homeassistant.components.efergy
|
||||||
pyefergy==0.1.5
|
pyefergy==22.1.1
|
||||||
|
|
||||||
# homeassistant.components.eight_sleep
|
# homeassistant.components.eight_sleep
|
||||||
pyeight==0.2.0
|
pyeight==0.2.0
|
||||||
|
|
|
@ -920,7 +920,7 @@ pydispatcher==2.0.5
|
||||||
pyeconet==0.1.14
|
pyeconet==0.1.14
|
||||||
|
|
||||||
# homeassistant.components.efergy
|
# homeassistant.components.efergy
|
||||||
pyefergy==0.1.5
|
pyefergy==22.1.1
|
||||||
|
|
||||||
# homeassistant.components.everlights
|
# homeassistant.components.everlights
|
||||||
pyeverlights==0.1.0
|
pyeverlights==0.1.0
|
||||||
|
|
|
@ -57,9 +57,9 @@ async def mock_responses(
|
||||||
"""Mock responses from Efergy."""
|
"""Mock responses from Efergy."""
|
||||||
base_url = "https://engage.efergy.com/mobile_proxy/"
|
base_url = "https://engage.efergy.com/mobile_proxy/"
|
||||||
api = Efergy(
|
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:
|
if error:
|
||||||
aioclient_mock.get(
|
aioclient_mock.get(
|
||||||
f"{base_url}getInstant?token={token}",
|
f"{base_url}getInstant?token={token}",
|
||||||
|
@ -75,19 +75,19 @@ async def mock_responses(
|
||||||
text=load_fixture("efergy/instant.json"),
|
text=load_fixture("efergy/instant.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/daily_energy.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/weekly_energy.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/monthly_energy.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/yearly_energy.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
aioclient_mock.get(
|
||||||
|
@ -95,19 +95,19 @@ async def mock_responses(
|
||||||
text=load_fixture("efergy/budget.json"),
|
text=load_fixture("efergy/budget.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/daily_cost.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/weekly_cost.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/monthly_cost.json"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=load_fixture("efergy/yearly_cost.json"),
|
||||||
)
|
)
|
||||||
if token == TOKEN:
|
if token == TOKEN:
|
||||||
|
|
Loading…
Add table
Reference in a new issue