Allow booting with no sensors attached

This commit is contained in:
Mike Cifelli 2023-07-15 12:20:53 -04:00
parent 95a0f36bfa
commit 6ff7f4fc1b
Signed by: mike
GPG Key ID: 6B08C6BE47D08E4C
3 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -1,2 +1,3 @@
from .mcp9808 import MCP9808
from .mcp9808 import SimulatedMCP9808
from .watersensor import WaterSensor

View File

@ -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