--- /dev/null
+/venv/
+/controlpi_readjson.egg-info/
-# 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.
+++ /dev/null
-"""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)
--- /dev/null
+"""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)
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=[