#!/usr/bin/env python3
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
#########################################################################
# Copyright 2013 KNX-User-Forum e.V. http://knx-user-forum.de/
#########################################################################
# This file is part of SmartHome.py. http://mknx.github.io/smarthome/
#
# SmartHome.py is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SmartHome.py is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SmartHome.py. If not, see <http://www.gnu.org/licenses/>.
#########################################################################
import logging
logger = logging.getLogger('')
[docs]class AsyncPlugin():
"""This is an example plugin for asynchronus TCP communication."""
def __init__(self, smarthome):
self._sh = smarthome
def run(self):
self.alive = True
# if you want to create child threads, do not make them daemon = True!
# They will not shutdown properly. (It's a python bug)
def stop(self):
self.alive = False
def parse_item(self, item):
if 'plugin_attr' in item.conf:
logger.debug("parse item: {0}".format(item))
return self.update_item
else:
return None
def parse_logic(self, logic):
if 'xxx' in logic.conf:
# self.function(logic['name'])
pass
def update_item(self, item, caller=None, source=None, dest=None):
if caller != 'plugin':
logger.info("update item: {0}".format(item.id()))
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
myplugin = AsyncPlugin('smarthome-dummy')
myplugin.run()