controller implemented and tested
This commit is contained in:
25
energysystem.py
Normal file
25
energysystem.py
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
|
||||
class EnergySystem():
|
||||
def __init__(self):
|
||||
self.components = []
|
||||
|
||||
def add_components(self, *args):
|
||||
for comp in args:
|
||||
self.components.append(comp)
|
||||
|
||||
def get_state_and_store_to_database(self, db):
|
||||
state = {}
|
||||
for comp in self.components:
|
||||
component_state = comp.get_state()
|
||||
state[comp.device_name] = component_state
|
||||
db.store_data(comp.device_name, component_state)
|
||||
|
||||
return state
|
||||
|
||||
def get_component_by_name(self, name):
|
||||
for comp in self.components:
|
||||
if comp.device_name == name:
|
||||
return comp
|
||||
|
||||
Reference in New Issue
Block a user