{
+ "TriggerWait2": {
+ "plugin": "Alias",
+ "from": { "sender": "Wait1", "event": "finished" },
+ "to": { "target": "Wait2", "command": "wait" }
+ },
+ "TriggerWait1": {
+ "plugin": "Alias",
+ "from": { "sender": "Wait2", "event": "finished" },
+ "to": { "target": "Wait1", "command": "wait" }
+ },
"Wait1": {
"plugin": "Wait",
"seconds": 1.0
"messages": [
{ "event": "started" },
{ "target": "Wait1", "command": "wait" },
- { "target": "Wait2", "command": "wait" },
{ "event": "stopped" }
]
},
"""Provide utility plugins for all kinds of systems.
-TODO: documentation, doctests, check configurations
-TODO: Keyboard, State, AndState, OrState
+TODO: documentation, doctests, check configurations during _process_conf
+TODO: State, AndState, OrState?
"""
import asyncio
class Alias(BasePlugin):
- async def _alias(self, message):
- alias_message = {"name": self._name}
+ async def _alias(self, message: Message) -> None:
+ alias_message = {}
+ alias_message['sender'] = self._name
+ alias_message.update(self._to)
for key in message:
- if key not in self._aliasfor:
+ if key != 'sender' and key not in self._from:
alias_message[key] = message[key]
await self._bus.send(alias_message)
def _process_conf(self, conf):
- self._aliasfor = conf['aliasfor']
- self._bus.register(conf['aliasfor'], self._alias)
+ self._from = conf['from']
+ self._to = conf['to']
+ self._bus.register(self._name, [self._to], [self._from], self._alias)