GithubHelp home page GithubHelp logo

mikozak / deconz2mqtt Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 3.0 13 KB

Simple bridge between Conbee (deCONZ websocket API) and MQTT broker

Python 100.00%
mqtt-client deconz conbee websocket python bridge

deconz2mqtt's Introduction

deconz2mqtt

Simple bridge between Conbee (its deCONZ websocket API) and MQTT broker.

deconz2mqtt.py reads deCONZ messages, parses them and converts to MQTT message. Let's see an example, following deCONZ message:

{"e":"changed","id":"3","r":"sensors","state":{"buttonevent":1002,"lastupdated":"2020-01-11T23:35:14"},"t":"event","uniqueid":"00:15:8d:00:02:7c:93:43-01-0006"}

is published to MQTT with topic deconz/sensors/3/state (deconz part of the topic can be configured) and following payload:

{"buttonevent": 1002, "lastupdated": "2020-01-11T23:35:14"}

Installation

You will need

  • deconz2mqtt.py - script which does the job
  • deconz2mqtt.yaml - configuration file
  • Python (at least 3.7)
  • Running deCONZ REST API (at least 2.04.40)
  • Running MQTT broker

Installation steps

  1. Create directory (for example /opt/deconz2mqtt) and put inside deconz2mqtt.py

    cd /opt
    mkdir deconz2mqtt
    cd deconz2mqtt
    curl -o deconz2mqtt.py 'https://raw.githubusercontent.com/mikozak/deconz2mqtt/master/deconz2mqtt.py'
    
  2. Create python virtual environment

    python3 -m venv env
    
  3. Install dependencies

    curl -o requirements.txt 'https://raw.githubusercontent.com/mikozak/deconz2mqtt/master/requirements.txt'
    env/bin/python -m pip install --upgrade pip -r requirements.txt
    
  4. Install configuration file (for example in /etc)

    sudo curl -o /etc/deconz2mqtt.yaml 'https://raw.githubusercontent.com/mikozak/deconz2mqtt/master/deconz2mqtt.yaml'
    
  5. Edit configuration file installed in previous step. You need to verify/update at least two parameters

    • MQTT connection details

      mqtt:
          client:
          uri: "mqtt://localhost"
      
    • deCONZ websocket connection details

      deconz:
          uri: "ws://localhost:8080/ws"
      
  6. Run it

    env/bin/python deconz2mqtt.py --config /etc/deconz2mqtt.yaml
    

Installation as a service

  1. Create system user which will be used to run service process (for the purpose of this instruction user named deconz will be used)

    sudo useradd -r deconz
    
  2. Install service

    sudo curl -o /etc/systemd/system/deconz2mqtt.service 'https://raw.githubusercontent.com/mikozak/deconz2mqtt/master/deconz2mqtt.service'
    
  3. Verify and edit if needed in /etc/systemd/system/deconz2mqtt.service:

    • WorkingDirectory and ExecStart paths are valid (and absolute!)
    • User is correct (equals username created in step 1)
  4. Start service

    sudo systemctl start deconz2mqtt
    

    If you want to start the service automatically after system restart you need to enable it

    sudo systemctl enable deconz2mqtt
    

deconz2mqtt's People

Contributors

mikozak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deconz2mqtt's Issues

question of understanding

Hi Michal

How do you get the Stats from DeConz?
Is it realtime (get status change) or do you ask all the time (e.g every sec) "make pull requests"?

for further questions, can we write emails?

Best regards
Daniel

ConnectionRefusedError [Errno 111]

I'm getting a connection refused error when trying to run the app as described in the steps

ERROR:deconz2mqtt.deconz_message_reader: Can't read message from wbesockets. ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 8080)

I've searched the internet but haven't find a solutions.
What can I do next?

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.