From 6660cf701d1dccb36fa8cd9bf86636eb70485e09 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 23 Jun 2020 00:34:26 +0200 Subject: [PATCH] Remove lockitron integration (#37012) --- .coveragerc | 1 - .../components/lockitron/__init__.py | 1 - homeassistant/components/lockitron/lock.py | 87 ------------------- .../components/lockitron/manifest.json | 6 -- 4 files changed, 95 deletions(-) delete mode 100644 homeassistant/components/lockitron/__init__.py delete mode 100644 homeassistant/components/lockitron/lock.py delete mode 100644 homeassistant/components/lockitron/manifest.json diff --git a/.coveragerc b/.coveragerc index a1c3307c12c..8105920b3e6 100644 --- a/.coveragerc +++ b/.coveragerc @@ -444,7 +444,6 @@ omit = homeassistant/components/linux_battery/sensor.py homeassistant/components/lirc/* homeassistant/components/llamalab_automate/notify.py - homeassistant/components/lockitron/lock.py homeassistant/components/logi_circle/__init__.py homeassistant/components/logi_circle/camera.py homeassistant/components/logi_circle/const.py diff --git a/homeassistant/components/lockitron/__init__.py b/homeassistant/components/lockitron/__init__.py deleted file mode 100644 index d2f9f749533..00000000000 --- a/homeassistant/components/lockitron/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""The lockitron component.""" diff --git a/homeassistant/components/lockitron/lock.py b/homeassistant/components/lockitron/lock.py deleted file mode 100644 index e1ece3da725..00000000000 --- a/homeassistant/components/lockitron/lock.py +++ /dev/null @@ -1,87 +0,0 @@ -"""Lockitron lock platform.""" -import logging - -import requests -import voluptuous as vol - -from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity -from homeassistant.const import CONF_ACCESS_TOKEN, CONF_ID, HTTP_OK -import homeassistant.helpers.config_validation as cv - -_LOGGER = logging.getLogger(__name__) - -DOMAIN = "lockitron" - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - {vol.Required(CONF_ACCESS_TOKEN): cv.string, vol.Required(CONF_ID): cv.string} -) -BASE_URL = "https://api.lockitron.com" - - -def setup_platform(hass, config, add_entities, discovery_info=None): - """Set up the Lockitron platform.""" - access_token = config.get(CONF_ACCESS_TOKEN) - device_id = config.get(CONF_ID) - response = requests.get( - f"{BASE_URL}/v2/locks/{device_id}?access_token={access_token}", timeout=5 - ) - if response.status_code == HTTP_OK: - add_entities([Lockitron(response.json()["state"], access_token, device_id)]) - else: - _LOGGER.error("Error retrieving lock status during init: %s", response.text) - - -class Lockitron(LockEntity): - """Representation of a Lockitron lock.""" - - LOCK_STATE = "lock" - UNLOCK_STATE = "unlock" - - def __init__(self, state, access_token, device_id): - """Initialize the lock.""" - self._state = state - self.access_token = access_token - self.device_id = device_id - - @property - def name(self): - """Return the name of the device.""" - return DOMAIN - - @property - def is_locked(self): - """Return True if the lock is currently locked, else False.""" - return self._state == Lockitron.LOCK_STATE - - def lock(self, **kwargs): - """Lock the device.""" - self._state = self.do_change_request(Lockitron.LOCK_STATE) - - def unlock(self, **kwargs): - """Unlock the device.""" - self._state = self.do_change_request(Lockitron.UNLOCK_STATE) - - def update(self): - """Update the internal state of the device.""" - response = requests.get( - f"{BASE_URL}/v2/locks/{self.device_id}?access_token={self.access_token}", - timeout=5, - ) - if response.status_code == HTTP_OK: - self._state = response.json()["state"] - else: - _LOGGER.error("Error retrieving lock status: %s", response.text) - - def do_change_request(self, requested_state): - """Execute the change request and pull out the new state.""" - response = requests.put( - f"{BASE_URL}/v2/locks/{self.device_id}?access_token={self.access_token}&state={requested_state}", - timeout=5, - ) - if response.status_code == HTTP_OK: - return response.json()["state"] - - _LOGGER.error( - "Error setting lock state: %s\n%s", requested_state, response.text - ) - return self._state diff --git a/homeassistant/components/lockitron/manifest.json b/homeassistant/components/lockitron/manifest.json deleted file mode 100644 index 088bc847621..00000000000 --- a/homeassistant/components/lockitron/manifest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "domain": "lockitron", - "name": "Lockitron", - "documentation": "https://www.home-assistant.io/integrations/lockitron", - "codeowners": [] -}