change of mqtt payloads for fermenterupdate and fermenterstepupdate

This commit is contained in:
avollkopf 2024-02-22 19:45:06 +01:00
parent ef67caaa68
commit 28f0ca9779
4 changed files with 26 additions and 5 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.3.2.a7"
__version__ = "4.3.2.a8"
__codename__ = "Winter Storm"

View file

@ -524,6 +524,11 @@ class FermentationController:
except Exception as 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"):
@ -531,7 +536,8 @@ class FermentationController:
self.cbpi.ws.send(dict(topic=key, data=list(map(lambda item: item.to_dict(), 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
else:
fermentersteps=self.get_fermenter_steps()
@ -542,6 +548,9 @@ class FermentationController:
for step in fermenter['steps']:
if step['status'] == 'A':
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:
logging.info("FermenterStep Controller - call Action {} {}".format(id, action))

View file

@ -34,6 +34,11 @@ class SatelliteController:
]
self.tasks = set()
def remove_key(self,d, key):
r = dict(d)
del r[key]
return r
async def init(self):
@ -132,7 +137,8 @@ class SatelliteController:
try:
self.fermenter=self.fermentercontroller.get_state()
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:
self.logger.warning("Failed to send fermenterupdate via mqtt: {}".format(e))

View file

@ -37,6 +37,11 @@ class MQTTUtil(CBPiExtension):
self.push_update()
await asyncio.sleep(self.mqttupdate)
def remove_key(self,d, key):
r = dict(d)
del r[key]
return r
def push_update(self):
# try:
# self.actor=self.actorcontroller.get_state()
@ -61,8 +66,9 @@ class MQTTUtil(CBPiExtension):
pass
try:
self.fermenter=self.fermentationcontroller.get_state()
for item in self.fermenter['data']:
self.cbpi.push_update("cbpi/{}/{}".format("fermenterupdate",item['id']), item)
for item in self.fermenter['data']:
item_new=self.remove_key(item,"steps")
self.cbpi.push_update("cbpi/{}/{}".format("fermenterupdate",item['id']), item_new)
except Exception as e:
logging.error(e)
pass