Code Monkey home page Code Monkey logo

cozify-temp's Introduction

cozify-temp

Pull sensor data from Cozify Hub into InfluxDB. At current temperature & humidity data is supported but expanding that is trivial.

Authentication and other Cozify details are handled by python-cozify bindings developed separately: github.com/Artanicus/python-cozify but this repo acts as an official example.

Installation

If you just want to use it:

pip3 install cozifytemp
cozifytemp-single-sample # perform the first time authentication and create a default config. Storage will fail if you don't have a local InfluxDB instance!
# edit ~/.config/cozify-temp/influxdb.cfg to match your infuxdb location if needed
cozifytemp-sample-loop # pull & store data in a loop.

If you want to experiment with the code:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3 -
git clone https://github.com/Artanicus/cozify-temp
cd cozify-temp
poetry install
poetry run cozifytemp-single-sample
poetry run cozifytemp-sample-loop

Configuration

  • For storage, create a InfluxDB bucket called for example cozify. You will also need to configure your organization and generate a token that has write access to the bucket.
  • The easiest way is to use the web interface of InfluxDB 2.0 by navigating to http://localhost:8086 or which ever hostname your InfluxDB server is hosted at.
  • Run cozifytemp-single-sample. It won't work but you'll generate the default config to modify.
  • Edit ~/.config/cozify-temp/influxdb.cfg to include your DB url, token, organization and bucket names.
  • Test connection by running cozifytemp-single-sample to get a single snapshot and push it to InfluxDB. The single-sample script is more naive but simpler to get started with.
  • if a single sample was fine, run cozifytemp-sample-loop to get and push data on a 60s interval. The loop script is more robust than the single sample and is usable as a systemd daemon.
  • To explore all options run cozifytemp-sample-loop --help

Docker

The image is published on GitHub at ghcr.io/artanicus/cozify-temp As with other methods of running, first run a single sample run to init config, edit the generated infuxdb config and then run the long-term sampler.

docker pull ghcr.io/artanicus/cozify-temp:latest
docker run -v /path/to/persistent/config:/root/.config/ -it cozify-temp:latest cozifytemp-single-sample # interactive run to initialize config & authenticate
docker run -v /path/to/persistent/config:/root/.config/ cozify-temp:latest # long term sampler

example Grafana graphs

cozify-temp's People

Contributors

dependabot[bot] avatar jinnatar avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ik-12

cozify-temp's Issues

storage module ignores timestamp

Read multisensor values are assumed to be valid as of the time of read. The sensor blob does contain a timestamp that may indicate when the data was read, so storing with that timestamp instead of at time of read would provide more accurate data.

Bucket and organization are not read from config file

Thank you for an excellent utility! However, I noticed a small glitch:

Row 54 of cozifytemp/storage.py should probably read as:

    write_api.write(c.config['Storage']['bucket'], c.config['Storage']['organization'], sequence)

And you might want to remove the hardcode variables from rows 7-9.

I create a PR for this.

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.