Skip to content

Commit

Permalink
Merge pull request #122 from zabuldon/dev
Browse files Browse the repository at this point in the history
2020-01-12
  • Loading branch information
alandtse authored Jan 12, 2021
2 parents 1f85f97 + 441a72a commit 5dd9716
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def run(self):
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(exclude=("tests",)),
packages=find_packages(exclude=("tests*",)),
# If your package is a single module, use this instead of "packages":
# py_modules=["mypackage"],
# entry_points={
Expand Down
8 changes: 8 additions & 0 deletions teslajsonpy/homeassistant/charger.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def __init__(self, data: Dict, controller) -> None:
self.__charge_current_request = None
self.__charger_actual_current = None
self.__charger_voltage = None
self.__charger_soc_limit = None

async def async_update(self, wake_if_asleep=False, force=False) -> None:
"""Update the battery state."""
Expand Down Expand Up @@ -207,6 +208,8 @@ def refresh(self) -> None:
self.__charge_current_request = data["charge_current_request"]
self.__charger_actual_current = data["charger_actual_current"]
self.__charger_voltage = data["charger_voltage"]
self.__charge_limit_soc = data["charge_limit_soc"]
self.attrs["charge_limit_soc"] = self.charge_soc_limit
if self.measurement != "mi/hr":
self.__added_range = round(self.__added_range / 0.621371, 2)
self.__charging_rate = round(self.__charging_rate / 0.621371, 2)
Expand Down Expand Up @@ -251,6 +254,11 @@ def charge_energy_added(self) -> float:
"""Return the energy added."""
return self.__charge_energy_added

@property
def charge_soc_limit(self) -> int:
"""Return the state of charge limit."""
return self.__charge_limit_soc

@property
def device_class(self) -> Text:
"""Return the HA device class."""
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/homeassistant/test_charging_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_get_value_on_init(monkeypatch):
assert _sensor.charger_actual_current is None
assert _sensor.charger_voltage is None
assert _sensor.charge_energy_added is None
assert _sensor.charge_limit_soc is None


@pytest.mark.asyncio
Expand All @@ -71,6 +72,7 @@ async def test_get_value_after_update(monkeypatch):
assert _sensor.charger_actual_current == 0
assert _sensor.charger_voltage == 0
assert _sensor.charge_energy_added == 12.41
assert _sensor.charge_limit_soc == 90


@pytest.mark.asyncio
Expand All @@ -93,6 +95,7 @@ async def test_async_update(monkeypatch):
assert _sensor.charger_actual_current == 0
assert _sensor.charger_voltage == 0
assert _sensor.charge_energy_added == 12.41
assert _sensor.charge_limit_soc == 90


@pytest.mark.asyncio
Expand Down

0 comments on commit 5dd9716

Please sign in to comment.