GithubHelp home page GithubHelp logo

tobiasdroste / home_assistant_tgtg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chouffy/home_assistant_tgtg

0.0 1.0 0.0 44 KB

TooGoodToGo items stock as sensor in Home Assistant

License: MIT License

Python 100.00%

home_assistant_tgtg's Introduction

TooGoodToGo items stock as a sensor in Home Assistant

This aim to show the stock of one or multiple TooGoodToGo item using the tgtg-python library.
Sensor data can be used afterward to generate notifications, history graphs, ... share your best examples in the Discussion tab!

Usage

Installation via HACS

  1. Search for TooGoodToGo in the Integration tab of HACS
  2. Click Install
  3. Install required packages on your local PC:
    • Python >=3.8
    • tgtg-python library: In a command line, type pip install tgtg>=0.11.0 or pip install --upgrade tgtg if you already have it.
  4. Run the tgtg_get_tokens script on your local PC:
  5. Paste the result in your /config/configuration.yaml.
  6. Restart the Home Assistant server
    • โš  Each time you add/remove a favorite in the TGTG app, restart your Home Assistant. Favorites are only updated at boot!

Configuration option

sensor:
- platform: tgtg

  # Mandatory: tokens for authentication - see the tgtg_get_tokens.py script
  access_token: "abc123"
  refresh_token: "abc123"
  user_id: "123"

  # Optional: email so you know which account is used
  username: 'Your TGTG mail'

  # Optional: Refresh the stock every 15 minutes
  scan_interval: 900

  # Optional, use defined items ID instead to get your favorites
  item:
    # item_id 1
    - 1234
    # item_id 2
    - 5678

  # Optional: user agent - by default, the latest one is retrieved from the Google Play store
  #user_agent: "TGTG/22.2.1 Dalvik/2.1.0 (Linux; U; Android 9; SM-G955F Build/PPR1.180610.011)"

access_token, refresh_token and user_id can be retrieved using the tgtg_get_tokens script!

How to get item_id

Check the tgtg_get_favorites_item_id script!

  1. Set up email/password
  2. Run it
  3. Copy the full output in the configuration.yaml for the item section

Features

  • Fetch each item stock defined
  • Authenticate using tokens
  • Retrieve all favorites instead of a manual list of item_id if no item: are defined
  • Retrieve additional information as attributes, if available:
    • Item ID
    • TooGoodToGo price and original value
    • Pick-up start and end
    • Sold-out date

Q&A

  • I have a sensor that shows now as unavailable when there's no stock
    • Try add it manually using Item ID - See this issue
  • The tgtg integration won't start, all my sensors are unavailable and I have a list of manually defined items ID

home_assistant_tgtg's People

Contributors

chouffy 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.