diff --git a/homeassistant/components/august/entity.py b/homeassistant/components/august/entity.py index 03c7698770c..a3f72da44be 100644 --- a/homeassistant/components/august/entity.py +++ b/homeassistant/components/august/entity.py @@ -18,7 +18,6 @@ class AugustEntityMixin(Entity): super().__init__() self._data = data self._device = device - self._undo_dispatch_subscription = None @property def should_poll(self): diff --git a/homeassistant/components/august/manifest.json b/homeassistant/components/august/manifest.json index 523cb5a361f..ef1df806575 100644 --- a/homeassistant/components/august/manifest.json +++ b/homeassistant/components/august/manifest.json @@ -3,7 +3,7 @@ "name": "August", "documentation": "https://www.home-assistant.io/integrations/august", "requirements": [ - "py-august==0.21.0" + "py-august==0.22.0" ], "dependencies": [ "configurator" diff --git a/homeassistant/components/august/sensor.py b/homeassistant/components/august/sensor.py index 8c5682b8e42..6e8571c343a 100644 --- a/homeassistant/components/august/sensor.py +++ b/homeassistant/components/august/sensor.py @@ -9,10 +9,6 @@ from homeassistant.helpers.entity import Entity from .const import DATA_AUGUST, DOMAIN from .entity import AugustEntityMixin -BATTERY_LEVEL_FULL = "Full" -BATTERY_LEVEL_MEDIUM = "Medium" -BATTERY_LEVEL_LOW = "Low" - _LOGGER = logging.getLogger(__name__) @@ -26,16 +22,7 @@ def _retrieve_linked_keypad_battery_state(detail): if detail.keypad is None: return None - battery_level = detail.keypad.battery_level - - 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 + return detail.keypad.battery_percentage SENSOR_TYPES_BATTERY = { diff --git a/requirements_all.txt b/requirements_all.txt index 7304a9ccb77..5c96ae181b4 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1079,7 +1079,7 @@ pushover_complete==1.1.1 pwmled==1.5.0 # homeassistant.components.august -py-august==0.21.0 +py-august==0.22.0 # homeassistant.components.canary py-canary==0.5.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index de43f8f9d21..b9b035610e8 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -391,7 +391,7 @@ pure-python-adb==0.2.2.dev0 pushbullet.py==0.11.0 # homeassistant.components.august -py-august==0.21.0 +py-august==0.22.0 # homeassistant.components.canary py-canary==0.5.0 diff --git a/tests/components/august/test_sensor.py b/tests/components/august/test_sensor.py index a0c1a2ea7bb..dfcae6dd362 100644 --- a/tests/components/august/test_sensor.py +++ b/tests/components/august/test_sensor.py @@ -82,3 +82,42 @@ async def test_create_lock_with_linked_keypad(hass): ) assert entry 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" diff --git a/tests/fixtures/august/get_lock.low_keypad_battery.json b/tests/fixtures/august/get_lock.low_keypad_battery.json new file mode 100644 index 00000000000..f848a8d30eb --- /dev/null +++ b/tests/fixtures/august/get_lock.low_keypad_battery.json @@ -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 + } + } +}