Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from custom-components/multi-user
Browse files Browse the repository at this point in the history
🍺 Unique sensor names based on userid
  • Loading branch information
swetoast authored Jan 3, 2019
2 parents 13e9c32 + 796778d commit 1ae6eb7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# Untappd

[![Version](https://img.shields.io/badge/version-0.0.9-green.svg?style=for-the-badge)](#) [![mantained](https://img.shields.io/maintenance/yes/2018.svg?style=for-the-badge)](#)

[![maintainer](https://img.shields.io/badge/maintainer-Peter%20Skopa%20%40swetoast-blue.svg?style=for-the-badge)](#) [![maintainer](https://img.shields.io/badge/maintainer-Ian%20Richardson%20%40iantrich-blue.svg?style=for-the-badge)](#)
[![Version](https://img.shields.io/badge/version-0.1.1-green.svg?style=for-the-badge)](#) [![mantained](https://img.shields.io/maintenance/yes/2018.svg?style=for-the-badge)](#)

[![maintainer](https://img.shields.io/badge/maintainer-Peter%20Skopa%20%40swetoast-blue.svg?style=for-the-badge)](#) [![maintainer](https://img.shields.io/badge/maintainer-Ian%20Richardson%20%40iantrich-blue.svg?style=for-the-badge)](#)

Checks your untappd info and keeps you updated from home-assistant and your wishlist that can be automated to send the list to your phone when your at the bar if you set it up right. Use the [beer card](https://github.com/ciotlosm/custom-lovelace/tree/master/beer-card) to display the wishlist its made by [Ciotlosm](https://github.com/ciotlosm)

Like this component for home-assistant?
Get Untappd last badge, check-in, wishlist and more in Home Assistant. You can also use the [beer card](https://github.com/ciotlosm/custom-lovelace/tree/master/beer-card) by [ciotlosm](https://github.com/ciotlosm) or the [list-card](https://github.com/custom-cards/list-card) by [iantrich](https://github.com/iantrich) to display your wishlist in Lovelace.

## Like this component for home-assistant?

@swetoast
<div style="text-align: center">
<a href="https://www.paypal.me/swetoast">
<img src="http://www.libertymachinenews.com/uploads/5/8/4/3/58432585/7594747_orig.png" width="300" />
</a>
</div>

@iantrich
[![coffee](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](https://www.buymeacoffee.com/zJtVxUAgH)

To get started put `/custom_components/sensor/untappd.py` here:
`<config directory>/custom_components/sensor/untappd.py`

To get started put `/custom_components/sensor/untappd.py` here:
`<config directory>/custom_components/sensor/untappd.py`

**Example configuration.yaml:**
```yaml
sensor:
Expand All @@ -29,16 +30,16 @@ sensor:
id: FSDJLKHDF786287UGHLE
secret: FJKSDLHKS8337R6948F
```
**Configuration variables:**
key | description
:--- | :---
**platform (Required)** | untappd
**id (Required)** | Your Untappd API id.
**secret (Required)** | Your Untappd API secret.
**username (Required)** | The username of the Untappd user, you want updates for.
You will need to apply for an [API from Untappd](https://untappd.com/api) to use this.
**Configuration variables:**
key | description
:--- | :---
**platform (Required)** | untappd
**id (Required)** | Your Untappd API id.
**secret (Required)** | Your Untappd API secret.
**username (Required)** | The username of the Untappd user, you want updates for.
You will need to apply for an [API from Untappd](https://untappd.com/api) to use this.
***
Due to how `custom_componentes` are loaded, it is normal to see a `ModuleNotFoundError` error on first boot after adding this, to resolve it, restart Home-Assistant.
18 changes: 9 additions & 9 deletions custom_components/sensor/untappd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

REQUIREMENTS = ['pyuntappd==0.0.5']

__version__ = '0.1.0'
__version__ = '0.1.1'

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, username, api_id, api_secret):

def update(self):
current_date = parser.parse(str(datetime.now())).replace(tzinfo=None)
result = self._untappd.get_last_activity(self._apiid,
result = self._untappd.get_last_activity(self._apiid,
self._apisecret, self._username)
if not result :
return False
Expand All @@ -101,7 +101,7 @@ def update(self):
self._score = str(result['rating_score'])
self._picture = result['beer']['beer_label']
self._abv = str(result['beer']['beer_abv']) + '%'
result = self._untappd.get_info(self._apiid,
result = self._untappd.get_info(self._apiid,
self._apisecret, self._username)
if not result :
return False
Expand All @@ -113,10 +113,10 @@ def update(self):
self._total_friends = result['stats']['total_friends']
self._total_followings = result['stats']['total_followings']
self._total_photos = result['stats']['total_photos']

@property
def name(self):
return 'Untappd Last Check-in'
return 'Untappd Last Check-in (' + self._username + ')'

@property
def entity_picture(self):
Expand Down Expand Up @@ -159,7 +159,7 @@ def __init__(self, hass, username, api_id, api_secret):
self.update()

def update(self):
result = self._untappd.get_wishlist(self._apiid,
result = self._untappd.get_wishlist(self._apiid,
self._apisecret, self._username)
if not result :
return False
Expand All @@ -185,7 +185,7 @@ def update(self):

@property
def name(self):
return 'Untappd On The Wishlist'
return 'Untappd Wishlist (' + self._username + ')'

@property
def state(self):
Expand All @@ -212,7 +212,7 @@ def __init__(self, hass, username, api_id, api_secret):


def update(self):
result = self._untappd.get_badges(self._apiid,
result = self._untappd.get_badges(self._apiid,
self._apisecret, self._username)
if not result or len(result) < 1 :
return False
Expand All @@ -234,7 +234,7 @@ def update(self):

@property
def name(self):
return 'Untappd Last Badge'
return 'Untappd Last Badge (' + self._username + ')'

@property
def entity_picture(self):
Expand Down
2 changes: 1 addition & 1 deletion custom_updater.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sensor.untappd": {
"updated_at": "",
"version": "0.0.8",
"version": "0.1.1",
"local_location": "/custom_components/sensor/untappd.py",
"remote_location": "https://raw.githubusercontent.com/custom-components/sensor.untapped/master/custom_components/sensor/untappd.py",
"visit_repo": "https://github.com/custom-components/sensor.untapped",
Expand Down
2 changes: 1 addition & 1 deletion root.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"untappd": {
"component": "sensor",
"version": "0.0.1",
"version": "0.1.1",
"mantained": "yes",
"author": "Peter Skopa @swetoast",
"added_to_ha": "false",
Expand Down

0 comments on commit 1ae6eb7

Please sign in to comment.