Allow booting with no sensors attached
This commit is contained in:
parent
95a0f36bfa
commit
6ff7f4fc1b
8
main.py
8
main.py
|
@ -11,6 +11,7 @@ from net import templates
|
|||
from net import util
|
||||
from net.config import config
|
||||
from sensors import MCP9808
|
||||
from sensors import SimulatedMCP9808
|
||||
from sensors import WaterSensor
|
||||
|
||||
|
||||
|
@ -18,8 +19,13 @@ class SensorServer(Server):
|
|||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
try:
|
||||
self.mcp = MCP9808(I2C(0))
|
||||
except:
|
||||
self.mcp = SimulatedMCP9808(temperature=37)
|
||||
|
||||
self.waterSensor = WaterSensor(0)
|
||||
self.mcp = MCP9808(I2C(0))
|
||||
self.aio = AdafruitIO()
|
||||
self.ntfy = Ntfy()
|
||||
self.ntp_interval_in_seconds = 60 * 60
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
from .mcp9808 import MCP9808
|
||||
from .mcp9808 import SimulatedMCP9808
|
||||
from .watersensor import WaterSensor
|
||||
|
|
|
@ -251,3 +251,12 @@ class MCP9808(object):
|
|||
part = 0 if i > 7 else 1
|
||||
value = 1 if (cfg[part] & (2**(i % 8))) > 0 else 0
|
||||
print(meanings[i][0] + ": " + meanings[i][1 + value])
|
||||
|
||||
|
||||
class SimulatedMCP9808():
|
||||
|
||||
def __init__(self, temperature):
|
||||
self.temperature = temperature
|
||||
|
||||
def get_temp(self):
|
||||
return self.temperature
|
||||
|
|
Loading…
Reference in New Issue