Giter VIP home page Giter VIP logo

pidinohomeautomation's Introduction

PiDinoHomeAutomation

##Description

PiDinoHomeAutomation is an open source project under GNU license for HomeAutomation based on Raspberry pi & Arduino.

The main goal of the project is allow easy interaction between different home automation platforms and PiDino. Communication between modules is done over Modbus protocol, you can find more info about Modbus on [Wikipedia] (https://en.wikipedia.org/wiki/Modbus). �Modbus can work over different transport layers, I'm currently using RS-485 in half-duplex mode (This mean than only 2 wires twisted plus ground is required, and usually, local ground is enough). RS-485 uses differential balanced lines, so it can span relatively large distances, up to 1,200 m (4,000 ft), offer high speeds (up to 100 mbps) and noise tolerance.

There are two types of modules, master and slave. All communication is started by the master module, each slave has an unique address and 16 of 16bits local registers. The master module can either read or write on slaves registers.

##Modules

Currently this modules are implemented, the type of the module (master/slave) is denoted in its name.

###RestServer-master

This module, written in Python, offers a REST API with json as body language to interact with all of the slaves.

Dependencies

Can be installed easily from pip

pip install flask minimalmodbus

Usage

Usage: pidino_server.py [options]

Options:
  -h, --help            show this help message and exit
  -c CONF, --config=CONF
                        Use another config file.
  -d DEVS, --devices=DEVS
                        Use another devices file.
  -v, --verbose         Show all logging to stdout.
  --logLevel=LOG_LEVEL  Set the logger level.

There are two configuration files:

Server config

This file controls the basic server functionality and has two sections, Basic and TrustedProxies.

[Basic]
Host:       0.0.0.0
Port:       5001
LogFile:    pidino.log
# 200MB in bytes, 200*1024*1024
LogMaxSize: 209715200

[TrustedProxies]
Enabled: True
Allowed: ["127.0.0.1"]

Devices config

This file list the different devices, its configuration and its registers with read/write permissions.

[heater]
Interface: /dev/ttyUSB0
BaudRate:  19200
ByteSize:  8
Parity:    NONE
StopBits:  1
Timeout:   0.05
Mode:      RTU
Address:   1
Registers: [{"read": true, "write": true}, 
            {"read": true, "write": true}, 
            {"read": true, "write": true}, 
            {"read": true, "write": true}]

[cooler]
Interface: /dev/ttyUSB0
BaudRate:  19200
ByteSize:  8
Parity:    NONE
StopBits:  1
Timeout:   0.05
Mode:      RTU
Address:   2
Registers: [{"read": true, "write": true}]

Current API specification (variables are denoted between %):

Path Method Status Code Body
/%deviceName%/registers/%registerId% GET 200 {"value": %registerValue%}
400 {"msg": "Device %deviceName% not found, check your devices config file"}
401 {"msg": "You are not authorized."}
403 {"msg": "You dont have permission to do that."}
404 {"msg": "Register %registerId% out of index. Device %deviceName% has only %deviceRegisters% registers"}
500 {"msg": "Error trying to read register value. Something went wrong, check server log"}
/%deviceName%/registers/%registerId% POST, PUT 200 {"msg": "register updated successfully"}
400 {"msg": "Device %deviceName% not found, check your devices config file"}
401 {"msg": "You are not authorized."}
403 {"msg": "You dont have permission to do that."}
404 {"msg": "Register %registerId% out of index. Device %deviceName% has only %deviceRegisters% registers"}
500 {"msg": "Error trying to write register value. Something went wrong, check server log"}

pidinohomeautomation's People

Contributors

jvictorsoto avatar

Watchers

 avatar  avatar

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.