mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-27 17:28:02 +01:00
change of mqtt payloads for fermenterupdate and fermenterstepupdate
This commit is contained in:
parent
ef67caaa68
commit
28f0ca9779
4 changed files with 26 additions and 5 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.3.2.a7"
|
__version__ = "4.3.2.a8"
|
||||||
__codename__ = "Winter Storm"
|
__codename__ = "Winter Storm"
|
||||||
|
|
||||||
|
|
|
@ -524,6 +524,11 @@ class FermentationController:
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
|
|
||||||
|
def remove_key(self,d, key):
|
||||||
|
r = dict(d)
|
||||||
|
del r[key]
|
||||||
|
return r
|
||||||
|
|
||||||
def push_update(self, key="fermenterupdate"):
|
def push_update(self, key="fermenterupdate"):
|
||||||
|
|
||||||
|
@ -531,7 +536,8 @@ class FermentationController:
|
||||||
self.cbpi.ws.send(dict(topic=key, data=list(map(lambda item: item.to_dict(), self.data))))
|
self.cbpi.ws.send(dict(topic=key, data=list(map(lambda item: item.to_dict(), self.data))))
|
||||||
|
|
||||||
for item in self.data:
|
for item in self.data:
|
||||||
self.cbpi.push_update("cbpi/{}/{}".format(self.update_key,item.id), item.to_dict())
|
fermenters=self.remove_key(item.to_dict(),"steps")
|
||||||
|
self.cbpi.push_update("cbpi/{}/{}".format(self.update_key,item.id), fermenters)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
fermentersteps=self.get_fermenter_steps()
|
fermentersteps=self.get_fermenter_steps()
|
||||||
|
@ -542,6 +548,9 @@ class FermentationController:
|
||||||
for step in fermenter['steps']:
|
for step in fermenter['steps']:
|
||||||
if step['status'] == 'A':
|
if step['status'] == 'A':
|
||||||
self.cbpi.push_update("cbpi/{}/{}/{}".format(key,fermenter['id'],step['id']), step)
|
self.cbpi.push_update("cbpi/{}/{}/{}".format(key,fermenter['id'],step['id']), step)
|
||||||
|
else:
|
||||||
|
self.cbpi.push_update("cbpi/{}/{}/{}".format(key,fermenter['id'],step['id']), "")
|
||||||
|
|
||||||
|
|
||||||
async def call_action(self, id, action, parameter) -> None:
|
async def call_action(self, id, action, parameter) -> None:
|
||||||
logging.info("FermenterStep Controller - call Action {} {}".format(id, action))
|
logging.info("FermenterStep Controller - call Action {} {}".format(id, action))
|
||||||
|
|
|
@ -34,6 +34,11 @@ class SatelliteController:
|
||||||
|
|
||||||
]
|
]
|
||||||
self.tasks = set()
|
self.tasks = set()
|
||||||
|
|
||||||
|
def remove_key(self,d, key):
|
||||||
|
r = dict(d)
|
||||||
|
del r[key]
|
||||||
|
return r
|
||||||
|
|
||||||
async def init(self):
|
async def init(self):
|
||||||
|
|
||||||
|
@ -132,7 +137,8 @@ class SatelliteController:
|
||||||
try:
|
try:
|
||||||
self.fermenter=self.fermentercontroller.get_state()
|
self.fermenter=self.fermentercontroller.get_state()
|
||||||
for item in self.fermenter['data']:
|
for item in self.fermenter['data']:
|
||||||
self.cbpi.push_update("cbpi/{}/{}".format("fermenterupdate",item['id']), item)
|
item_new=self.remove_key(item,"steps")
|
||||||
|
self.cbpi.push_update("cbpi/{}/{}".format("fermenterupdate",item['id']), item_new)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning("Failed to send fermenterupdate via mqtt: {}".format(e))
|
self.logger.warning("Failed to send fermenterupdate via mqtt: {}".format(e))
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,11 @@ class MQTTUtil(CBPiExtension):
|
||||||
self.push_update()
|
self.push_update()
|
||||||
await asyncio.sleep(self.mqttupdate)
|
await asyncio.sleep(self.mqttupdate)
|
||||||
|
|
||||||
|
def remove_key(self,d, key):
|
||||||
|
r = dict(d)
|
||||||
|
del r[key]
|
||||||
|
return r
|
||||||
|
|
||||||
def push_update(self):
|
def push_update(self):
|
||||||
# try:
|
# try:
|
||||||
# self.actor=self.actorcontroller.get_state()
|
# self.actor=self.actorcontroller.get_state()
|
||||||
|
@ -61,8 +66,9 @@ class MQTTUtil(CBPiExtension):
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.fermenter=self.fermentationcontroller.get_state()
|
self.fermenter=self.fermentationcontroller.get_state()
|
||||||
for item in self.fermenter['data']:
|
for item in self.fermenter['data']:
|
||||||
self.cbpi.push_update("cbpi/{}/{}".format("fermenterupdate",item['id']), item)
|
item_new=self.remove_key(item,"steps")
|
||||||
|
self.cbpi.push_update("cbpi/{}/{}".format("fermenterupdate",item['id']), item_new)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue