Coder Social home page Coder Social logo

x10_any's Introduction

x10_any

Wrapper module to control X10 devices.

image

Table of Contents

Information

Initial focus is supporting:

Implemented in pure Python. Known to work with:

  • Python 2.7
  • Python 3.4.4
  • Python 3.5

Getting Started

To get started and install the latest version from PyPi:

pip install x10_any
# Or latest from source code via; pip install git+https://github.com/clach04/x10_any.git

If installing/working with a source checkout issue:

pip install -r requirements.txt

NOTE Debian/Ubuntu/Rasbian can install system packages instead of using pip via:

sudo apt-get install python-serial
sudo apt-get install python2-serial

Then run tests via:

python -m x10_any.test.tests

Serial Port Permissions under Linux

Under Linux most users do not have serial port permissions, either:

  • give user permission (e.g. add to group "dialout") - RECOMMENDED
  • run this demo as root - NOT recommended!

Giver user dialout (serial port) access:

# NOTE requires logout/login to take effect
sudo usermod -a -G dialout $USER

Sample

Mochad:

import x10_any

dev = x10_any.MochadDriver()
dev.x10_command('A', 1, x10_any.ON)
dev.x10_command('A', 1, x10_any.OFF)

Firecracker:

import logging

log = logging.getLogger('x10_any')
logging.basicConfig()  # TODO include function name/line numbers in log
#log.setLevel(level=logging.INFO)
log.setLevel(level=logging.DEBUG)

import x10_any

dev = x10_any.FirecrackerDriver()
#dev = x10_any.FirecrackerDriver('COM11')
#dev = x10_any.FirecrackerDriver('/dev/ttyUSB0')
house_code = 'A'
unit_code = 1
dev.x10_command(house_code, unit_code, x10_any.ON)
dev.x10_command(house_code, unit_code, x10_any.OFF)

Serial Port Device names under Linux

See http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/ for notes on using udevadm to determine serial number and adding entries to /etc/udev/rules.d/99-usb-serial.rules for persistent devicenames if using multiple usb serial adapters.

x10_any's People

Contributors

clach04 avatar

Stargazers

 avatar Aric Renzo avatar  avatar Mark Traverse avatar

Watchers

 avatar James Cloos avatar Mark Traverse avatar  avatar

x10_any's Issues

x10_any/cm17a.py is not thread safe

Simple test case (note requires hardware) will silently fail, devices will not change state:

#!/usr/bin/env python3

import threading

import x10_any

#x10_any.default_logger.setLevel(x10_any.logging.DEBUG) # DEBUG


class X10(threading.Thread):
    def __init__(self, house_code, house_num):
        threading.Thread.__init__(self)
        self.house_code = house_code
        self.house_num = house_num
        #print('%r' % ((self.house_code, self.house_num),))

    def run(self):
        # TODO use same device, probably not?
        dev = x10_any.FirecrackerDriver()
        #dev = x10_any.FirecrackerDriver('COM11')
        #dev = x10_any.FirecrackerDriver('/dev/ttyUSB0')

        #print('%r ON' % ((self.house_code, self.house_num),))
        #print('%r OFF' % ((self.house_code, self.house_num),))
        dev.x10_command(self.house_code, self.house_num, x10_any.ON)
        dev.x10_command(self.house_code, self.house_num, x10_any.OFF)


# TODO there are better ways than this....

c4 = X10('C', 4)
c6 = X10('C', 6)

c4.start()
c6.start()

# wait to stop
"""
c4.join()
c6.join()
"""

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.