Debian Codegraph @

src/tests/call_json_thermostat.py

raw symbols SCIP
1 """
2 Thermostat Device API Responses
3
4 THERMOSTATS variable is a list of setup_entry's from the device_map
5
6 DETAILS_RESPONSES variable is a dictionary of responses from the API
7 for get_details() methods. The keys are the device types and the
8 values are the responses. The responses are tuples of (response, status)
9
10 METHOD_RESPONSES variable is a defaultdict of responses from the API. This is
11 the FunctionResponse variable from the utils module in the tests dir.
12 The default response is a tuple with the value ({"code": 0, "msg": "success"}, 200).
13
14 The values of METHOD_RESPONSES can be a function that takes a single argument or
15 a static value. The value is checked if callable at runtime and if so, it is called
16 with the provided argument. If not callable, the value is returned as is.
17
18 METHOD_RESPONSES = {
19 'DEV_TYPE': defaultdict(
20 lambda: {"code": 0, "msg": "success"}
21 )
22 }
23
24 # For a function to handle the response
25 def status_response(request_body=None):
26 # do work with request_body
27 return request_body, 200
28
29 METHOD_RESPONSES['DEV_TYPE']['set_status'] = status_response
30
31 # To change the default value for a device type
32
33 METHOD_RESPONSES['DEVTYPE'].default_factory = lambda: {"code": 0, "msg": "success"}
34 """
35 from copy import deepcopy
36 from pyvesync.device_map import thermostat_modules
37 from pyvesync.const import ThermostatConst
38 from defaults import (
39 build_bypass_v2_response,
40 FunctionResponsesV2,
41 )
42
43 THERMOSTATS = [m.setup_entry for m in thermostat_modules]
44 THERMOSTATS_NUM = len(THERMOSTATS)
45
46
47 class ThermostatDefaults:
48 current_temp = 65
49 target_temp = 75
50 humidity = 45
51 work_mode = ThermostatConst.WorkMode.HEAT
52 work_status = ThermostatConst.WorkStatus.HEATING
53 eco_mode = ThermostatConst.EcoType.BALANCE
54 temp_unit = "f"
55 schedule_enabled = "on"
56 away_mode = "off"
57 child_lock = "off"
58 screen_display = "on"
59 outdoor_temp = 600
60 outdoor_humidity = 300
61 filter_life = 100
62 battery_level = 100
63 hvac_state = "idle"
64 compressor_state = "off"
65 fan_state = "off"
66 fan_speed = "auto"
67 fan_speed_level = 1
68 swing_mode = "off"
69 aux_heat_state = "off"
70
71
72 THERMOSTAT_DETAILS: dict[str, dict] = {
73 "LTM-A401S-WUS": {
74 "supportMode": [0, 1, 2, 3, 5],
75 "workMode": 3,
76 "workStatus": 2,
77 "fanMode": 1,
78 "fanStatus": 1,
79 "routineRunningId": 2,
80 "tempUnit": "f",
81 "temperature": 75.570000,
82 "humidity": 56,
83 "heatToTemp": 60,
84 "coolToTemp": 70,
85 "lockStatus": False,
86 "scheduleOrHold": 2,
87 "holdEndTime": 1696033274,
88 "holdOption": 5,
89 "deadband": 4,
90 "safetyTempLow": "40.00",
91 "safetyTempHigh": "100.00",
92 "ecoType": 3,
93 "alertStatus": 2,
94 "routines": [
95 {"name": "Home", "routineId": 2},
96 {"name": "Away", "routineId": 1},
97 {"name": "Sleep", "routineId": 3},
98 ],
99 },
100 }
101 """Dictionary with setup_entry as the key and the value being the result object of
102 the device response from the get_details API for thermostats."""
103
104
105 DEVICE_DETAILS = {
106 "LTM-A401S-WUS": build_bypass_v2_response(inner_result=THERMOSTAT_DETAILS["LTM-A401S-WUS"]),
107 }
108
109 METHOD_RESPONSES = {
110 "LTM-A401S-WUS": deepcopy(FunctionResponsesV2)
111 }