Skip to content
Snippets Groups Projects
Select Git revision
  • c4002e6063a82749a9d5ee31e1f6dae5251aecca
  • main default protected
  • py2-backport
  • tags/release-0.5_final
  • tags/release-0.4_final
  • tags/release-0.4_r2
  • tags/release-0.3
7 results

python

  • Clone with SSH
  • Clone with HTTPS
  • user avatar
    jkerdreu authored
    git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2897 b32b6428-25c9-4566-ad07-03861ab6144f
    c4002e60
    History

    xAAL Python stack

    Requirements

    To install xAAL for Python, you need Python3.

    Un*x like

    Install the following packages:

    • subversion
    • python3-dev
    • python3-setuptools
    • libsodium-dev

    For Debian / Ubuntu users:

    $ apt-get install subversion python3-dev libsodium-dev python3-setuptools gcc
    # recommended
    $ apt-get install python3-venv python3-pip

    Manual Install

    Right now, there is no public release (pip based) of xAAL Python binding, so you have to install things from SVN or archive.

    You can use virtualenv (recommended).

    First build a virtualenv :

    $ python3 -m venv xaal_env

    Everytime, you want to use the binding, you must source the activate script.

    $ source xaal_env/bin/activate

    Download sources from SVN:

    $ svn checkout https://redmine.telecom-bretagne.eu/svn/xaal/code/Python/trunk/ xaal_svn

    First, install the xaal.lib package:

    $ cd xaal_svn/libs/lib/
    $ python setup.py develop

    Install the monitor lib (needed by Dashboard, REST API..)

    $ cd xaal_svn/libs/monitor/
    $ python setup.py develop

    Install the schemas (needed by some devices)

    $ cd xaal_svn/libs/schemas/
    $ python setup.py develop

    Install the tools

    $ cd xaal_svn/apps/tools
    $ python setup.py develop

    You can use the python setup.py install instead of develop, but modification in source files won't be applied, you have to re-install it. Right now, develop is the best option.

    Create the configuration file in your home directory:

    $ mkdir ~/.xaal/
    $ cp xaal_svn/libs/lib/xaal.ini.sample ~/.xaal/xaal.ini
    $ xaal-keygen

    xaal-keygen will compute an key for a given passphrase. Edit the xaal.ini file according to your needs.

    Automatic Install

    Instead of manual installation of each package, you can use the install.py script. This script will install allmost all packages without user interaction.

    Docker

    The docker folder contains an Dockerfile to run the xALL software in a docker container. The Dockerfile use the automatic installation script.

    Tests

    First, you can launch a message dumper with this tools

    $ xaal-dumper
    $ or xaal-tail

    To start an fake lamp:

    $ python -m xaal.dummy.lamp

    To check devices, you can use:

    # search alive devices
    $ xaal-isalive
    
    # search lamp.basic devices
    $ xaal-isalive -t lamp.basic
    
    # search any kind of lamp
    $ xaal-isalive -t lamp.any
    
    # display description / attribute
    $ xaal-info xxxxxxxxxxxxxx <- uuid
    
    # display description / attribute for all devices
    $ xaal-walker
    
    # same but only for lamp devices
    $ xaal-walker -t lamp.any

    To turn on/off the lamp

    # turn on the lamp
    $ xaal-send -d xxxxxxxxxxxxxx -r turn_off
    $ xaal-send -d xxxxxxxxxxxxxx -r turn_on

    Windows

    This code can be used w/ Windows (tested w/ Win10 and Python 3.8). You can build the virtualenv with the same way. To activate the venv, you should run Scriptsactivate.bat. For Powershell users (recommanded), you must tweak the ExecutionPolicy to be able to run Activate.ps1.

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    To install libsodium. You can dowload it here: https://download.libsodium.org/libsodium/releases/ Extract the DLL from the zip file (libsodium-x.y.z-stable-msvc.ziplibsodiumx64Releasevzzzdynamic) in the Win32 DLL folder.

    If everything is fine, you can use exactly the same commands on Un*x and Windows. The xaal-* commands are just renamed with an exe extension (ie: xaal-dumper.exe)

    Issues:

    Right now some gateways won't work on Windows due to missing libaries (openZwave ie)

    Coding style

    Every xAAL program (device, gateway, apps) use a namespace. For example, xaal.rest, or xaal.zwave. By convention, you can run everything just by calling the namespace module.

    # to run the meta data sever:
    $ python -m xaal.metadb
    
    # to run the dashboard (web interface)
    $ python -m xaal.dashboard
    
    # to run the Open Weather Map gateway
    $ python -m xaal.owm

    Of course, you need to install packages first.

    To reduce memory footprint, you can use the xaal-pkgrun command. This tool will register every package on a single Python interpreter.

    # to run aqara and owm gateways:
    $ xaal-pkgrun owm aqara

    Notes

    • If you use xAAL on multiple hosts, take care of the system clock. xAAL use date/time to cypher the messages. If clocks differs, you will receive an error message about a "replay attack". In production, NTP is your best friend. A window of 1 minutes is accepted, but no more.

    FAQ

    • Configuration files are hard to read / edit. Why don't you use YAML or XML for config ?

      First, we need something that support nested config so we can not use ConfigParser. Next, we tested severals YAML packages, but they are really slow to import. We want xAAL stack to load as fast as possible, and importing big packages (like PyYAML) take around 0.5 sec on a Raspy. This is way too much for a simple command-line tools like xaal-info for example. We want to provide a better user experience.