activation working so far
This commit is contained in:
1 parent
148928f88c
commit
af98f90085
9 files changed
+25
-275
No files matched your search
@@ -0,0 +1 @@
|
||||
sensors = [{"pin_int_sda": 8, "type": "ambilight", "pin_int": 8, "pin_int_scl": 9}, {"pin_int": 15, "type": "dht22"}, {"pin_int": 26, "type": "moisture"}]
|
||||
@@ -1 +1 @@
|
||||
config = {"pin": "4628", "password": "95%04-MM", "ssid": "Oppa-95.lan"}
|
||||
config = {"pin": "1234", "password": "95%04-MM", "ssid": "Oppa-95.lan"}
|
||||
@@ -1,4 +1,5 @@
|
||||
import network
|
||||
import json
|
||||
|
||||
|
||||
class DeviceInfo:
|
||||
@@ -58,6 +59,9 @@ class DeviceInfo:
|
||||
'ip_address': self.get_ipaddress(),
|
||||
'token': self.token}
|
||||
|
||||
def config(self):
|
||||
return self._loadConfig()
|
||||
|
||||
def _format_mac(self, mac):
|
||||
# Split the MAC address into pairs of two characters each
|
||||
pairs = [mac[i:i+2] for i in range(0, len(mac), 2)]
|
||||
@@ -65,4 +69,10 @@ class DeviceInfo:
|
||||
formatted_mac = ":".join(pairs)
|
||||
return formatted_mac
|
||||
|
||||
def _loadConfig(self):
|
||||
with open('/gs/config/sensors.py', 'r') as file:
|
||||
json_content = file.read()
|
||||
return json.loads(json_content)
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ class GrowSystemApi:
|
||||
self.base_url = self.device_info.server_url
|
||||
self.connect_wifi(ic.config['ssid'], ic.config['password'])
|
||||
|
||||
# config = self.device_info.config()
|
||||
# print("Config:", config)
|
||||
# print("Test", config['test'])
|
||||
|
||||
def activate(self, config):
|
||||
data = self._get_device_data()
|
||||
data.update({
|
||||
|
||||
+9
-1
@@ -1,5 +1,6 @@
|
||||
from gs.setup import Setup
|
||||
import os
|
||||
import ujson
|
||||
|
||||
|
||||
class GrowSystem:
|
||||
@@ -34,7 +35,14 @@ class GrowSystem:
|
||||
import gs.config.initial_config as ic
|
||||
self.initial_config = ic.config
|
||||
device_config = self.gsapi.activate(self.initial_config)
|
||||
print("Device Config:", device_config)
|
||||
#print("Device Config:", device_config['data'])
|
||||
sensors = device_config['data']['sensors']
|
||||
sensor_configs = []
|
||||
for sensor in sensors:
|
||||
sensor_configs.append(sensor['config'])
|
||||
print(sensor['config'])
|
||||
with open("/gs/config/device_config.py", "w") as f:
|
||||
f.write("sensors = " + ujson.dumps(sensor_configs))
|
||||
|
||||
def _is_config_existing(self):
|
||||
return self._is_file_existing('/gs/config/config.py')
|
||||
|
||||
Reference in new issue
Block a user