Skip to content

Commit 3f275ac

Browse files
committed
Added prog for changing a parameter
1 parent 8997712 commit 3f275ac

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tryViCareAPI/setParamViHP.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# ==================================================
2+
# This program can be used to set a single parameter
3+
# ===================================================
4+
from PyViCare.PyViCare import PyViCare
5+
6+
client_id = ""
7+
email = ""
8+
password = ""
9+
10+
# ==== Parameter to be modified ======
11+
circuit = 1
12+
feature = f"heating.circuits.{circuit}.temperature.levels"
13+
property = "max"
14+
command = "setMax"
15+
params = {"temperature": 50.0}
16+
# ====================================
17+
18+
vicare = PyViCare()
19+
vicare.initWithCredentials(email, password, client_id, "token.save")
20+
device = vicare.devices[1]
21+
22+
# Get Value before change
23+
valInit = device.service.getProperty(feature)["properties"][property]["value"]
24+
25+
# Change value
26+
ok = True
27+
try:
28+
res = device.service.setProperty(feature, command, params,)
29+
except Exception as e:
30+
ok = False
31+
32+
# Get Value after change
33+
valFinal = device.service.getProperty(feature)["properties"][property]["value"]
34+
35+
# Print result
36+
print("")
37+
print(f"Feature: {feature}")
38+
print(f"Property: {property}")
39+
print(f"Initial value: {valInit}")
40+
if ok:
41+
print(f"Result: {res}")
42+
else:
43+
print(f"Exception: {e}")
44+
print(f"Final value: {valFinal}")

0 commit comments

Comments
 (0)