-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
291 changed files
with
64,515 additions
and
1,222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,12 @@ For an git introduction to git see: [http://gitimmersion.com/](http://gitimmersi | |
|
||
It you want to publish your plugin, get an [github account](https://github.com/users) as soon as possible. | ||
|
||
### Usefull commands | ||
### Useful commands | ||
* __list changes__ since the release with the tag VERSIONTAG: `git log --pretty=format:"%s" <VERSIONTAG>..HEAD` | ||
* __undo commit__ with the id XXXIDXXX: `git reset --hard XXXIDXXX && git push origin develop --force` | ||
* __copy commit__ to current branch: `git cherry-pick <commit>` | ||
|
||
Follow the [commit Atom Feed](https://github.com/mknx/smarthome/commits/develop.atom) | ||
Follow the [commit Atom Feed](https://github.com/smarthomeNG/smarthome/commits/develop.atom) | ||
|
||
### Global settings | ||
* only push the current branch (not all): `git config --global push.default current` | ||
|
@@ -25,13 +25,13 @@ The repositry consist of three main branches: | |
|
||
* __master__: it contains the stable/release code | ||
* __develop__: is the branch where new features and plugins are merged into | ||
* __gh-pages__: this branch contains the SmartHome.py website hostet at: [http://mknx.github.io/smarthome/](http://mknx.github.io/smarthome/) | ||
* __gh-pages__: this branch contains the SmartHomeNG.py website | ||
|
||
The branch setup is based on [this model](http://nvie.com/posts/a-successful-git-branching-model/). | ||
|
||
### Getting the Source | ||
* you could fork the repository on github or | ||
* get the repository: `git clone git://github.com/mknx/smarthome.git` | ||
* get the repository: `git clone https://github.com/smarthomeNG/smarthome.git | ||
* create your own (local) branch (from develop) `git checkout -b myplugin develop` | ||
|
||
## Python Version | ||
|
@@ -41,7 +41,7 @@ You should only use Python =< 3.2 methods. If not make it clear in the documenta | |
Your code should conform to [pep 8](http://www.python.org/dev/peps/pep-0008/). (I'm ignoring "E501 line too long".) | ||
|
||
## Start Coding | ||
* __copy__ the skeleton directory: `cp -r plugins/skeleton plugins/myplugin` | ||
* __copy__ the sample plugin directory: `cp -r dev/sample_plugin plugins/myplugin` | ||
* __edit__ the main file: `vi plugins/myplugin/__init__.py` | ||
|
||
### Tools | ||
|
@@ -71,19 +71,19 @@ In your plugin directory should be a __README.md__ (from the skeleton directory) | |
* changes to plugins from other developers must be checked with the developer. | ||
|
||
### Fork | ||
* Goto [SmartHome Repo](https://github.com/mknx/smarthome) logged in with your username/password. | ||
* Goto [SmartHome Repo](https://github.com/smarthomeNG/smarthome) logged in with your username/password. | ||
* Click on 'fork' in the right upper corner. | ||
* Change to your Terminal and enter `git clone https://USER:[email protected]/USER/smarthome` | ||
* Checkout the develop branch `git checkout develop` | ||
* Change/create a file. | ||
* Add the file `git add FILE` | ||
* Commit the changes with a usefull comment: 'git commit' | ||
* Push your changes to your repository: `git pull && git push` | ||
* Create a pull request on github: base: mknx/develop compare: USER/develop | ||
* Create a pull request on github: base: smarthomeNG/develop compare: USER/develop | ||
|
||
|
||
### Merge | ||
If you think your code is ready for prime time send me a __pull request via github__ or an [email](mailto:[email protected]) with the code. | ||
If you think your code is ready for prime time send me a __pull request via github__ | ||
|
||
Acitve commiters could merge the myplugin branch into develop with: | ||
|
||
|
@@ -96,7 +96,7 @@ Acitve commiters could merge the myplugin branch into develop with: | |
If you have problems pushing, you could check the repo git config. Mine looks like this: | ||
<pre> | ||
[remote "origin"] | ||
url = git@github.com:mknx/smarthome.git | ||
url = https://github.com/smarthomeNG/smarthome | ||
fetch = +refs/heads/*:refs/remotes/origin/* | ||
[branch "master"] | ||
remote = origin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab | ||
######################################################################### | ||
# Copyright 2014 <AUTHOR> <EMAIL> | ||
# Copyright 2016 <name> | ||
######################################################################### | ||
# This file is part of SmartHome.py. http://smarthome.sourceforge.net/ | ||
# This file is part of SmartHomeNG | ||
# https://github.com/smarthomeNG/smarthome | ||
# http://knx-user-forum.de/ | ||
# | ||
# SmartHome.py is free software: you can redistribute it and/or modify | ||
# SmartHomeNG 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, | ||
# SmartHomeNG 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/>. | ||
# along with SmartHomeNG If not, see <http://www.gnu.org/licenses/>. | ||
######################################################################### | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('') | ||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#!/usr/bin/env python3 | ||
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab | ||
######################################################################### | ||
# Copyright 2016 <AUTHOR> <EMAIL> | ||
######################################################################### | ||
# This file is part of SmartHomeNG. | ||
# | ||
# Basic Skeleton for new plugins to run with SmartHomeNG version 1.1 | ||
# upwards. | ||
# | ||
# SmartHomeNG 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. | ||
# | ||
# SmartHomeNG 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 SmartHomeNG. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
######################################################################### | ||
|
||
import logging | ||
from lib.model.smartplugin import SmartPlugin | ||
|
||
# todo | ||
# instead of PluginName you name your plugin | ||
class PluginClassName(SmartPlugin): | ||
""" | ||
Main class of the Plugin. Does all plugin specific stuff and provides | ||
the update functions for the items | ||
""" | ||
|
||
# todo | ||
# change ALLOW_MULTIINSTANCE to true if your plugin will support multiple instances (seldom) | ||
ALLOW_MULTIINSTANCE = False | ||
|
||
# todo | ||
# set the version number of you plugin | ||
# a.b should reflect the version of SmartHomeNG that is first compatible with this | ||
# plugin | ||
# c is the version of your plugin | ||
# a sample plugin with a 23rd revision starting for SmartHomeNG 1.2 would be '1.2.23' | ||
PLUGIN_VERSION = "a.b.c" | ||
|
||
|
||
def __init__(self, sh, *args, **kwargs): | ||
""" | ||
Initalizes the plugin. The parameters describe for this method are pulled from the entry in plugin.conf. | ||
:param sh: The instance of the smarthome object, save it for later references | ||
""" | ||
# attention: | ||
# if your plugin runs standalone, sh will likely be None so do not rely on it later or check it within your code | ||
|
||
self._sh = sh | ||
self.logger = logging.getLogger(__name__) # get a unique logger for the plugin and provide it internally | ||
|
||
# todo: | ||
# put any initialization for your plugin here | ||
|
||
|
||
def run(self): | ||
""" | ||
Run method for the plugin | ||
""" | ||
self.logger.debug("run method called") | ||
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): | ||
""" | ||
Stop method for the plugin | ||
""" | ||
self.logger.debug("stop method called") | ||
self.alive = False | ||
|
||
def parse_item(self, item): | ||
""" | ||
Default plugin parse_item method. Is called when the plugin is initialized. | ||
Selects each item corresponding to its attribute keywords and adds it to an internal array | ||
:param item: The item to process. | ||
""" | ||
# todo | ||
# change 'foo_itemtag' into your attribute name | ||
# you might also check for other attribute names if your plugin supports multiple attributes | ||
if self.has_iattr(item.conf, 'foo_itemtag'): | ||
self.logger.debug("parse item: {0}".format(item)) | ||
|
||
def parse_logic(self, logic): | ||
""" | ||
Default plugin parse_logic method | ||
""" | ||
if 'xxx' in logic.conf: | ||
# self.function(logic['name']) | ||
pass | ||
|
||
def update_item(self, item, caller=None, source=None, dest=None): | ||
""" | ||
Write items values | ||
:param item: item to be updated towards the plugin | ||
:param caller: if given it represents the callers name | ||
:param source: if given it represents the source | ||
:param dest: if given it represents the dest | ||
""" | ||
# todo | ||
# change 'foo_itemtag' into your attribute name | ||
if item(): | ||
if self.has_iattr(item.conf, 'foo_itemtag'): | ||
self.logger("update_item ws called with item '{}' from caller '{}', source '{}' and dest '{}'".format(item, caller, source, dest)) | ||
pass | ||
|
||
# PLEASE CHECK CODE HERE. The following was in the old skeleton.py and seems not to be | ||
# valid any more | ||
# # todo here: change 'plugin' to the plugin name | ||
# if caller != 'plugin': | ||
# logger.info("update item: {0}".format(item.id())) | ||
|
||
|
||
""" | ||
If the plugin is run standalone e.g. for test purposes the follwing code will be executed | ||
""" | ||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s') | ||
# todo | ||
# change PluginClassName appropriately | ||
PluginClassName(None).run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.