Skip to content

Commit 48b6b50

Browse files
committed
Fixes unit on last pour for Keg
1 parent b3c952d commit 48b6b50

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ optional arguments:
3434
TEMPERATURE = "v56"
3535
UNIT_TYPE = "v71"
3636
MEASURE_UNIT = "v75"
37+
MASS_UNIT = "v73"
3738
VOLUME_UNIT = "v82"
3839
LAST_POUR = "v59"
3940
DATE = "v67"
41+
OG = "v65"
42+
FG = "v66"
43+
ABV = "v68"
44+
FIRMWARE_VERSION = "v93"
45+
LEAK_DETECTION = "v83"
46+
MODE = "v88"
4047
```
4148

4249
### AirLock
@@ -46,7 +53,7 @@ optional arguments:
4653
BATCH_VOLUME = "v104"
4754
OG = "v105"
4855
SG = "v106"
49-
ABV = "107"
56+
ABV = "v107"
5057
TEMPERATURE_UNIT = "v108"
5158
VOLUME_UNIT = "v109"
5259
BUBBLES = "v110"

pyplaato/const.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
UNIT_TEMP_CELSIUS = "°C"
55
UNIT_TEMP_FAHRENHEIT = "°F"
66
UNIT_PERCENTAGE = "%"
7+
UNIT_OZ = "oz"
8+
UNIT_ML = "ml"
79
UNIT_BUBBLES_PER_MINUTE = "bpm"
810

11+
METRIC = "1"
12+
913
# Webhook attributes
1014
ATTR_DEVICE_ID = "device_id"
1115
ATTR_DEVICE_NAME = "device_name"

pyplaato/models/airlock.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def from_web_hook(cls, data):
4646
@property
4747
def temperature(self):
4848
if self.__temperature is not None:
49-
return round(float(self.__temperature), 1)
49+
try:
50+
return round(float(self.__temperature), 1)
51+
except ValueError:
52+
return self.__temperature
5053

5154
@property
5255
def abv(self):

pyplaato/models/keg.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
from .device import PlaatoDevice, PlaatoDeviceType
77
from .pins import PinsBase
8-
from ..const import UNIT_TEMP_CELSIUS, UNIT_TEMP_FAHRENHEIT, UNIT_PERCENTAGE
8+
from ..const import UNIT_TEMP_CELSIUS, UNIT_TEMP_FAHRENHEIT, UNIT_PERCENTAGE, \
9+
METRIC, UNIT_OZ, UNIT_ML
910

1011

1112
class PlaatoKeg(PlaatoDevice):
@@ -29,7 +30,7 @@ def __init__(self, attrs):
2930
self.__pouring = attrs.get(self.Pins.POURING, False)
3031
self.__beer_left = attrs.get(self.Pins.BEER_LEFT, None)
3132
self.__temperature = attrs.get(self.Pins.TEMPERATURE, None)
32-
self.__temperature_unit = attrs.get(self.Pins.TEMPERATURE_UNIT, None)
33+
self.__unit_type = attrs.get(self.Pins.UNIT_TYPE, None)
3334
self.__last_pour = attrs.get(self.Pins.LAST_POUR, None)
3435
self.__date = attrs.get(self.Pins.DATE, None)
3536

@@ -53,7 +54,7 @@ def temperature(self):
5354

5455
@property
5556
def temperature_unit(self):
56-
if self.__temperature_unit is "1":
57+
if self.__unit_type == METRIC:
5758
return UNIT_TEMP_CELSIUS
5859
return UNIT_TEMP_FAHRENHEIT
5960

@@ -74,9 +75,9 @@ def last_pour(self):
7475

7576
@property
7677
def last_pour_unit(self):
77-
if self.measure_unit is "1":
78-
return self.mass_unit
79-
return self.volume_unit
78+
if self.__unit_type == METRIC:
79+
return UNIT_ML
80+
return UNIT_OZ
8081

8182
@property
8283
def abv(self):
@@ -90,7 +91,7 @@ def pouring(self):
9091
255 = Pouring
9192
:return: True if 255 = Pouring else False
9293
"""
93-
return self.__pouring is "255"
94+
return self.__pouring == "255"
9495

9596
@property
9697
def leak_detection(self):
@@ -99,15 +100,15 @@ def leak_detection(self):
99100
0 = Not Leaking
100101
:return: True if 1 = Leaking else False
101102
"""
102-
return self.__leak_detection is "1"
103+
return self.__leak_detection == "1"
103104

104105
@property
105106
def mode(self):
106107
"""
107108
1 = Beer
108109
2 = Co2
109110
"""
110-
return "Beer" if self.__mode is "1" else "Co2"
111+
return "Beer" if self.__mode == "1" else "Co2"
111112

112113
@property
113114
def name(self) -> str:
@@ -185,7 +186,7 @@ class Pins(PinsBase, Enum):
185186
BEER_LEFT = "v51"
186187
BEER_LEFT_UNIT = "v74"
187188
TEMPERATURE = "v56"
188-
TEMPERATURE_UNIT = "v71"
189+
UNIT_TYPE = "v71"
189190
MEASURE_UNIT = "v75"
190191
MASS_UNIT = "v73"
191192
VOLUME_UNIT = "v82"

pyplaato/plaato.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def get_keg_data(self, session: ClientSession) -> PlaatoKeg:
4444
errors = Plaato._get_errors_as_string(result)
4545
if errors:
4646
logging.getLogger(__name__) \
47-
.error(f"Failed to get values for {errors}")
47+
.warning(f"Failed to get value for {errors}")
4848

4949
return PlaatoKeg(result)
5050

@@ -57,7 +57,7 @@ async def get_airlock_data(self, session: ClientSession) -> PlaatoAirlock:
5757
errors = Plaato._get_errors_as_string(result)
5858
if errors:
5959
logging.getLogger(__name__) \
60-
.error(f"Failed to get values for {errors}")
60+
.warning(f"Failed to get value for {errors}")
6161

6262
return PlaatoAirlock(result)
6363

@@ -81,7 +81,7 @@ async def fetch_data(self, session: ClientSession, pin: PinsBase):
8181

8282
except JSONDecodeError as e:
8383
logging.getLogger(__name__)\
84-
.error(f"Failed to decode json for pin {pin} - {e.msg}")
84+
.warning(f"Failed to decode json for pin {pin} - {e.msg}")
8585
return result
8686

8787
@staticmethod

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aiohttp==3.7.3
2+
python-dateutil==2.8.1

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="pyplaato",
8-
version="0.0.14",
8+
version="0.0.15",
99
author="JohNan",
1010
author_email="johan.nanzen@gmail.com",
1111
description="Asynchronous Python client for getting Plaato Airlock and Keg data",

0 commit comments

Comments
 (0)