File: set_high_tariff_schedule.py

package info (click to toggle)
python-technove 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 408 kB
  • sloc: python: 653; sh: 5; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 1,446 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Asynchronous Python client for TechnoVE."""

import asyncio

from technove import TechnoVE


async def main() -> None:
    """Show example on setting the max current of a station."""
    async with TechnoVE("192.168.10.162") as technove:
        print("Initial value:")
        device = await technove.update()
        initial_value = device.info.high_tariff_period_active
        print(initial_value)

        print("Activating high tariff schedule...")
        await technove.set_high_tariff_schedule(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.high_tariff_period_active)

        print("Disabling auto_charge...")
        await technove.set_high_tariff_schedule(enabled=False)
        await asyncio.sleep(2)
        device = await technove.update()
        print(device.info.high_tariff_period_active)

        if device.info.high_tariff_period_active != initial_value:
            # Sets the initial value back, just to be nice
            print("Setting back to initial value...")
            await technove.set_high_tariff_schedule(enabled=initial_value)
            await asyncio.sleep(2)
            device = await technove.update()
            print(device.info.high_tariff_period_active)


if __name__ == "__main__":
    asyncio.run(main())