-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Moustachauve/automatic-charging-toggle
Automatic charging toggle
- Loading branch information
Showing
7 changed files
with
225 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Asynchronous Python client for TechnoVE.""" | ||
|
||
import asyncio | ||
|
||
from technove import TechnoVE | ||
|
||
|
||
async def main() -> None: | ||
"""Show example on getting infos from your TechnoVE station.""" | ||
async with TechnoVE("192.168.10.162") as technove: | ||
device = await technove.update() | ||
print(device.info.name) | ||
print(device.info.version) | ||
|
||
print(device.info) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This extend our general Ruff rules specifically for the examples | ||
extend = "../pyproject.toml" | ||
|
||
extend-ignore = [ | ||
"T201", # Allow the use of print() in examples | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Asynchronous Python client for TechnoVE.""" | ||
|
||
import asyncio | ||
|
||
from technove import TechnoVE | ||
|
||
|
||
async def main() -> None: | ||
"""Show example on setting the automatic charging feature.""" | ||
async with TechnoVE("192.168.10.162") as technove: | ||
print("Initial value:") | ||
device = await technove.update() | ||
initial_value = device.info.auto_charge | ||
print(initial_value) | ||
|
||
print("Activating auto_charge...") | ||
await technove.set_auto_charge(enabled=True) | ||
# Sleep is needed because the station takes a bit of time to fully | ||
# enable the automatic charging feature. | ||
await asyncio.sleep(2) | ||
device = await technove.update() | ||
print(device.info.auto_charge) | ||
|
||
print("Disabling auto_charge...") | ||
await technove.set_auto_charge(enabled=False) | ||
await asyncio.sleep(2) | ||
device = await technove.update() | ||
print(device.info.auto_charge) | ||
|
||
if device.info.auto_charge != initial_value: | ||
# Sets the initial value back, just to be nice | ||
print("Setting back to initial value...") | ||
await technove.set_auto_charge(enabled=initial_value) | ||
await asyncio.sleep(2) | ||
device = await technove.update() | ||
print(device.info.auto_charge) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Tests for `technove.TechnoVE`.""" | ||
|
||
|
||
import pytest | ||
|
||
from technove import Status, TechnoVEError | ||
|
||
|
||
def test_status_build() -> None: | ||
"""Test status build with a known status code.""" | ||
assert Status.build(67) == Status.PLUGGED_CHARGING | ||
|
||
|
||
def test_status_build_unknown() -> None: | ||
"""Test status build with an unknown status code.""" | ||
with pytest.raises(TechnoVEError): | ||
Status.build(42) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters