"save props for steps"

This commit is contained in:
Manuel Fritsch 2021-03-07 23:52:20 +01:00
parent 51c8f82834
commit 7a5e852121
6 changed files with 14 additions and 27 deletions

View file

@ -1 +1 @@
__version__ = "4.0.0.30"
__version__ = "4.0.0.31"

View file

@ -34,9 +34,9 @@ class Props:
return self.__data__[key]
else:
return d
def to_dict(self):
def to_dict(self):
def parse_object(value):
if isinstance(value, Props):
return value.to_dict()
@ -48,7 +48,6 @@ class Props:
return dict((key, parse_object(value)) for (key, value) in self.__data__.items())
@dataclass
class Actor:
id: str = None

View file

@ -67,8 +67,8 @@ class CBPiStep(CBPiBase):
async def on_props_update(self, props):
self.props = {**self.props, **props}
async def save_props(self, props):
pass
async def save_props(self):
await self.cbpi.step.save()
async def push_update(self):
self.cbpi.step.push_udpate()

View file

@ -37,18 +37,17 @@ class StepController:
name = data.get("name")
type = data.get("type")
status = StepState(data.get("status", "I"))
props = data.get("props", {})
props = Props(data.get("props", {}))
try:
type_cfg = self.types.get(type)
clazz = type_cfg.get("class")
instance = clazz(self.cbpi, id, name, Props(props), self.done)
instance = clazz(self.cbpi, id, name, props, self.done)
except Exception as e:
logging.warning("Failed to create step instance %s - %s" % (id, e))
instance = None
return Step(id, name, type=type, status=status, instance=instance, props=Props(props) )
return Step(id, name, type=type, status=status, instance=instance, props=props )
def load(self, startActive=False):
@ -94,7 +93,6 @@ class StepController:
try:
type_cfg = self.types.get(item.type)
clazz = type_cfg.get("class")
item.instance = clazz(self.cbpi, item.id, item.name, item.props, self.done)
except Exception as e:
logging.warning("Failed to create step instance %s - %s " % (item.id, e))
@ -139,6 +137,9 @@ class StepController:
async def next(self):
logging.info("Trigger Next")
print("\n\n\n\n")
print(self.profile)
print("\n\n\n\n")
step = self.find_by_status(StepState.ACTIVE)
if step is not None:
if step.instance is not None:

View file

@ -21,13 +21,7 @@ class DummyActor(CBPiActor):
print("YES!")
await self.cbpi.step.next()
@action("HELLO WORLD", {})
async def helloWorld(self, **kwargs):
print("HELLO WORLD")
self.cbpi.notify(title="HELLO WORLD", message="DO YOU WANT TO START THE NEXT STEP", action=[NotificationAction("YES", self.yes), NotificationAction("NO")])
async def start(self):
await super().start()

View file

@ -11,18 +11,9 @@ import logging
Property.Kettle(label="Kettle")])
class MashStep(CBPiStep):
@action(key="Custom RESET", parameters=[])
async def custom_reset(self, **kwargs):
self.summary = ""
await self.push_update()
@action(key="Custom Action", parameters=[Property.Number(label="Value", configurable=True)])
async def custom_action(self, Value, **kwargs):
self.summary = "VALUE FROM ACTION {}".format(Value)
await self.push_update()
async def on_timer_done(self,timer):
self.summary = ""
await self.next()
@ -54,6 +45,8 @@ class MashStep(CBPiStep):
self.timer.start()
return StepResult.DONE
@parameters([Property.Number(label="Timer", description="Time in Minutes", configurable=True)])
class WaitStep(CBPiStep):