Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
domotique [2015/05/29 17:34] – créée madko | domotique [2016/03/21 17:21] (Version actuelle) – [Jeedom sur Raspberry PI 2 ou 3] madko | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Configuration de tellstick duo pour piloter une prise DIO: | + | ====== Jeedom sur Raspberry PI 2 ou 3 ====== |
+ | Avec l' | ||
- | user = " | + | < |
- | group = " | + | pacman -S docker |
- | deviceNode = "/ | + | </ |
- | ignoreControllerConfirmation = " | + | |
- | device {\\ | + | Mettre son utilisateur courant dans le groupe docker (pour éviter sudo). |
- | id = 1\\ | + | |
- | name = " | + | Utilisation de l' |
- | controller = 1\\ | + | |
- | protocol = " | + | < |
- | #model = " | + | docker pull sbeuzit/ |
- | model = " | + | docker run --name data sbeuzit/ |
- | parameters {\\ | + | </ |
- | # devices = "" | + | |
- | house = " | + | Cette image ne sert que pour conserver les données. Il faut ensuite un containeur pour la partie MySQL : |
- | unit = " | + | |
- | # code = "" | + | < |
- | # system = "" | + | docker pull hypriot/ |
- | # units = "" | + | docker run --name jeedom-mysql -e MYSQL_ROOT_PASSWORD=my_mysql_password --volumes-from data -d hypriot/ |
- | # fade = "" | + | </ |
- | }\\ | + | |
- | }\\ | + | Il s'agit de l' |
- | controller {\\ | + | |
- | id = 1\\ | + | Il ne reste plus qu'à lancer le containeur jeedom avec le lien vers nos containeurs précédents : |
- | # name = "" | + | |
- | type = 2\\ | + | < |
- | serial = " | + | docker run -d --link jeedom-mysql: |
+ | </ | ||
+ | |||
+ | A noter le / | ||
+ | |||
+ | ====== Domoticz sur Raspberry PI B+ ====== | ||
+ | |||
+ | Récuperer les sources et les compiler (pas trop lourd même sur un RPI). | ||
+ | |||
+ | Configuration de tellstick duo pour piloter une prise DIO fichier / | ||
+ | |||
+ | < | ||
+ | user = " | ||
+ | group = " | ||
+ | deviceNode = "/ | ||
+ | ignoreControllerConfirmation = " | ||
+ | device { | ||
+ | id = 1 | ||
+ | name = " | ||
+ | controller = 1 | ||
+ | protocol = " | ||
+ | #model = " | ||
+ | model = " | ||
+ | parameters { | ||
+ | # devices = "" | ||
+ | house = " | ||
+ | unit = " | ||
+ | # code = "" | ||
+ | # system = "" | ||
+ | # units = "" | ||
+ | # fade = "" | ||
+ | } | ||
} | } | ||
+ | controller { | ||
+ | id = 1 | ||
+ | # name = "" | ||
+ | type = 2 | ||
+ | serial = " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Quelques tâches en cron pour les tests sur IP: | ||
+ | |||
+ | < | ||
+ | */10 * * * * / | ||
+ | |||
+ | */10 * * * * / | ||
+ | </ | ||
+ | |||
+ | Et le script check_device_online.py: | ||
+ | |||
+ | < | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Date: 25-02-2015 | ||
+ | # Info: Checks the presence of the given device on the network and reports back to domoticz | ||
+ | # URL : https:// | ||
+ | # | ||
+ | |||
+ | import sys | ||
+ | import datetime | ||
+ | import time | ||
+ | import os | ||
+ | import subprocess | ||
+ | import urllib2 | ||
+ | import json | ||
+ | import base64 | ||
+ | |||
+ | # Settings for the domoticz server | ||
+ | domoticzserver=" | ||
+ | domoticzusername = " | ||
+ | domoticzpassword = " | ||
+ | |||
+ | # If enabled. The script will log to the file _.log | ||
+ | # Logging to file only happens after the check for other instances, before that it only prints to screen. | ||
+ | # | ||
+ | log_to_file = True | ||
+ | |||
+ | # The script supports two types to check if another instance of the script is running. | ||
+ | # One will use the ps command, but this does not work on all machine (Synology has problems) | ||
+ | # The other option is to create a pid file named _.pid. The script will update the timestamp | ||
+ | # every interval. If a new instance of the script spawns it will check the age of the pid file. | ||
+ | # If the file doesn' | ||
+ | # Please chose the option you want to use " | ||
+ | check_for_instances = " | ||
+ | |||
+ | # DO NOT CHANGE BEYOND THIS LINE | ||
+ | if len(sys.argv) != 5 : | ||
+ | print ("Not enough parameters. Needs %Host %Switchid %Interval %Cooldownperiod." | ||
+ | sys.exit(0) | ||
+ | |||
+ | device=sys.argv[1] | ||
+ | switchid=sys.argv[2] | ||
+ | interval=sys.argv[3] | ||
+ | cooldownperiod=sys.argv[4] | ||
+ | previousstate=-1 | ||
+ | lastsuccess=datetime.datetime.now() | ||
+ | lastreported=-1 | ||
+ | # | ||
+ | domoticzurl = ' | ||
+ | |||
+ | if check_for_instances.lower() == " | ||
+ | pidfile = sys.argv[0] + ' | ||
+ | if os.path.isfile( pidfile ): | ||
+ | print datetime.datetime.now().strftime(" | ||
+ | if (time.time() - os.path.getmtime(pidfile)) < | ||
+ | print datetime.datetime.now().strftime(" | ||
+ | print datetime.datetime.now().strftime(" | ||
+ | sys.exit(0) | ||
+ | else: | ||
+ | print datetime.datetime.now().strftime(" | ||
+ | else: | ||
+ | open(pidfile, | ||
+ | |||
+ | if check_for_instances.lower() == " | ||
+ | if int(subprocess.check_output(' | ||
+ | print (datetime.datetime.now().strftime(" | ||
+ | sys.exit(0) | ||
+ | |||
+ | def log(message): | ||
+ | print message | ||
+ | if log_to_file == True: | ||
+ | logfile = open(sys.argv[0] + ' | ||
+ | logfile.write(message + " | ||
+ | logfile.close() | ||
+ | |||
+ | def domoticzstatus (): | ||
+ | json_object = json.loads(domoticzrequest(domoticzurl)) | ||
+ | status = 0 | ||
+ | switchfound = False | ||
+ | if json_object[" | ||
+ | for i, v in enumerate(json_object[" | ||
+ | if json_object[" | ||
+ | switchfound = True | ||
+ | if json_object[" | ||
+ | status = 1 | ||
+ | if json_object[" | ||
+ | status = 0 | ||
+ | if switchfound == False: print (datetime.datetime.now().strftime(" | ||
+ | return status | ||
+ | |||
+ | def domoticzrequest (url): | ||
+ | request = urllib2.Request(url) | ||
+ | # | ||
+ | try: | ||
+ | response = urllib2.urlopen(request) | ||
+ | except: | ||
+ | print(" | ||
+ | sys.exit(-1) | ||
+ | else: | ||
+ | return response.read() | ||
+ | |||
+ | log (datetime.datetime.now().strftime(" | ||
+ | |||
+ | lastreported = domoticzstatus() | ||
+ | if lastreported == 1 : | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | if lastreported == 0 : | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | |||
+ | while 1==1: | ||
+ | currentstate = subprocess.call(' | ||
+ | |||
+ | if currentstate == 0 : lastsuccess=datetime.datetime.now() | ||
+ | if currentstate == 0 and currentstate != previousstate and lastreported == 1 : | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | if currentstate == 0 and currentstate != previousstate and lastreported != 1 : | ||
+ | if domoticzstatus() == 0 : | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | domoticzrequest(" | ||
+ | else: | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | lastreported=1 | ||
+ | |||
+ | if currentstate == 1 and currentstate != previousstate : | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | |||
+ | if currentstate == 1 and (datetime.datetime.now()-lastsuccess).total_seconds()> | ||
+ | if domoticzstatus() == 1 : | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | domoticzrequest(" | ||
+ | else: | ||
+ | log (datetime.datetime.now().strftime(" | ||
+ | lastreported=0 | ||
+ | |||
+ | time.sleep (float(interval)) | ||
+ | |||
+ | previousstate=currentstate | ||
+ | if check_for_instances.lower() == " | ||
+ | </ | ||