Code Monkey home page Code Monkey logo

zytemp_mqtt's Introduction

zytemp-mqtt

This is a MQTT interface for the Holtek USB-zyTemp chipset which is used in inexpensive CO2 monitors, such as co2Meter.com or TFA Dostmann.

Installation

  • Clone the repository

    git clone https://github.com/patrislav1/zytemp_mqtt.git
  • Install the Python module

    sudo pip3 install .
  • Run the install script to create the service user and the systemd service.

    sudo ./install.sh

Configuration

The configuration file can be in $HOME/.config/zytempmqtt/config.yaml or zytempmqtt/config.yaml.

It contains following configuration:

mqtt_host: homeassistant.local  # MQTT server
mqtt_port: 1883                 # MQTT port (default: 1883)
mqtt_username: user             # MQTT username
mqtt_password: pass             # MQTT password
mqtt_client_id: foobar          # MQTT client ID (default: zytemp-mqtt)
mqtt_topic: /foo/bar            # MQTT topic (default: zytemp-mqtt)
friendly_name: aircontrol       # Friendly name for HomeAssistant (default: zytemp-mqtt)
discovery_prefix: homeassistant # Discovery prefix for HomeAssistant (default: homeassistant)
decrypt: False                  # Decrypt data from zyTemp, may be needed for some devices (default: False)

Home Assistant integration

On startup, zytemp-mqtt performs MQTT Discovery so that the sensors magically show up in the Home Assistant system without any manual configuration:

HomeAssistant screenshot

zytemp_mqtt's People

Contributors

patrislav1 avatar zeldovich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zytemp_mqtt's Issues

Compatibility with paho-mqtt >=2.0

Paho-mqtt introduced a callback API version setting as a breaking change in 2.0.

self.client = mqtt.Client(client_id=self.cfg.mqtt_client_id)

Might consider doing something like this

try:
    self.client = mqtt.Client(
        callback_api_version=mqtt.CallbackAPIVersion.VERSION1,
        client_id=self.cfg.mqtt_client_id
    )
except TypeError:  # if running paho-mqtt <2.0
    self.client = mqtt.Client(client_id=self.cfg.mqtt_client_id)

co2meter.com's RAD-0301 requires additional data decoding

When using zytempmqtt with a RAD-0301 from co2meter.com, I get:

INFO:zytemp:Found CO2 sensor at intf. 0, 0001:0006:00, VID=04d9, PID=a052
INFO:zytemp:Using device at 0001:0006:00
INFO:mqtt:connected to ...
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device
DEBUG:zytemp:Unexpected data from device

However, when I add the "decryption" support from https://github.com/vfilimonov/co2meter/blob/master/co2meter/co2meter.py#L197 (and the initialization at https://github.com/vfilimonov/co2meter/blob/master/co2meter/co2meter.py#L147), I get data that parses correctly.

I haven't tried to understand the protocol for this device, which is why I'm submitting this as an issue rather than a PR.. I also don't know why my RAD-0301 seems to require this additional step, even though zytempmqtt's README.md has a link to seemingly the same model (RAD-0301) on co2meter.com's site as a supported device. Maybe my RAD-0301 is an older version?

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.