Skip to content

Commit e6eaa3e

Browse files
committed
Additional battery percentage estimations
* Battery percentage for the mars2 lock * Battery percentage for the keypad These mirror the name to percentage mappings currently used in home assistant
1 parent 9adeef6 commit e6eaa3e

File tree

7 files changed

+398
-6
lines changed

7 files changed

+398
-6
lines changed

august/doorbell.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,21 @@ def __init__(self, data):
7272

7373
self._battery_level = None
7474
if "telemetry" in data:
75-
self._battery_level = data["telemetry"].get("battery_soc", None)
75+
telemetry = data["telemetry"]
76+
if "battery_soc" in telemetry:
77+
self._battery_level = telemetry.get("battery_soc", None)
78+
elif telemetry.get("doorbell_low_battery"):
79+
self._battery_level = 10
80+
elif "battery" in telemetry:
81+
battery = telemetry["battery"]
82+
if battery >= 4:
83+
self._battery_level = 100
84+
elif battery >= 3.75:
85+
self._battery_level = 75
86+
elif battery >= 3.50:
87+
self._battery_level = 50
88+
else:
89+
self._battery_level = 25
7690

7791
@property
7892
def status(self):
@@ -112,6 +126,7 @@ def image_url(self, var):
112126

113127
@property
114128
def battery_level(self):
129+
"""Return an approximation of the battery percentage."""
115130
return self._battery_level
116131

117132
@property

august/keypad.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from august.device import DeviceDetail
22

3+
BATTERY_LEVEL_FULL = "Full"
4+
BATTERY_LEVEL_MEDIUM = "Medium"
5+
BATTERY_LEVEL_LOW = "Low"
6+
37

48
class KeypadDetail(DeviceDetail):
59
def __init__(self, house_id, keypad_name, data):
@@ -8,7 +12,7 @@ def __init__(self, house_id, keypad_name, data):
812
keypad_name,
913
house_id,
1014
data["serialNumber"],
11-
data["currentFirmwareVersion"]
15+
data["currentFirmwareVersion"],
1216
)
1317

1418
self._battery_level = data["batteryLevel"]
@@ -20,3 +24,18 @@ def model(self):
2024
@property
2125
def battery_level(self):
2226
return self._battery_level
27+
28+
@property
29+
def battery_percentage(self):
30+
"""Return an approximation of the battery percentage."""
31+
if not self._battery_level:
32+
return None
33+
34+
if self._battery_level == BATTERY_LEVEL_FULL:
35+
return 100
36+
if self._battery_level == BATTERY_LEVEL_MEDIUM:
37+
return 60
38+
if self._battery_level == BATTERY_LEVEL_LOW:
39+
return 10
40+
41+
return 0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='py-august',
5-
version='0.21.0',
5+
version='0.22.0',
66
packages=['august'],
77
url='https://github.com/snjoetw/py-august',
88
license='MIT',
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"doorbellID": "did",
3+
"serialNumber": "sr",
4+
"appID": "august-iphone-v5",
5+
"installUserID": "iid",
6+
"name": "Front Door",
7+
"installDate": "2019-02-25T05:32:11.263Z",
8+
"pubsubChannel": "pubsub",
9+
"settings": {
10+
"ABREnabled": true,
11+
"auto_contrast_mode": 0,
12+
"backlight_comp": false,
13+
"batteryChargeCurrent": 60,
14+
"batteryLowThreshold": 3.1,
15+
"batteryUseThreshold": 3.4,
16+
"batteryRun": false,
17+
"bellTimerConfig": 50,
18+
"bitrateCeiling": 512000,
19+
"brightness": 50,
20+
"contrast": 50,
21+
"directLink": true,
22+
"debug": false,
23+
"flashBrightness": 40,
24+
"flashDuringCall": true,
25+
"flashOnPIR": true,
26+
"haloBrightnessX": 25,
27+
"hue": 50,
28+
"initialBitrate": 384000,
29+
"IREnabled": true,
30+
"irConfiguration": 16836880,
31+
"irSensitivity": 70,
32+
"IVAEnabled": false,
33+
"JPGQuality": 70,
34+
"keepEncoderRunning": true,
35+
"maintainIVConnection": true,
36+
"micVolume": 100,
37+
"minACNoScaling": 40,
38+
"minimumSnapshotInterval": 30,
39+
"overlayEnabled": true,
40+
"ringSoundEnabled": true,
41+
"saturation": 50,
42+
"sharpness": 50,
43+
"speakerVolume": 92,
44+
"turnOffCamera": false,
45+
"buttonpush_notifications": true,
46+
"motion_notifications": true,
47+
"notify_when_offline": false,
48+
"buttonpush_notifications_partners": false
49+
},
50+
"type": "mars2",
51+
"dvrSubscriptionSetupDone": true,
52+
"secChipCertSerial": null,
53+
"createdAt": "2019-02-25T05:32:11.263Z",
54+
"updatedAt": "2019-02-25T05:50:03.087Z",
55+
"status": "doorbell_call_status_online",
56+
"statusUpdatedAtMs": 1582608961596,
57+
"telemetry": {
58+
"date": "2019-02-25 08:19:56",
59+
"BSSID": "a:b:c",
60+
"SSID": "none",
61+
"wifi_freq": 2437,
62+
"ip_addr": "4.3.3.2",
63+
"link_quality": 70,
64+
"signal_level": -35,
65+
"uptime": "9499.66 7505.92",
66+
"load_average": "0.42 0.39 0.45 2/180 5959",
67+
"temperature": 49.25,
68+
"steady_ac_in": 0,
69+
"battery": 4.147,
70+
"ac_in": 0,
71+
"doorbell_low_battery": false,
72+
"mcu_version": "900aecaf",
73+
"mcu_temp": 61.470001,
74+
"mcu_bat_cur": 63.779999,
75+
"mcu_dc_in": 4.925,
76+
"chg_state": "CHARGING",
77+
"updated_at": "2019-02-25T08:19:58.678Z"
78+
},
79+
"caps": ["reconnect", "webrtc", "no_iv"],
80+
"doorbellServerURL": "https://doorbells.august.com",
81+
"recentImage": {
82+
"public_id": "pubid",
83+
"version": 123,
84+
"signature": "sig",
85+
"width": 480,
86+
"height": 640,
87+
"format": "jpg",
88+
"resource_type": "image",
89+
"created_at": "2020-02-25T05:50:02Z",
90+
"tags": [],
91+
"bytes": 25330,
92+
"type": "upload",
93+
"etag": "etag",
94+
"placeholder": false,
95+
"url": "http://of.jpg",
96+
"secure_url": "https://of.jpg",
97+
"original_filename": "file"
98+
},
99+
"messagingProtocol": "pubnub",
100+
"chimes": [],
101+
"firmwareVersion": "2.3.0-VULRC18+201812100947",
102+
"invitations": [],
103+
"HouseID": "houseid",
104+
"HouseName": "housename"
105+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"doorbellID": "did",
3+
"serialNumber": "sr",
4+
"appID": "august-iphone-v5",
5+
"installUserID": "iid",
6+
"name": "Front Door",
7+
"installDate": "2019-02-25T05:32:11.263Z",
8+
"pubsubChannel": "pubsub",
9+
"settings": {
10+
"ABREnabled": true,
11+
"auto_contrast_mode": 0,
12+
"backlight_comp": false,
13+
"batteryChargeCurrent": 60,
14+
"batteryLowThreshold": 3.1,
15+
"batteryUseThreshold": 3.4,
16+
"batteryRun": false,
17+
"bellTimerConfig": 50,
18+
"bitrateCeiling": 512000,
19+
"brightness": 50,
20+
"contrast": 50,
21+
"directLink": true,
22+
"debug": false,
23+
"flashBrightness": 40,
24+
"flashDuringCall": true,
25+
"flashOnPIR": true,
26+
"haloBrightnessX": 25,
27+
"hue": 50,
28+
"initialBitrate": 384000,
29+
"IREnabled": true,
30+
"irConfiguration": 16836880,
31+
"irSensitivity": 70,
32+
"IVAEnabled": false,
33+
"JPGQuality": 70,
34+
"keepEncoderRunning": true,
35+
"maintainIVConnection": true,
36+
"micVolume": 100,
37+
"minACNoScaling": 40,
38+
"minimumSnapshotInterval": 30,
39+
"overlayEnabled": true,
40+
"ringSoundEnabled": true,
41+
"saturation": 50,
42+
"sharpness": 50,
43+
"speakerVolume": 92,
44+
"turnOffCamera": false,
45+
"buttonpush_notifications": true,
46+
"motion_notifications": true,
47+
"notify_when_offline": false,
48+
"buttonpush_notifications_partners": false
49+
},
50+
"type": "mars2",
51+
"dvrSubscriptionSetupDone": true,
52+
"secChipCertSerial": null,
53+
"createdAt": "2019-02-25T05:32:11.263Z",
54+
"updatedAt": "2019-02-25T05:50:03.087Z",
55+
"status": "doorbell_call_status_online",
56+
"statusUpdatedAtMs": 1582608961596,
57+
"telemetry": {
58+
"date": "2019-02-25 05:50:01",
59+
"BSSID": "4:d:d",
60+
"SSID": "zip",
61+
"wifi_freq": 2437,
62+
"ip_addr": "1.2.2.4",
63+
"link_quality": 70,
64+
"signal_level": -38,
65+
"uptime": "504.12 380.94",
66+
"load_average": "0.57 0.41 0.22 1/180 1149",
67+
"temperature": 45.625,
68+
"steady_ac_in": 0,
69+
"battery": 3.023,
70+
"ac_in": 0,
71+
"doorbell_low_battery": true,
72+
"mcu_version": "900aecaf",
73+
"mcu_temp": 59.009998,
74+
"mcu_bat_cur": 65,
75+
"mcu_dc_in": 4.978,
76+
"chg_state": "CHARGING",
77+
"updated_at": "2020-02-25T05:50:03.087Z"
78+
},
79+
"caps": ["reconnect", "webrtc", "no_iv"],
80+
"doorbellServerURL": "https://doorbells.august.com",
81+
"recentImage": {
82+
"public_id": "pubid",
83+
"version": 123,
84+
"signature": "sig",
85+
"width": 480,
86+
"height": 640,
87+
"format": "jpg",
88+
"resource_type": "image",
89+
"created_at": "2020-02-25T05:50:02Z",
90+
"tags": [],
91+
"bytes": 25330,
92+
"type": "upload",
93+
"etag": "etag",
94+
"placeholder": false,
95+
"url": "http://of.jpg",
96+
"secure_url": "https://of.jpg",
97+
"original_filename": "file"
98+
},
99+
"messagingProtocol": "pubnub",
100+
"chimes": [],
101+
"firmwareVersion": "2.3.0-VULRC18+201812100947",
102+
"invitations": [],
103+
"HouseID": "houseid",
104+
"HouseName": "housename"
105+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"doorbellID": "did",
3+
"serialNumber": "sr",
4+
"appID": "august-iphone-v5",
5+
"installUserID": "iid",
6+
"name": "Front Door",
7+
"installDate": "2019-02-25T05:32:11.263Z",
8+
"pubsubChannel": "pubsub",
9+
"settings": {
10+
"ABREnabled": true,
11+
"auto_contrast_mode": 0,
12+
"backlight_comp": false,
13+
"batteryChargeCurrent": 60,
14+
"batteryLowThreshold": 3.1,
15+
"batteryUseThreshold": 3.4,
16+
"batteryRun": false,
17+
"bellTimerConfig": 50,
18+
"bitrateCeiling": 512000,
19+
"brightness": 50,
20+
"contrast": 50,
21+
"directLink": true,
22+
"debug": false,
23+
"flashBrightness": 40,
24+
"flashDuringCall": true,
25+
"flashOnPIR": true,
26+
"haloBrightnessX": 25,
27+
"hue": 50,
28+
"initialBitrate": 384000,
29+
"IREnabled": true,
30+
"irConfiguration": 16836880,
31+
"irSensitivity": 70,
32+
"IVAEnabled": false,
33+
"JPGQuality": 70,
34+
"keepEncoderRunning": true,
35+
"maintainIVConnection": true,
36+
"micVolume": 100,
37+
"minACNoScaling": 40,
38+
"minimumSnapshotInterval": 30,
39+
"overlayEnabled": true,
40+
"ringSoundEnabled": true,
41+
"saturation": 50,
42+
"sharpness": 50,
43+
"speakerVolume": 92,
44+
"turnOffCamera": false,
45+
"buttonpush_notifications": true,
46+
"motion_notifications": true,
47+
"notify_when_offline": false,
48+
"buttonpush_notifications_partners": false
49+
},
50+
"type": "mars2",
51+
"dvrSubscriptionSetupDone": true,
52+
"secChipCertSerial": null,
53+
"createdAt": "2019-02-25T05:32:11.263Z",
54+
"updatedAt": "2019-02-25T05:50:03.087Z",
55+
"status": "doorbell_call_status_online",
56+
"statusUpdatedAtMs": 1582608961596,
57+
"telemetry": {
58+
"date": "2019-02-25 08:19:56",
59+
"BSSID": "a:b:c",
60+
"SSID": "none",
61+
"wifi_freq": 2437,
62+
"ip_addr": "4.3.3.2",
63+
"link_quality": 70,
64+
"signal_level": -35,
65+
"uptime": "9499.66 7505.92",
66+
"load_average": "0.42 0.39 0.45 2/180 5959",
67+
"temperature": 49.25,
68+
"steady_ac_in": 0,
69+
"battery": 3.82,
70+
"ac_in": 0,
71+
"doorbell_low_battery": false,
72+
"mcu_version": "900aecaf",
73+
"mcu_temp": 61.470001,
74+
"mcu_bat_cur": 63.779999,
75+
"mcu_dc_in": 4.925,
76+
"chg_state": "CHARGING",
77+
"updated_at": "2019-02-25T08:19:58.678Z"
78+
},
79+
"caps": ["reconnect", "webrtc", "no_iv"],
80+
"doorbellServerURL": "https://doorbells.august.com",
81+
"recentImage": {
82+
"public_id": "pubid",
83+
"version": 123,
84+
"signature": "sig",
85+
"width": 480,
86+
"height": 640,
87+
"format": "jpg",
88+
"resource_type": "image",
89+
"created_at": "2020-02-25T05:50:02Z",
90+
"tags": [],
91+
"bytes": 25330,
92+
"type": "upload",
93+
"etag": "etag",
94+
"placeholder": false,
95+
"url": "http://of.jpg",
96+
"secure_url": "https://of.jpg",
97+
"original_filename": "file"
98+
},
99+
"messagingProtocol": "pubnub",
100+
"chimes": [],
101+
"firmwareVersion": "2.3.0-VULRC18+201812100947",
102+
"invitations": [],
103+
"HouseID": "houseid",
104+
"HouseName": "housename"
105+
}

0 commit comments

Comments
 (0)