8
8
9
9
10
10
board = Automation2040W ()
11
+ isMini = False
12
+
13
+ # Uncomment for Automation2040WMini
14
+ '''
15
+ from automation import Automation2040WMini
16
+ board = Automation2040WMini()
17
+ isMini = True
18
+ '''
11
19
12
20
13
21
def status_handler (mode , status , ip ):
14
22
15
23
print ("Network: {}" .format (WIFI_CONFIG .SSID ))
16
24
status_text = "Connecting..."
17
- board .conn_led (20.0 )
25
+ board .conn_led (20 )
18
26
if status is not None :
19
27
if status :
20
28
status_text = "Connection successful!"
@@ -72,7 +80,9 @@ def post(self, data):
72
80
if 'two' in data .keys ():
73
81
board .output (1 , int (data ['two' ]))
74
82
if 'three' in data .keys ():
75
- board .output (2 , int (data ['three' ]))
83
+ if (not isMini ):
84
+ board .output (2 , int (data ['three' ]))
85
+
76
86
return {'message' : 'outputs updated' }, 201
77
87
78
88
@@ -82,7 +92,10 @@ def not_exists(self):
82
92
return {'message' : 'no data provided' }, 404
83
93
84
94
def get (self , data ):
85
- return {"one" : board .read_input (0 ), "two" : board .read_input (1 ), "three" : board .read_input (2 ), "four" : board .read_input (3 )}, 201
95
+ if (not isMini ):
96
+ return {"one" : board .read_input (0 ), "two" : board .read_input (1 ), "three" : board .read_input (2 ), "four" : board .read_input (3 )}, 201
97
+ else :
98
+ return {"one" : board .read_input (0 ), "two" : board .read_input (1 ), "three" : "N/A" , "four" : "N/A" }, 201
86
99
87
100
def post (self , data ):
88
101
return {'message' : 'outputs updated' }, 201
@@ -118,21 +131,28 @@ def not_exists(self):
118
131
return {'message' : 'no data provided' }, 404
119
132
120
133
def get (self , data ):
134
+
121
135
if 'one' in data .keys ():
122
- board .output (0 , bool (data ['one' ]))
136
+ print (int (data ['one' ]))
137
+ board .output (0 , bool (int (data ['one' ])))
123
138
if 'two' in data .keys ():
124
- board .output (1 , bool (data ['two' ]))
139
+ board .output (1 , bool (int ( data ['two' ]) ))
125
140
if 'three' in data .keys ():
126
- board .output (2 , bool (data ['three' ]))
127
- return {"one" : bool (board .output (0 )), "two" : bool (board .output (1 )), "three" : bool (board .output (2 ))}, 201
141
+ if (not isMini ):
142
+ board .output (2 , bool (int (data ['three' ])))
143
+ if (not isMini ):
144
+ return {"one" : bool (board .output (0 )), "two" : bool (board .output (1 )), "three" : bool (board .output (2 ))}, 201
145
+ else :
146
+ return {"one" : bool (board .output (0 )), "two" : bool (board .output (1 )), "three" : "N/A" }, 201
128
147
129
148
def post (self , data ):
130
149
if 'one' in data .keys ():
131
- board .output (0 , int (data ['one' ]))
150
+ board .output (0 , bool ( int (data ['one' ]) ))
132
151
if 'two' in data .keys ():
133
- board .output (1 , int (data ['two' ]))
152
+ board .output (1 , bool ( int (data ['two' ]) ))
134
153
if 'three' in data .keys ():
135
- board .output (2 , int (data ['three' ]))
154
+ if (not isMini ):
155
+ board .output (2 , int (data ['three' ]))
136
156
return {'message' : 'outputs updated' }, 201
137
157
138
158
@@ -143,20 +163,30 @@ def not_exists(self):
143
163
144
164
def get (self , data ):
145
165
if 'one' in data .keys ():
146
- board .relay (0 , int (data ['one' ]))
166
+ if (not isMini ):
167
+ board .relay (0 , int (data ['one' ]))
168
+ else :
169
+ board .relay (int (data ['one' ]))
147
170
if 'two' in data .keys ():
148
- board .relay (1 , int (data ['two' ]))
171
+ if (not isMini ):
172
+ board .relay (1 , int (data ['two' ]))
149
173
if 'three' in data .keys ():
150
- board .relay (2 , int (data ['three' ]))
151
- return {"one" : board .relay (0 ), "two" : board .relay (1 ), "three" : board .relay (2 )}, 201
174
+ if (not isMini ):
175
+ board .relay (2 , int (data ['three' ]))
176
+ if (not isMini ):
177
+ return {"one" : bool (board .relay (0 )), "two" : bool (board .relay (1 )), "three" : bool (board .relay (2 ))}, 201
178
+ else :
179
+ return {"one" : bool (board .relay ()), "two" : "N/A" , "three" : "N/A" }, 201
152
180
153
181
def post (self , data ):
154
182
if 'one' in data .keys ():
155
183
board .relay (0 , int (data ['one' ]))
156
184
if 'two' in data .keys ():
157
- board .relay (1 , int (data ['two' ]))
185
+ if (not isMini ):
186
+ board .relay (1 , int (data ['two' ]))
158
187
if 'three' in data .keys ():
159
- board .relay (2 , int (data ['three' ]))
188
+ if (not isMini ):
189
+ board .relay (2 , int (data ['three' ]))
160
190
return {'message' : 'outputs updated' }, 201
161
191
162
192
0 commit comments