actor update api for WS

This commit is contained in:
avollkopf 2022-08-31 20:46:27 +02:00
parent 9c6ede13f1
commit ac3c880523
3 changed files with 24 additions and 1 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.0.7.a3"
__version__ = "4.0.7.a4"
__codename__ = "Spring Break"

View file

@ -66,3 +66,11 @@ class ActorController(BasicController):
self.cbpi.push_update("cbpi/actorupdate/{}".format(id), item.to_dict())
except Exception as e:
logging.error("Failed to update Actor {} {}".format(id, e))
async def ws_actor_update(self):
try:
#await self.push_udpate()
self.cbpi.ws.send(dict(topic=self.update_key, data=list(map(lambda x: x.to_dict(), self.data))),self.sorting)
# self.cbpi.push_update("cbpi/actorupdate/{}".format(id), item.to_dict())
except Exception as e:
logging.error("Failed to update Actors {}".format(e))

View file

@ -24,6 +24,21 @@ class ActorHttpEndpoints():
"""
return web.json_response(data=self.controller.get_state())
@request_mapping(path="/ws_update", auth_required=False)
async def http_get_all(self, request):
"""
---
description: Update WS actors
tags:
- Actor
responses:
"204":
description: successful operation
"""
return web.json_response(data=await self.controller.ws_actor_update())
@request_mapping(path="/{id:\w+}", auth_required=False)
async def http_get_one(self, request):
"""