Git Product home page Git Product logo

shelly-devices-api's Introduction

shelly_api_get.py

Poll Shelly Relays and write Data to INFLUX Database for further use with i.e. Grafana as in my case.

Currently the script is only fetching the TEMPERATURE data from the Relays. Only the following models if Shelly are supported:

  • Shelly 1L
  • Shelly 1PM
  • Shelly 2.5

Prerequisites

  • Running INFLUX Database

Search documentation for INFLUX setup options on their respective websites.

Required Python3 Modules

The following Python3 Modules need to be installed (either locally or system wide):

  • json
  • urllib.request
  • datetime
  • pytz
  • influxdb
  • argparse

You can you the command:

python3 -m pip install <module>

Some configuration is required

To run this script, some configuration in the script will be needed. Please change the following, found in the script "Global Variables" and "InfluxDB Configuration":

  • Global Variables

    • shellyUsername="CHANGE" -> Username to log into the Shelly Web Interface
    • shellyPassword="CHANGE" -> Password to log into the Shelly Web Interface
  • InfluxDB Configuration

    • databaseHost = "CHANGE" -> Hostname where your InfluxDB is Running
    • databasePort = "CHANGE" -> Port for communication, Typically 8086
    • databaseDatabase = "CHANGE" -> Database name to write to
    • databaseUsername = "CHANGE" -> Username for the Database
    • databasePassword = "CHANGE" -> Password for the Database

Usage

usage: shelly_api_get.py [-h] ip {temp} {1PM,1L,2.5}

positional arguments:
  ip              Shelly IP Address
  {temp}          What data to poll (currently only relay temperature is available)
  {1PM,1L,2.5}  Currently Supported Shelly Devices

optional arguments:
  -h, --help      show this help message and exit

Example

user@server:~ $ python3 shell_api_get.py 10.0.5.170 temp 1L

Automate polling

If you wish to automate the polling, you could use crontab. Example crontab entry:

* * * * * /usr/bin/python3 /home/user/python/test/shelly_api_get.py 10.0.5.170 temp 1L

This entry will run the script each minute and write the data to InfluxDB

shelly-devices-api's People

Contributors

gerbecd-py avatar

Watchers

 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.