GithubHelp home page GithubHelp logo

neoacheron / homeassistant-greenchoice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jessevl/homeassistant-greenchoice

0.0 1.0 0.0 22 KB

This is a Home Assistant custom component that connects to the Greenchoice API

License: MIT License

Python 100.00%

homeassistant-greenchoice's Introduction

Home Assistant Greenchoice Sensor

hacs_badge

This is a Home Assistant custom component (sensor) that connects to the Greenchoice API to retrieve current usage data (daily meter data).

The sensor will check every hour if a new reading can be retrieved but Greenchoice practically only gives us one reading a day over this API. The reading is also delayed by 1 or 2 days (this seems to vary). The sensor will give you the date of the reading as an attribute.

Install:

  1. Search for 'greenchoice' in HACS. OR Place the 'greenchoice' folder in your 'custom_compontents' directory if it exists or create a new one under your config directory.
  2. The Greenchoice API can theoretically have multiple contracts under one user account, so we need to figure out the ID for the contract. We will need to manually use the Greenchoice API to retrieve this using a tool like Postman.
    1. Send a POST request to https://app.greenchoice.nl/token with the following x-www-form-urlencoded body: grant_type=password&client_id=MobileApp&client_secret=A6E60EBF73521F57&username=[youusername]&password=[yourpassword]. You will retrieve a token.
    2. Now send a GET request to https://app.greenchoice.nl/api/v1/klant/getovereenkomsten with the token you've just retrieved in the header "Authorization":"Bearer [yourtoken]". You will now get a list of all contracts (probably just one) and their IDs.
  3. Add the component to your configuration.yaml, an example of a proper config entry:
sensor:
  - platform: greenchoice
    name: meterstanden
    password: !secret greenchoicepass
    username: !secret greenchoiceuser
    overeenkomst_id: !secret greenchoicecontract

Alternative to Postman:

  1. It's possible to retrieve the greenchoice contract info using a curl command:
    1. Get the token:
    curl https://app.greenchoice.nl/token -X POST -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "grant_type=password" --data-urlencode "client_id=MobileApp" --data-urlencode "client_secret=A6E60EBF73521F57" --data-urlencode "username=********" --data-urlencode "password=********"
    
    1. Get the contract info:
    curl https://app.greenchoice.nl/api/v1/klant/getovereenkomsten -X GET -H "Authorization: Bearer ********"
    

(Credits for this info go to eelcohn)

homeassistant-greenchoice's People

Contributors

jessevl avatar danielhaitink avatar gaganpreet avatar pimdoos avatar eelcohn avatar filmgarage avatar

Watchers

James Cloos 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.