--- /dev/null
+Copyright (c) 2021 Graph-IT GmbH
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
--- /dev/null
+# Control-Pi-Plugin für Statemachines
+Dieses Paket enthält ein Plugin für das ControlPi-System, mit dem
+Statemachines konfiguriert werden können, die auf Nachrichten des zentralen
+Nachrichten-Busses des ControlPi-Systems reagieren und bei
+Zustands-Wechseln Kommandos/Nachrichten an andere Komponenten des Systems
+schicken.
+
+Die Dokumentation kann unter [doc/index.md](doc/index.md) bzw.
+[https://docs.graph-it.com/graphit/controlpi-plugin](https://docs.graph-it.com/graphit/controlpi-plugin)
+gefunden werden.
--- /dev/null
+{
+ "State": {
+ "plugin": "State"
+ },
+ "WaitCheck": {
+ "plugin": "Wait",
+ "seconds": 1.0
+ },
+ "TriggerStateCheck": {
+ "plugin": "Alias",
+ "from": { "sender": "WaitCheck", "event": "finished" },
+ "to": { "target": "State", "command": "get state" }
+ },
+ "TriggerWaitCheck": {
+ "plugin": "Alias",
+ "from": { "sender": "WaitCheck", "event": "finished" },
+ "to": { "target": "WaitCheck", "command": "wait" }
+ },
+ "WaitOn": {
+ "plugin": "Wait",
+ "seconds": 1.5
+ },
+ "TriggerStateOnOff": {
+ "plugin": "Alias",
+ "from": { "sender": "WaitOn", "event": "finished" },
+ "to": { "target": "State", "command": "set state", "state": false }
+ },
+ "TriggerWaitOnOff": {
+ "plugin": "Alias",
+ "from": { "sender": "WaitOn", "event": "finished" },
+ "to": { "target": "WaitOff", "command": "wait" }
+ },
+ "WaitOff": {
+ "plugin": "Wait",
+ "seconds": 1.5
+ },
+ "TriggerStateOffOn": {
+ "plugin": "Alias",
+ "from": { "sender": "WaitOff", "event": "finished" },
+ "to": { "target": "State", "command": "set state", "state": true }
+ },
+ "TriggerWaitOffOn": {
+ "plugin": "Alias",
+ "from": { "sender": "WaitOff", "event": "finished" },
+ "to": { "target": "WaitOn", "command": "wait" }
+ },
+ "Test Procedure": {
+ "plugin": "Init",
+ "messages": [
+ { "event": "started" },
+ { "target": "WaitOff", "command": "wait" },
+ { "target": "WaitCheck", "command": "wait" },
+ { "event": "stopped" }
+ ]
+ },
+ "Debug Logger": {
+ "plugin": "Log",
+ "filter": [
+ {}
+ ]
+ },
+ "State Change Logger": {
+ "plugin": "Log",
+ "filter": [
+ { "sender": "State", "changed": true }
+ ]
+ }
+}
--- /dev/null
+"""Provide …
+
+TODO: documentation, doctests
+"""
+from controlpi import BasePlugin, Message, PluginConfiguration
+
+
+class Statemachine(BasePlugin):
+ async def _receive(self, message: Message) -> None:
+ send_message = {'sender': self._name}
+ await self._bus.send(send_message)
+
+ def _process_conf(self, conf: PluginConfiguration) -> None:
+ self._bus.register(self._name, sends, receives, self._receive)
+ super()._process_conf(conf)
+
+ async def run(self) -> None:
+ await super().run()
+ await self._bus.send({'sender': self._name})
--- /dev/null
+# Control-Pi-Plugin für Statemachines
+Dieses Paket enthält ein Plugin für das ControlPi-System, mit dem
+Statemachines konfiguriert werden können, die auf Nachrichten des zentralen
+Nachrichten-Busses des ControlPi-Systems reagieren und bei
+Zustands-Wechseln Kommandos/Nachrichten an andere Komponenten des Systems
+schicken.
+
+## Installation
+Eine ausführliche Dokumentation ist in der Dokumentation der
+[ControlPi-Infrastruktur](https://docs.graph-it.com/graphit/controlpi) zu
+finden.
+
+Der Code dieses Plugins kann mit git geclonet werden:
+```sh
+$ git clone git://git.graph-it.com/graphit/controlpi-statemachine.git
+```
+(Falls Zugang zu diesem Server per SSH besteht und Änderungen gepusht
+werden sollen, sollte stattdessen die SSH-URL benutzt werden.)
+
+Dann kann es editierbar in ein virtuelles Environment installiert werden:
+```sh
+(venv)$ pip install --editable <Pfad zum Code-Repository>
+```
+
+Auf dem Raspberry Pi (oder wenn keine Code-Änderungen gewünscht sind) kann
+es auch direkt, ohne einen git-Clone installiert werden:
+```sh
+(venv)$ pip install git+git://git.graph-it.com/graphit/controlpi-statemachine.git
+```
+
+## Benutzung
+…
--- /dev/null
+import setuptools
+
+with open("README.md", "r") as readme_file:
+ long_description = readme_file.read()
+
+setuptools.setup(
+ name="controlpi-statemachine",
+ version="0.1.0",
+ author="Graph-IT GmbH",
+ author_email="info@graph-it.com",
+ description="Control-Pi-Plugin für Statemachines",
+ long_description=long_description,
+ long_description_content_type="text/markdown",
+ url="http://docs.graph-it.com/graphit/controlpi-statemachine",
+ packages=['controlpi.plugins'],
+ classifiers=[
+ "Programming Language :: Python",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+ ],
+)