Giter Site home page Giter Site logo

lighthome's Introduction

Lighthome - Lightweight Home Automation

This repository contains part of my home automation configuration.

Introduction

Though I'm using Home Assistant on the central server at the heart of my home automation (configuration here), I have various Raspberry Pis and other devices that are an integral part my home automation system.

To keep things on the various devices as lightweight and as portable as possible, I wrote 'lighthome'. It consists of various shell scripts and some simple programs to read/write several sensors. Central in the communication between all devices is the MQTT broker.

Architecture

  • scripts/common/include.sh - Defines common functions, including:
    • mqtt_receiver *[handlers]* - Subscribes to MQTT and registers one or more handler scripts, takes care of reconnect logic in case of failures, parallelisation, and runs asynchronously
    • mqtt_transmitter *[topic] [interval] [sender]* - Takes input and publishes it on MQTT, takes care of reconnect logic in case of failures, parallelisation, and runs asynchronously
    • mqttpub *[topic]* *[payload]*- Publish a single MQTT message
  • handler scripts (scripts/mqtthandlers/*) - Receives MQTT stream on standard input and should invoke scripts that perform the action by calling an action script.
    • These scripts are sourced and everything inside should be run asynchronously!
    • The script doesn't have to deal with MQTT itself, except if it wants to publish feedback (using mqttpub)
  • sender scripts (scripts/mqttsenders/*) - Monitors some device/sensor (preferably via an independent action script or program) and then translates its output for MQTT (standard output)
    • These scripts are run normally, either over and over at a specified interval or as a one-shot script that runs indefinitely by itself.
    • Standard output serves as payload for MQTT (the script doesn't have to deal with MQTT itself)
  • actions scripts and programs (scripts/, programs/) - Perform any action, completely MQTT unaware, can also be invoked independently from command line for low-level testing

I decided on simple shell scripts to act as the glue between components and not opt for another layer in for example Python. In true UNIX-fashion each tool should have a well defined task, be efficient, communicate over standard input and output, and not add any unnecessary complexity. I also tried to separate the MQTT-logic from the logic addressing various sensors, so the latter can also be used independently.

The actual communication with MQTT is done via the excellent mosquitto CLI clients (mosquitto_sub and mosquitto_pub) communicating with the mosquitto daemon running on the main server.

Devices

Raspberry Pi 1 (RaspiOS)

GPIO wiring schematic

Raspberry Pi 2 (RaspiOS)

  • GPIO: 433.92Mhz Transmitter for lights
  • GPIO: Door/window sensors (wired, reed contacts)
  • GPIO: Neopixels LED (WS2812B) for ambilight in living room
  • GPIO: IR LED for remote control of TV/audio
  • GPIO: IR Receiver
  • USB: RFLink Transceiver, 433.92Mhz, based on Arduino Mega

GPIO wiring schematic

Raspberry Pi 3 (RaspiOS)

Raspberry Pi 4 (RaspiOS)

  • GPIO: Neopixels LED (WS2912B)

GPIO wiring schematic

History

Initially I ran Home Assistant on these devices as well, but due to their decision to remove GPIO support and the increased amount of unnecessary bloat which I don't need, I desired to go for a more lightweight approach and just write things from scratch.

lighthome's People

Contributors

proycon 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.