mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Move keypad battery implementation details into py-august (#32349)
* Move keypad battery implementation details into py-august * Upgrade to py-august 0.22.0 which also adds gen2 doorbell battery data * remove cruft from previous refactor
This commit is contained in:
parent
924c313c8a
commit
7ca4665711
@ -18,7 +18,6 @@ class AugustEntityMixin(Entity):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self._data = data
|
self._data = data
|
||||||
self._device = device
|
self._device = device
|
||||||
self._undo_dispatch_subscription = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "August",
|
"name": "August",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/august",
|
"documentation": "https://www.home-assistant.io/integrations/august",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"py-august==0.21.0"
|
"py-august==0.22.0"
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"configurator"
|
"configurator"
|
||||||
|
@ -9,10 +9,6 @@ from homeassistant.helpers.entity import Entity
|
|||||||
from .const import DATA_AUGUST, DOMAIN
|
from .const import DATA_AUGUST, DOMAIN
|
||||||
from .entity import AugustEntityMixin
|
from .entity import AugustEntityMixin
|
||||||
|
|
||||||
BATTERY_LEVEL_FULL = "Full"
|
|
||||||
BATTERY_LEVEL_MEDIUM = "Medium"
|
|
||||||
BATTERY_LEVEL_LOW = "Low"
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -26,16 +22,7 @@ def _retrieve_linked_keypad_battery_state(detail):
|
|||||||
if detail.keypad is None:
|
if detail.keypad is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
battery_level = detail.keypad.battery_level
|
return detail.keypad.battery_percentage
|
||||||
|
|
||||||
if battery_level == BATTERY_LEVEL_FULL:
|
|
||||||
return 100
|
|
||||||
if battery_level == BATTERY_LEVEL_MEDIUM:
|
|
||||||
return 60
|
|
||||||
if battery_level == BATTERY_LEVEL_LOW:
|
|
||||||
return 10
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
SENSOR_TYPES_BATTERY = {
|
SENSOR_TYPES_BATTERY = {
|
||||||
|
@ -1079,7 +1079,7 @@ pushover_complete==1.1.1
|
|||||||
pwmled==1.5.0
|
pwmled==1.5.0
|
||||||
|
|
||||||
# homeassistant.components.august
|
# homeassistant.components.august
|
||||||
py-august==0.21.0
|
py-august==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.canary
|
# homeassistant.components.canary
|
||||||
py-canary==0.5.0
|
py-canary==0.5.0
|
||||||
|
@ -391,7 +391,7 @@ pure-python-adb==0.2.2.dev0
|
|||||||
pushbullet.py==0.11.0
|
pushbullet.py==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.august
|
# homeassistant.components.august
|
||||||
py-august==0.21.0
|
py-august==0.22.0
|
||||||
|
|
||||||
# homeassistant.components.canary
|
# homeassistant.components.canary
|
||||||
py-canary==0.5.0
|
py-canary==0.5.0
|
||||||
|
@ -82,3 +82,42 @@ async def test_create_lock_with_linked_keypad(hass):
|
|||||||
)
|
)
|
||||||
assert entry
|
assert entry
|
||||||
assert entry.unique_id == "A6697750D607098BAE8D6BAA11EF8063_linked_keypad_battery"
|
assert entry.unique_id == "A6697750D607098BAE8D6BAA11EF8063_linked_keypad_battery"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_create_lock_with_low_battery_linked_keypad(hass):
|
||||||
|
"""Test creation of a lock with a linked keypad that both have a battery."""
|
||||||
|
lock_one = await _mock_lock_from_fixture(hass, "get_lock.low_keypad_battery.json")
|
||||||
|
await _create_august_with_devices(hass, [lock_one])
|
||||||
|
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||||
|
|
||||||
|
sensor_a6697750d607098bae8d6baa11ef8063_name_battery = hass.states.get(
|
||||||
|
"sensor.a6697750d607098bae8d6baa11ef8063_name_battery"
|
||||||
|
)
|
||||||
|
assert sensor_a6697750d607098bae8d6baa11ef8063_name_battery.state == "88"
|
||||||
|
assert (
|
||||||
|
sensor_a6697750d607098bae8d6baa11ef8063_name_battery.attributes[
|
||||||
|
"unit_of_measurement"
|
||||||
|
]
|
||||||
|
== "%"
|
||||||
|
)
|
||||||
|
entry = entity_registry.async_get(
|
||||||
|
"sensor.a6697750d607098bae8d6baa11ef8063_name_battery"
|
||||||
|
)
|
||||||
|
assert entry
|
||||||
|
assert entry.unique_id == "A6697750D607098BAE8D6BAA11EF8063_device_battery"
|
||||||
|
|
||||||
|
sensor_a6697750d607098bae8d6baa11ef8063_name_keypad_battery = hass.states.get(
|
||||||
|
"sensor.a6697750d607098bae8d6baa11ef8063_name_keypad_battery"
|
||||||
|
)
|
||||||
|
assert sensor_a6697750d607098bae8d6baa11ef8063_name_keypad_battery.state == "10"
|
||||||
|
assert (
|
||||||
|
sensor_a6697750d607098bae8d6baa11ef8063_name_keypad_battery.attributes[
|
||||||
|
"unit_of_measurement"
|
||||||
|
]
|
||||||
|
== "%"
|
||||||
|
)
|
||||||
|
entry = entity_registry.async_get(
|
||||||
|
"sensor.a6697750d607098bae8d6baa11ef8063_name_keypad_battery"
|
||||||
|
)
|
||||||
|
assert entry
|
||||||
|
assert entry.unique_id == "A6697750D607098BAE8D6BAA11EF8063_linked_keypad_battery"
|
||||||
|
103
tests/fixtures/august/get_lock.low_keypad_battery.json
vendored
Normal file
103
tests/fixtures/august/get_lock.low_keypad_battery.json
vendored
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"LockName": "Front Door Lock",
|
||||||
|
"Type": 2,
|
||||||
|
"Created": "2017-12-10T03:12:09.210Z",
|
||||||
|
"Updated": "2017-12-10T03:12:09.210Z",
|
||||||
|
"LockID": "A6697750D607098BAE8D6BAA11EF8063",
|
||||||
|
"HouseID": "000000000000",
|
||||||
|
"HouseName": "My House",
|
||||||
|
"Calibrated": false,
|
||||||
|
"skuNumber": "AUG-SL02-M02-S02",
|
||||||
|
"timeZone": "America/Vancouver",
|
||||||
|
"battery": 0.88,
|
||||||
|
"SerialNumber": "X2FSW05DGA",
|
||||||
|
"LockStatus": {
|
||||||
|
"status": "locked",
|
||||||
|
"doorState": "closed",
|
||||||
|
"dateTime": "2017-12-10T04:48:30.272Z",
|
||||||
|
"isLockStatusChanged": true,
|
||||||
|
"valid": true
|
||||||
|
},
|
||||||
|
"currentFirmwareVersion": "109717e9-3.0.44-3.0.30",
|
||||||
|
"homeKitEnabled": false,
|
||||||
|
"zWaveEnabled": false,
|
||||||
|
"isGalileo": false,
|
||||||
|
"Bridge": {
|
||||||
|
"_id": "aaacab87f7efxa0015884999",
|
||||||
|
"mfgBridgeID": "AAGPP102XX",
|
||||||
|
"deviceModel": "august-doorbell",
|
||||||
|
"firmwareVersion": "2.3.0-RC153+201711151527",
|
||||||
|
"operative": true
|
||||||
|
},
|
||||||
|
"keypad": {
|
||||||
|
"_id": "5bc65c24e6ef2a263e1450a8",
|
||||||
|
"serialNumber": "K1GXB0054Z",
|
||||||
|
"lockID": "92412D1B44004595B5DEB134E151A8D3",
|
||||||
|
"currentFirmwareVersion": "2.27.0",
|
||||||
|
"battery": {},
|
||||||
|
"batteryLevel": "Low",
|
||||||
|
"batteryRaw": 170
|
||||||
|
},
|
||||||
|
"OfflineKeys": {
|
||||||
|
"created": [],
|
||||||
|
"loaded": [
|
||||||
|
{
|
||||||
|
"UserID": "cccca94e-373e-aaaa-bbbb-333396827777",
|
||||||
|
"slot": 1,
|
||||||
|
"key": "kkk01d4300c1dcxxx1c330f794941111",
|
||||||
|
"created": "2017-12-10T03:12:09.215Z",
|
||||||
|
"loaded": "2017-12-10T03:12:54.391Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deleted": [],
|
||||||
|
"loadedhk": [
|
||||||
|
{
|
||||||
|
"key": "kkk01d4300c1dcxxx1c330f794941222",
|
||||||
|
"slot": 256,
|
||||||
|
"UserID": "cccca94e-373e-aaaa-bbbb-333396827777",
|
||||||
|
"created": "2017-12-10T03:12:09.218Z",
|
||||||
|
"loaded": "2017-12-10T03:12:55.563Z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"parametersToSet": {},
|
||||||
|
"users": {
|
||||||
|
"cccca94e-373e-aaaa-bbbb-333396827777": {
|
||||||
|
"UserType": "superuser",
|
||||||
|
"FirstName": "Foo",
|
||||||
|
"LastName": "Bar",
|
||||||
|
"identifiers": [
|
||||||
|
"email:foo@bar.com",
|
||||||
|
"phone:+177777777777"
|
||||||
|
],
|
||||||
|
"imageInfo": {
|
||||||
|
"original": {
|
||||||
|
"width": 948,
|
||||||
|
"height": 949,
|
||||||
|
"format": "jpg",
|
||||||
|
"url": "http://www.image.com/foo.jpeg",
|
||||||
|
"secure_url": "https://www.image.com/foo.jpeg"
|
||||||
|
},
|
||||||
|
"thumbnail": {
|
||||||
|
"width": 128,
|
||||||
|
"height": 128,
|
||||||
|
"format": "jpg",
|
||||||
|
"url": "http://www.image.com/foo.jpeg",
|
||||||
|
"secure_url": "https://www.image.com/foo.jpeg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pubsubChannel": "3333a674-ffff-aaaa-b351-b3a4473f3333",
|
||||||
|
"ruleHash": {},
|
||||||
|
"cameras": [],
|
||||||
|
"geofenceLimits": {
|
||||||
|
"ios": {
|
||||||
|
"debounceInterval": 90,
|
||||||
|
"gpsAccuracyMultiplier": 2.5,
|
||||||
|
"maximumGeofence": 5000,
|
||||||
|
"minimumGeofence": 100,
|
||||||
|
"minGPSAccuracyRequired": 80
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user