setup.py and plugin rename.
authorBenjamin Braatz <bb@bbraatz.eu>
Wed, 23 Aug 2023 04:32:13 +0000 (06:32 +0200)
committerBenjamin Braatz <bb@bbraatz.eu>
Wed, 23 Aug 2023 04:32:13 +0000 (06:32 +0200)
.gitignore [new file with mode: 0644]
README.md
controlpi_plugins/example.py [deleted file]
controlpi_plugins/readjson.py [new file with mode: 0644]
setup.py

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..6ece8bc
--- /dev/null
@@ -0,0 +1,2 @@
+/venv/
+/controlpi_readjson.egg-info/
index a7026c17796ed6484bdb2b305cff2e694db86771..c112267ec8caaca81f4c218fb7424598d89fe890 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,10 +1,12 @@
-# ControlPi Plugin for <PURPOSE>
+# ControlPi Plugin for Reading JSON from a Serial Device
 This distribution package contains a plugin for the
 [ControlPi system](https://docs.graph-it.com/graphit/controlpi), that
-<...>
+opens a serial device, reads lines from it, and just sends them to the
+ControlPi message bus if they can be interpreted as (arbitrary) JSON
+objects/messages.
 
 Documentation (in German) can be found at [doc/index.md](doc/index.md) in
 the source repository and at
-[https://docs.graph-it.com/graphit/controlpi-<NAME>/](https://docs.graph-it.com/graphit/controlpi-<NAME>/).
+[https://docs.graph-it.com/graphit/controlpi-readjson/](https://docs.graph-it.com/graphit/controlpi-readjson/).
 Code documentation (in English) including doctests is contained in the
 source files.
diff --git a/controlpi_plugins/example.py b/controlpi_plugins/example.py
deleted file mode 100644 (file)
index 72284c9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-"""ControlPi Plugin for <PURPOSE>."""
-import asyncio
-
-from controlpi import BasePlugin, Message, MessageTemplate
-from controlpi.baseplugin import JSONSchema
-
-
-class Example(BasePlugin):
-    """ControlPi plugin for <PURPOSE>."""
-
-    CONF_SCHEMA: JSONSchema = {'properties':
-                               {'init': {'type': 'boolean',
-                                         'default': False}},
-                               'required': []}
-
-    def process_conf(self) -> None:
-        """Register bus client."""
-        self._state = self.conf['init']
-        self.bus.register(self.name, 'Example',
-                          [MessageTemplate({'event':
-                                            {'const': 'changed'},
-                                            'state':
-                                            {'type': 'boolean'}}),
-                           MessageTemplate({'state':
-                                            {'type': 'boolean'}})],
-                          [([MessageTemplate({'target':
-                                              {'const': self.name},
-                                              'command':
-                                              {'const': 'get state'}})],
-                            self._get_state)])
-
-    async def _get_state(self, message) -> None:
-        await self.bus.send(Message(self.name, {'state': self._state}))
-
-    async def run(self) -> None:
-        """Run main loop of the plugin."""
-        while True:
-            self._state = not self._state
-            await self.bus.send(Message(self.name, {'event': 'changed',
-                                                    'state': self._state}))
-            await asyncio.sleep(10)
diff --git a/controlpi_plugins/readjson.py b/controlpi_plugins/readjson.py
new file mode 100644 (file)
index 0000000..72284c9
--- /dev/null
@@ -0,0 +1,41 @@
+"""ControlPi Plugin for <PURPOSE>."""
+import asyncio
+
+from controlpi import BasePlugin, Message, MessageTemplate
+from controlpi.baseplugin import JSONSchema
+
+
+class Example(BasePlugin):
+    """ControlPi plugin for <PURPOSE>."""
+
+    CONF_SCHEMA: JSONSchema = {'properties':
+                               {'init': {'type': 'boolean',
+                                         'default': False}},
+                               'required': []}
+
+    def process_conf(self) -> None:
+        """Register bus client."""
+        self._state = self.conf['init']
+        self.bus.register(self.name, 'Example',
+                          [MessageTemplate({'event':
+                                            {'const': 'changed'},
+                                            'state':
+                                            {'type': 'boolean'}}),
+                           MessageTemplate({'state':
+                                            {'type': 'boolean'}})],
+                          [([MessageTemplate({'target':
+                                              {'const': self.name},
+                                              'command':
+                                              {'const': 'get state'}})],
+                            self._get_state)])
+
+    async def _get_state(self, message) -> None:
+        await self.bus.send(Message(self.name, {'state': self._state}))
+
+    async def run(self) -> None:
+        """Run main loop of the plugin."""
+        while True:
+            self._state = not self._state
+            await self.bus.send(Message(self.name, {'event': 'changed',
+                                                    'state': self._state}))
+            await asyncio.sleep(10)
index 13dd6d5a0bb2a51e327716de388fcd3668c8d5df..51e3f5da953f9d7e33d41b46e12e5abeee39b5b3 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -4,16 +4,17 @@ with open("README.md", "r") as readme_file:
     long_description = readme_file.read()
 
 setuptools.setup(
-    name="controlpi-<NAME>",
+    name="controlpi-readjson",
     version="0.1.0",
     author="Graph-IT GmbH",
     author_email="info@graph-it.com",
-    description="ControlPi Plugin for <PURPOSE>",
+    description="ControlPi Plugin for Reading JSON from a Serial Device",
     long_description=long_description,
     long_description_content_type="text/markdown",
-    url="http://docs.graph-it.com/graphit/controlpi-<NAME>",
+    url="http://docs.graph-it.com/graphit/controlpi-readjson",
     packages=["controlpi_plugins"],
     install_requires=[
+        "pyserial-asyncio",
         "controlpi @ git+git://git.graph-it.com/graphit/controlpi.git",
     ],
     classifiers=[