-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdefault_settings.py
95 lines (80 loc) · 3.4 KB
/
default_settings.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Poupool - swimming pool control software
# Copyright (C) 2019 Cyril Jaquier
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import datetime
from controller.dispatcher import Dispatcher
from controller.mqtt import Mqtt
class FakeDispatcher:
def topics(self):
return []
def main():
dispatcher = Dispatcher()
dispatcher.register(None, None, None, None, None, None)
remaining = list(dispatcher.topics())
missing = []
mqtt = Mqtt.start(FakeDispatcher()).proxy()
mqtt.do_start()
def publish(topic, value):
settings = {"qos": 1, "retain": True}
if topic in remaining:
mqtt.publish(topic, value, **settings)
remaining.remove(topic)
else:
missing.append(topic)
publish("/settings/mode", "halt")
publish("/settings/filtration/duration", 10 * 3600)
publish("/settings/filtration/period", 3)
publish("/settings/filtration/reset_hour", 0)
publish("/settings/filtration/boost_duration", 5 * 60)
publish("/settings/filtration/tank_percentage", 0.1)
publish("/settings/filtration/stir_duration", 2 * 60)
publish("/settings/filtration/stir_period", 2 * 3600)
publish("/settings/filtration/backwash/period", 30)
publish("/settings/filtration/backwash/backwash_duration", 120)
publish("/settings/filtration/backwash/rinse_duration", 60)
publish("/settings/filtration/speed/eco", 1)
publish("/settings/filtration/speed/standby", 0)
publish("/settings/filtration/speed/overflow", 4)
publish("/settings/cover/position/eco", 0)
publish("/settings/tank/force_empty", "0")
publish("/settings/swim/mode", "halt")
publish("/settings/swim/timer", 5)
publish("/settings/swim/speed", 50)
publish("/status/filtration/backwash/last", datetime.datetime.now().strftime("%c"))
publish("/settings/light/mode", "halt")
publish("/settings/heater/setpoint", "3.0")
publish("/settings/heating/enable", "1")
publish("/settings/heating/setpoint", "26.0")
publish("/settings/heating/start_hour", "1")
publish("/settings/heating/min_temp", "15")
publish("/settings/disinfection/ph/enable", "1")
publish("/settings/disinfection/ph/setpoint", "7")
publish("/settings/disinfection/ph/pterm", "1.0")
publish("/settings/disinfection/orp/enable", "1")
publish("/settings/disinfection/orp/setpoint", "600")
publish("/settings/disinfection/orp/pterm", "1.0")
print("\n**** Missing default parameters ***")
[print(t) for t in remaining]
print("\n\n**** Unused default parameters ***")
[print(t) for t in missing]
print()
# Don't stop the client too quickly or not all messages will be published.
import time
time.sleep(1)
mqtt.do_stop()
mqtt.stop()
if __name__ == "__main__":
main()