Skip to content

Commit e9c23b7

Browse files
committed
Update manual_fixtures.py,
device_list- and notifications-json files are no longer used.
1 parent ea69326 commit e9c23b7

File tree

1 file changed

+6
-53
lines changed

1 file changed

+6
-53
lines changed

scripts/manual_fixtures.py

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import os
66

77

8-
def json_writer(
9-
manual_name: str, all_data: dict, device_list: list[str], notifications: dict
10-
) -> None:
8+
def json_writer(manual_name: str, all_data: dict) -> None:
119
"""Standardized writing json files."""
1210
if not os.path.exists(f"./fixtures/{manual_name}"):
1311
os.makedirs(f"./fixtures/{manual_name}")
@@ -23,73 +21,37 @@ def json_writer(
2321
with open(outfile, "w") as f:
2422
f.write(data + "\n")
2523

26-
outfile = f"./fixtures/{manual_name}/device_list.json"
27-
data = json.dumps(
28-
device_list,
29-
indent=2,
30-
separators=(",", ": "),
31-
sort_keys=False,
32-
default=lambda x: list(x) if isinstance(x, set) else x,
33-
)
34-
with open(outfile, "w") as f:
35-
f.write(data + "\n")
36-
37-
outfile = f"./fixtures/{manual_name}/notifications.json"
38-
data = json.dumps(
39-
notifications,
40-
indent=2,
41-
separators=(",", ": "),
42-
sort_keys=True,
43-
default=lambda x: list(x) if isinstance(x, set) else x,
44-
)
45-
with open(outfile, "w") as f:
46-
f.write(data + "\n")
47-
4824

4925
print("... Crafting m_* fixtures from userdata ...") # noqa: T201
5026

5127
base_adam_manual = "adam_jip"
5228
basefile = f"./fixtures/{base_adam_manual}/all_data.json"
53-
basefile_n = f"./fixtures/{base_adam_manual}/notifications.json"
54-
basefile_d = f"./fixtures/{base_adam_manual}/device_list.json"
5529

5630
io = open(basefile)
5731
base = json.load(io)
58-
io_d = open(basefile_d)
59-
base_d = json.load(io_d)
60-
io_n = open(basefile_n)
61-
base_n = json.load(io_n)
6232

6333
adam_jip = base.copy()
6434

6535
# Change mode to off for "1346fbd8498d4dbcab7e18d51b771f3d"
6636
adam_jip["devices"]["1346fbd8498d4dbcab7e18d51b771f3d"]["mode"] = "off"
6737

68-
json_writer("m_adam_jip", adam_jip, base_d, base_n)
38+
json_writer("m_adam_jip", adam_jip)
6939

7040
### Manual Adam fixtures
7141

7242
base_adam_manual = "adam_plus_anna_new"
7343
basefile = f"./fixtures/{base_adam_manual}/all_data.json"
74-
basefile_d = f"./fixtures/{base_adam_manual}/device_list.json"
75-
basefile_n = f"./fixtures/{base_adam_manual}/notifications.json"
7644

7745
io = open(basefile)
7846
base = json.load(io)
79-
io_d = open(basefile_d)
80-
base_d = json.load(io_d)
81-
io_n = open(basefile_n)
82-
base_n = json.load(io_n)
8347

8448
m_adam_cooling = base.copy()
85-
m_adam_cooling_device_list = base_d.copy()
8649

8750
# Set cooling_present to true
8851
m_adam_cooling["gateway"]["cooling_present"] = True
8952

9053
# Remove device "67d73d0bd469422db25a618a5fb8eeb0" from anywhere
9154
m_adam_cooling["devices"].pop("67d73d0bd469422db25a618a5fb8eeb0")
92-
m_adam_cooling_device_list.remove("67d73d0bd469422db25a618a5fb8eeb0")
9355

9456
# Correct setpoint for "ad4838d7d35c4d6ea796ee12ae5aedf8"
9557
m_adam_cooling["devices"]["ad4838d7d35c4d6ea796ee12ae5aedf8"]["thermostat"][
@@ -110,7 +72,6 @@ def json_writer(
11072
# (following diff, now 2954 is removed)
11173
# Remove device "29542b2b6a6a4169acecc15c72a599b8" from anywhere
11274
m_adam_cooling["devices"].pop("29542b2b6a6a4169acecc15c72a599b8")
113-
m_adam_cooling_device_list.remove("29542b2b6a6a4169acecc15c72a599b8")
11475

11576
# Back at ad48
11677
m_adam_cooling["devices"]["ad4838d7d35c4d6ea796ee12ae5aedf8"]["sensors"][
@@ -123,11 +84,9 @@ def json_writer(
12384
# (again, following diff)
12485
# Remove device "2568cc4b9c1e401495d4741a5f89bee1" from anywhere
12586
m_adam_cooling["devices"].pop("2568cc4b9c1e401495d4741a5f89bee1")
126-
m_adam_cooling_device_list.remove("2568cc4b9c1e401495d4741a5f89bee1")
12787

12888
# Remove device "854f8a9b0e7e425db97f1f110e1ce4b3" from anywhere
12989
m_adam_cooling["devices"].pop("854f8a9b0e7e425db97f1f110e1ce4b3")
130-
m_adam_cooling_device_list.remove("854f8a9b0e7e425db97f1f110e1ce4b3")
13190

13291
# Go for 1772
13392
m_adam_cooling["devices"]["1772a4ea304041adb83f357b751341ff"]["sensors"].pop("setpoint")
@@ -174,7 +133,7 @@ def json_writer(
174133
"intended_boiler_temperature"
175134
] = 17.5
176135

177-
json_writer("m_adam_cooling", m_adam_cooling, m_adam_cooling_device_list, base_n)
136+
json_writer("m_adam_cooling", m_adam_cooling)
178137

179138
### FROM ABOVE
180139

@@ -257,21 +216,15 @@ def json_writer(
257216
"resolution": 0.01,
258217
}
259218

260-
json_writer("m_adam_heating", m_adam_heating, m_adam_cooling_device_list, base_n)
219+
json_writer("m_adam_heating", m_adam_heating)
261220

262221
### ANNA
263222

264223
base_anna_manual = "anna_heatpump_heating"
265224
basefile = f"./fixtures/{base_anna_manual}/all_data.json"
266-
basefile_d = f"./fixtures/{base_anna_manual}/device_list.json"
267-
basefile_n = f"./fixtures/{base_anna_manual}/notifications.json"
268225

269226
io = open(basefile)
270227
base = json.load(io)
271-
io_d = open(basefile_d)
272-
base_d = json.load(io_d)
273-
io_n = open(basefile_n)
274-
base_n = json.load(io_n)
275228
m_anna_heatpump_cooling = base.copy()
276229

277230
# Set cooling_present to true
@@ -335,7 +288,7 @@ def json_writer(
335288
"setpoint_high"
336289
] = 30.0
337290

338-
json_writer("m_anna_heatpump_cooling", m_anna_heatpump_cooling, base_d, base_n)
291+
json_writer("m_anna_heatpump_cooling", m_anna_heatpump_cooling)
339292

340293
### FROM ABOVE
341294

@@ -378,4 +331,4 @@ def json_writer(
378331
"cooling_activation_outdoor_temperature"
379332
] = 25.0
380333

381-
json_writer("m_anna_heatpump_idle", m_anna_heatpump_idle, base_d, base_n)
334+
json_writer("m_anna_heatpump_idle", m_anna_heatpump_idle)

0 commit comments

Comments
 (0)