File: scheduling.py

package info (click to toggle)
tessie-api 0.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308 kB
  • sloc: python: 1,308; sh: 6; makefile: 3
file content (61 lines) | stat: -rw-r--r-- 2,010 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import aiohttp
from typing import Any, Dict
from .tessie_wrapper import tessieRequest


async def set_scheduled_charging(
    session: aiohttp.ClientSession,
    vin: str,
    api_key: str,
    timeMins: int,
    enable: bool = True,
    retry_duration: int = 40,
    wait_for_completion: bool = True,
) -> Dict[str, Any]:
    return await tessieRequest(
        session,
        "GET",
        f"/{vin}/command/set_scheduled_charging",
        api_key,
        params={
            "time": timeMins,
            "enable": str(enable).lower(),
            "retry_duration": retry_duration,
            "wait_for_completion": str(wait_for_completion).lower(),
        },
    )


async def set_scheduled_departure(
    session: aiohttp.ClientSession,
    vin: str,
    api_key: str,
    departure_time_mins: int,
    end_off_peak_time_mins: int,
    enable: bool = False,
    preconditioning_enabled: bool = False,
    preconditioning_weekdays_only: bool = False,
    off_peak_charging_enabled: bool = False,
    off_peak_charging_weekdays_only: bool = False,
    retry_duration: int = 40,
    wait_for_completion: bool = True,
) -> Dict[str, Any]:
    return await tessieRequest(
        session,
        "GET",
        f"/{vin}/command/set_scheduled_departure",
        api_key,
        params={
            "enable": str(enable).lower(),
            "departure_time": departure_time_mins,
            "preconditioning_enabled": str(preconditioning_enabled).lower(),
            "preconditioning_weekdays_only": str(preconditioning_weekdays_only).lower(),
            "off_peak_charging_enabled": str(off_peak_charging_enabled).lower(),
            "off_peak_charging_weekdays_only": str(
                off_peak_charging_weekdays_only
            ).lower(),
            "end_off_peak_time": end_off_peak_time_mins,
            "retry_duration": retry_duration,
            "wait_for_completion": str(wait_for_completion).lower(),
        },
    )