Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2020-01-12 #122

Merged
merged 3 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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