Example #1
0
import asyncio

from cbpi.api import parameters, Property, action
from cbpi.api.step import StepResult, CBPiStep
from cbpi.api.timer import Timer
from datetime import datetime
import time
from voluptuous.schema_builder import message
from cbpi.api.dataclasses import NotificationAction, NotificationType


@parameters([
    Property.Number(label="Timer",
                    description="Time in Minutes",
                    configurable=True),
    Property.Number(label="Temp", configurable=True),
    Property.Sensor(label="Sensor"),
    Property.Kettle(label="Kettle")
])
class MashStep(CBPiStep):
    async def on_timer_done(self, timer):
        self.summary = ""
        await self.next()

    async def on_timer_update(self, timer, seconds):
        self.summary = Timer.format_time(seconds)
        await self.push_update()

    async def on_start(self):
        if self.timer is None:
            self.timer = Timer(int(self.props.Timer) * 60,
Example #2
0
    async def on_stop(self):
        await self.timer.stop()
        self.summary = ""
        await self.push_update()

    async def run(self):
        while self.running == True:
            await asyncio.sleep(1)
            if self.timer.is_running is not True:
                self.timer.start()
                self.timer.is_running = True

        return StepResult.DONE

@parameters([Property.Number(label="Temp", configurable=True),
             Property.Sensor(label="Sensor"),
             Property.Kettle(label="Kettle"),
             Property.Text(label="Notification",configurable = True, description = "Text for notification when Temp is reached"),
             Property.Select(label="AutoMode",options=["Yes","No"], description="Switch Kettlelogic automatically on and off -> Yes")])
class MashInStep(CBPiStep):

    async def NextStep(self, **kwargs):
        await self.next()

    async def on_timer_done(self,timer):
        self.summary = ""
        self.kettle.target_temp = 0
        await self.push_update()
        if self.AutoMode == True:
            await self.setAutoMode(False)
Example #3
0
        await self.timer.stop()
        self.summary = ""
        await self.push_update()

    async def run(self):
        while self.running == True:
            await asyncio.sleep(1)
            if self.timer.is_running is not True:
                self.timer.start()
                self.timer.is_running = True

        return StepResult.DONE


@parameters([
    Property.Number(label="Temp", configurable=True),
    Property.Sensor(label="Sensor"),
    Property.Text(label="Notification",
                  configurable=True,
                  description="Text for notification when Temp is reached"),
    Property.Select(
        label="AutoMode",
        options=["Yes", "No"],
        description="Switch Fermenterlogic automatically on and off -> Yes")
])
class FermenterTargetTempStep(CBPiFermentationStep):
    async def NextStep(self, **kwargs):
        if self.shutdown != True:
            await self.next(self.fermenter.id)
            return StepResult.DONE
Example #4
0
class MQTTActor(CBPiActor):

    # Custom property which can be configured by the user
    @action("Set Power",
            parameters=[
                Property.Number(label="Power",
                                configurable=True,
                                description="Power Setting [0-100]")
            ])
    async def setpower(self, Power=100, **kwargs):
        self.power = int(Power)
        if self.power < 0:
            self.power = 0
        if self.power > 100:
            self.power = 100
        await self.set_power(self.power)

    def __init__(self, cbpi, id, props):
        super(MQTTActor, self).__init__(cbpi, id, props)

    async def on_start(self):
        self.topic = self.props.get("Topic", None)
        self.power = 100
        await self.off()
        self.state = False

    async def on(self, power=None):
        if power is not None:
            if power != self.power:
                power = min(100, power)
                power = max(0, power)
                self.power = round(power)
        await self.cbpi.satellite.publish(
            self.topic, json.dumps({
                "state": "on",
                "power": self.power
            }), True)
        self.state = True
        pass

    async def off(self):
        self.state = False
        await self.cbpi.satellite.publish(
            self.topic, json.dumps({
                "state": "off",
                "power": self.power
            }), True)
        pass

    async def run(self):
        while self.running:
            await asyncio.sleep(1)

    def get_state(self):
        return self.state

    async def set_power(self, power):
        self.power = round(power)
        if self.state == True:
            await self.on(power)
        else:
            await self.off()
        await self.cbpi.actor.actor_update(self.id, power)
        pass
Example #5
0
        await self.timer.stop()
        self.summary = ""
        await self.push_update()

    async def run(self):
        while self.running == True:
            await asyncio.sleep(1)
            if self.timer.is_running is not True:
                self.timer.start()
                self.timer.is_running = True

        return StepResult.DONE


@parameters([
    Property.Number(label="Temp", configurable=True),
    Property.Sensor(label="Sensor"),
    Property.Kettle(label="Kettle"),
    Property.Text(label="Notification",
                  configurable=True,
                  description="Text for notification hen Temp is reached"),
    Property.Select(
        label="AutoMode",
        options=["Yes", "No"],
        description="Switch Kettlelogic automatically on and off -> Yes")
])
class MashInStep(CBPiStep):
    async def NextStep(self, **kwargs):
        await self.next()

    async def on_timer_done(self, timer):