Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	doc/user/source/ideen_kommendes_release.rst
  • Loading branch information
msinn committed Dec 28, 2021
2 parents 0f462a1 + 5580894 commit 201260a
Show file tree
Hide file tree
Showing 2,301 changed files with 123,461 additions and 61,525 deletions.
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,44 @@

![Github Tag](https://img.shields.io/github/v/release/smarthomeng/smarthome?sort=semver)
![Made with Python](https://img.shields.io/badge/made%20with-python-blue.svg)
[![Build Status on TravisCI](https://travis-ci.org/smarthomeNG/smarthome.svg?branch=develop)](https://travis-ci.org/smarthomeNG/smarthome)
[![Build Status on TravisCI](https://travis-ci.com/smarthomeNG/smarthome.svg?branch=master)](https://travis-ci.com/smarthomeNG/smarthome)
[![Join the chat at https://gitter.im/smarthomeNG/smarthome](https://badges.gitter.im/smarthomeNG/smarthome.svg)](https://gitter.im/smarthomeNG/smarthome?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

SmartHomeNG [1] is a software that serves a basis for home automation. It interconnects multiple devices using plugins to access their specific interfaces.
This file contains basic information about the basic directories of SmartHomeNG.
SmartHomeNG [1] ist eine Software die eine Basis für eine Heimautomation bereitstellt. Über Plugins können spezielle Schnittstellen angesprochen und damit die Funktionalität des Gesamtsystems erweitert werden.

Developer documentation ([part of the user documentation](https://www.smarthomeng.de/user/entwicklung/entwicklung.html)) and user documentation ([german](https://www.smarthomeNG.de/user)) can be found on [www.smarthomeNG.de](https://www.smarthomeNG.de)
Auf der ([Webseite des Projektes](https://www.smarthomeNG.de)) kann eine [Benutzerdokumentation](https://www.smarthomeNG.de) eingesehen werden.

Ein [Wiki](https://github.com/smarthomeNG/smarthome/wiki) existiert zumeist in deutscher Sprache.

Die Kernfunktionalität wird alle 6-9 Monate in einem Release erweitert und freigegeben.

## Benutzte Werkzeuge

| Werkzeug | beschreibung |
| --- | :--- |
| <a href="https://www.jetbrains.com/?from=SmartHomeNG"><img src="https://smarthomeng.de/images/pycharm-logo.png" width="80" height="70"></a> | SmartHomeNG wird mit der Pycharm IDE entwickelt. |
| <a href="https://www.jetbrains.com/?from=SmartHomeNG"><img src="https://smarthomeng.de/images/webstorm-logo.png" width="70" height="70"></a> | Das Admin Interface von SmartHomeNG wird mit WebStorm IDE entwickelt. |

## Aktueller Status der Entwicklung

[![Aktuelle Entwicklung](https://travis-ci.com/smarthomeNG/smarthome.svg?branch=develop)](https://travis-ci.com/smarthomeNG/smarthome)


---

# SmartHomeNG and other languages

SmartHomeNG [1] is a software that serves as a basis for home automation. It interconnects multiple devices using plugins to access their specific interfaces.

User documentation ([german](https://www.smarthomeNG.de/user)) and developer documentation ([part of the user documentation](https://www.smarthomeng.de/user/entwicklung/entwicklung.html)) can be found on [www.smarthomeNG.de](https://www.smarthomeNG.de)

Additional information can be found in the [SmartHomeNG Wiki](https://github.com/smarthomeNG/smarthome/wiki).

It is possible to read the documentation with [Google's translation service](https://translate.google.com/translate?hl=&sl=de&tl=en&u=https://www.smarthomeng.de/dev/user/) in other languages as well.

This readme file contains basic information about the root directories of SmartHomeNG for an overview.


## Used Tools

| Tool | Description |
Expand All @@ -25,24 +53,24 @@ Additional information can be found in the [SmartHomeNG Wiki](https://github.com
## Directory Structure

| directory | description|
| --- | :--- |
| --- | :--- |
|bin | the main python file is based here |
|dev | if you plan to create a plugin then this is the folder you want to have a closer look at |
|dev | sample files for creating own plugins and modules |
|doc | Source files for the user- and developer documentation |
|etc | the three basic configuration files smarthome.yaml, module.yaml, plugin.yaml, logic.yaml and logging.yaml are located here, you will edit these files to reflect your basic settings|
|items | put here your own files for your items |
|lib | some more core python modules are in this directory. You won't need to change anything here
|logics | here your logic files are put
|modules | here are all loadable core-modules located (one subdirectory for every module)
|plugins | here are all plugins located (one subdirectory for every plugin). The plugins have to be installed from a separate repository (smarthomeNG/plugins)
|scenes | the scenes are stored here
| tests | The code for the automated travis tests is stored here
|tools | there are some tools which help you for creating an initial configuration
|var | everything that is changed by smarthome is put here, e.g. logfiles, cache, sqlite database etc.
|etc | the five basic configuration files smarthome.yaml, module.yaml, plugin.yaml, logic.yaml and logging.yaml are located here, you need to edit these files to reflect your basic settings |
|items | put your own files for your items here |
|lib | some more core python modules are in this directory. You won't need to change anything here |
|logics | put your own files for your logics here |
|modules | here are all loadable core-modules located (one subdirectory for every module) |
|plugins | here are all plugins located (one subdirectory for every plugin). The plugins have to be installed from a separate repository (smarthomeNG/plugins) |
|scenes | the scenes are stored here |
|tests | the code for the automated travis tests is stored here |
|tools | there are some tools which help you with creating an initial configuration |
|var | everything that is changed by smarthome is put here, e.g. logfiles, cache, sqlite database etc. |

## Some more detailed info on the configuration files

As of Version 1.5 the old conf format will still be valid but will be moved out of the docs since it's deprecated now for some time.
As of Version 1.5 the old conf format will still be valid but is removed from the docs since it's been deprecated now for some time.

### etc/smarthome.yaml
Upon installation you will need to create this file and specify your location.
Expand All @@ -57,7 +85,7 @@ tz: Europe/Berlin
```
### etc/module.yaml
Upon installation you will need to create this file and configure the modules and their parameters. On first start of SmartHomeNG this file is created from ```etc/module.yaml.default```.
Upon installation you will need to create this file and configure the modules and their parameters. On first start of SmartHomeNG this file is created from ```etc/module.yaml.default```, if not already present.

An example is shown below:

Expand All @@ -76,7 +104,7 @@ admin:
```
### etc/plugin.yaml
Upon installation you will need to create this file and configure the plugins and their parameters. On first start of SmartHomeNG this file is created from ```etc/plugin.yaml.default```.
Upon installation you will need to create this file and configure the plugins and their parameters. On first start of SmartHomeNG this file is created from ```etc/plugin.yaml.default```, if not already present.


An example is shown below:
Expand All @@ -93,7 +121,7 @@ database:
cli:
plugin_name: cli
ip: 0.0.0.0
update: True
update: true
websocket:
plugin_name: visu_websocket
Expand Down Expand Up @@ -147,5 +175,5 @@ If you want to read an item call `sh.item.path()` or to set an item `sh.item.pat
```python
# logics/sunset.py
if sh.global.sun(): # if sh.global.sun() == True:
sh.gloabl.sun(False) # set it to False
sh.global.sun(False) # set it to False
```
70 changes: 69 additions & 1 deletion bin/locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,67 @@ global_translations:
'Letztes Update': {'de': '=', 'en': 'Last Update', 'fr': ''}
'Letzter Change': {'de': '=', 'en': 'Last Change', 'fr': ''}

#Translations for lib.scene:
"A second 'scenes' object has been created. There should only be ONE instance of class 'Scenes'!!! Called from: {frame1} ({frame2})":
'de': "Ein zweites Szenenobjekt wurde erzeugt. Es darf jedoch nur EINE Instanz der Klasse 'Szenes' geben!!! Aufgerufen durch: {frame1} ({frame2})"
'en': '='
"Directory '{scenes_dir}' not found. Ignoring scenes.":
'de': "Directory '{scenes_dir}' nicht gefunden. Szenen werden ignoriert."
'en': '='
"Scene {scene}, state {state}: action '{action}' is not a dict":
'de': "Szene {scene}, Status {state}: Action '{action}' ist kein Dictionary"
'en': '='
"Scene {scene}, state {state}: actions are not a list":
'de': "Szene {scene}, Status {state}: Actionen sind keine Liste"
'en': '='
"Reloaded all scenes":
'de': "Alle Szenen neu geladen"
'en': '='
"Problem reading scene file {file}: No .yaml or .conf file found with this name":
'de': "Problem beim lesen der Szenen Datei {file}: Keine .yaml oder .conf Datei mit diesem Namen gefunden"
'en': '='
"Problem evaluating: {value} - {exception}":
'de': "Problem beim berechnen: {value} - {exception}"
'en': '='
"Invalid state '{state}' for scene {scene}":
'de': "Ungültiger Status '{state}' für Szene {scene}"
'en': '='
"Learn set to 'False', because '{rvalue}' != '{value}'":
'de': "Learn auf False gesetzt, weil '{rvalue}' != '{value}'"
'en': '='
"Could not find item or logic '{ditemname}' specified in {file}":
'de': "Item oder Logik '{ditemname}' nicht gefunden. Wurde in {file} spezifiziert"
'en': '='
"unable to get self._scenes['{scenename}']['{action}'][0][2] <- {res}":
'de': "self._scenes['{scenename}']['{action}'][0][2] kann nicht gelesen werden <- {res}"
'en': '='

#Translations for lib.userfunctions:
"Imported userfunctions from '{mmodule}' v{version} - {description}":
'de': "Userfunctions importiert aus '{module}' v{version} - {description}"
'en': '='
"Error importing userfunctions from '{module}': {error}":
'de': "Fehler beim importieren von Userfunctions aus '{module}': {error}"
'en': '='
"Error reloading userfunctions '{module}': Module is not loaded, trying to newly import userfunctions '{module}' instead":
'de': "Fehler beim Reload von Userfunctions '{module}': Modul ist nicht geladen, versuche stattdessen Userfunctions '{module}' neu zu importieren"
'en': '='
"Error reloading userfunctions '{module}': {error} - old version of '{module}' is still active":
'de': "Fehler beim Reload von userfunctions '{module}': {error} - alte Version von '{module}' ist noch aktiv"
'en': '='
"Reloaded userfunctions '{module}'":
'de': "Reload: Userfunctions '{module}' neu geladen"
'en': '='
"Reload: Userfunctions '{module}' do not exist":
'de': "Reload: Userfunctions '{module}' existieren nicht"
'en': '='
"Reload: Loaded new userfunctions '{module}'":
'de': "Reload: Neue Userfunctions '{module}' geladen"
'en': '='
"No userfunctions are loaded, nothing to reload":
'de': "Es existieren keine Userfunctions, es gibt nichts für einen Reload"
'en': '='


lib.shtime_translations:
'defined': {'de': 'definiert', 'en': '='}
Expand Down Expand Up @@ -114,5 +175,12 @@ lib.shtime_translations:
'de': "Aufgerufen mit einem Parameter der nicht vom Typ 'datetime' ist: {dt1}, {dt2}"
'en': '='
"Called with point in time that is earlier than now: {dt}":
'de': 'Aufgerufen mit Zeitpunkt in der Vergangenheit'
'de': 'Aufgerufen mit Zeitpunkt in der Vergangenheit: {dt}'
'en': '='
"Calculating beginning of week based on year {year}, week {week} and offset {offset}":
'de': 'Berechne Wochenstart basierend auf Jahr {year}, Woche {week} und Offset {offset}'
'en': '='
"Calculating length of month based on year {year}, month {month}{debug_month}":
'de': 'Berechne Länge des Monats basierend auf Jahr {year}, Monat {month}{debug_month}'
'en': '='

8 changes: 6 additions & 2 deletions bin/shngversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@
# Update auf 1.8.1a wg. Kennzeichnung des Stands als "nach dem v1.8.1 Release"

# Update auf 1.8.2 wg. Release
# Update auf 1.8.2a wg. Kennzeichnung des Stands als "nach dem v1.8.2 Release"
# Update auf 1.8.2b wg. Erweiterung des Item Loggings"
# Update auf 1.8.2c wg. Wegen Anpassungen an mem-logging / lib.log
# Update auf 1.8.2d Unterstützung für User-Functions

shNG_version = '1.8.2'
shNG_branch = 'master'
shNG_version = '1.8.2d'
shNG_branch = 'develop'

# ---------------------------------------------------------------------------------
FileBASE = None
Expand Down
3 changes: 2 additions & 1 deletion bin/smarthome.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
# https://stackoverflow.com/questions/31469707/changing-the-locale-preferred-encoding-in-python-3-in-windows



#####################################################################
# Read command line arguments
#####################################################################
Expand Down Expand Up @@ -137,12 +138,12 @@
# Import SmartHomeNG Modules
#####################################################################
#import lib.config
#import lib.connection
import lib.daemon
#import lib.item
#import lib.log
#import lib.logic
#import lib.module
#import lib.network
#import lib.plugin
#import lib.scene
#import lib.scheduler
Expand Down
49 changes: 10 additions & 39 deletions dev/sample_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@

import os
import logging
import json
import cherrypy
# import json
# import cherrypy


from lib.model.module import Module
from lib.module import Modules
from lib.shtime import Shtime
from lib.Utils import Utils



class SampleModule(Module):
version = '1.7.0'
version = '1.0.0'
longname = '... module for SmartHomeNG'
port = 0

Expand All @@ -47,8 +49,7 @@ def __init__(self, sh, testparam=''):
self.logger = logging.getLogger(__name__)
self._sh = sh
self.shtime = Shtime.get_instance()
self.logger.debug("Module '{}': Initializing".format(self._shortname))

self.logger.debug(f"Module '{self._shortname}': Initializing")

# Test if http module is loaded (if the module uses http)
# try:
Expand All @@ -63,20 +64,18 @@ def __init__(self, sh, testparam=''):
#
# self._showtraceback = self.mod_http._showtraceback


# get the parameters for the module (as defined in metadata module.yaml):
self.logger.debug("Module '{}': Parameters = '{}'".format(self._shortname, dict(self._parameters)))
self.logger.debug(f"Module '{self._shortname}': Parameters = '{dict(self._parameters)}'")
try:
# self.broker_ip = self._parameters['broker_host']
pass
except KeyError as e:
self.logger.critical(
"Module '{}': Inconsistent module (invalid metadata definition: {} not defined)".format(self._shortname, e))
f"Module '{self._shortname}': Inconsistent module (invalid metadata definition: {e} not defined)")
self._init_complete = False
return

ip = get_local_ipv4_address()

ip = Utils.get_local_ipv4_address() # remove line if `ip` unused

def start(self):
"""
Expand All @@ -87,7 +86,6 @@ def start(self):
"""
pass


def stop(self):
"""
If the module has started threads or uses python modules that created threads,
Expand All @@ -99,33 +97,6 @@ def stop(self):
pass



def get_local_ipv4_address():
"""
Get's local ipv4 address of the interface with the default gateway.
Return '127.0.0.1' if no suitable interface is found
:return: IPv4 address as a string
:rtype: string
"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(('8.8.8.8', 1))
IP = s.getsockname()[0]
except:
IP = '127.0.0.1'
finally:
s.close()
return IP


def translate(s):
# needed for AdminUI
return s


#import socket

#from lib.plugin import Plugins
#from lib.utils import Utils


4 changes: 2 additions & 2 deletions dev/sample_module/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
module:
# Global plugin attributes
classname: SampleModule
version: 1.7.0
sh_minversion: 1.7
version: 1.0.0
sh_minversion: 1.8
# sh_maxversion: # maximum shNG version to use this module (leave empty if latest)
# py_minversion: 3.6 # minimum Python version to use for this module
# py_maxversion: # maximum Python version to use for this module (leave empty if latest)
Expand Down
Loading

0 comments on commit 201260a

Please sign in to comment.