diff --git a/.coveragerc b/.coveragerc index 23b00aed6de..e49103c3b3b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -275,7 +275,6 @@ omit = homeassistant/components/garmin_connect/sensor.py homeassistant/components/gc100/* homeassistant/components/geniushub/* - homeassistant/components/gearbest/sensor.py homeassistant/components/geizhals/sensor.py homeassistant/components/gios/__init__.py homeassistant/components/gios/air_quality.py diff --git a/CODEOWNERS b/CODEOWNERS index c51b087c031..7404d3a62aa 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -141,7 +141,6 @@ homeassistant/components/fronius/* @nielstron homeassistant/components/frontend/* @home-assistant/frontend homeassistant/components/garmin_connect/* @cyberjunky homeassistant/components/gdacs/* @exxamalte -homeassistant/components/gearbest/* @HerrHofrat homeassistant/components/geniushub/* @zxdavb homeassistant/components/geo_rss_events/* @exxamalte homeassistant/components/geonetnz_quakes/* @exxamalte diff --git a/homeassistant/components/gearbest/__init__.py b/homeassistant/components/gearbest/__init__.py deleted file mode 100644 index c97d9469296..00000000000 --- a/homeassistant/components/gearbest/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""The gearbest component.""" diff --git a/homeassistant/components/gearbest/manifest.json b/homeassistant/components/gearbest/manifest.json deleted file mode 100644 index 4729fd6b6f3..00000000000 --- a/homeassistant/components/gearbest/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "domain": "gearbest", - "name": "Gearbest", - "documentation": "https://www.home-assistant.io/integrations/gearbest", - "requirements": ["gearbest_parser==1.0.7"], - "codeowners": ["@HerrHofrat"] -} diff --git a/homeassistant/components/gearbest/sensor.py b/homeassistant/components/gearbest/sensor.py deleted file mode 100644 index b9b2a35b89d..00000000000 --- a/homeassistant/components/gearbest/sensor.py +++ /dev/null @@ -1,123 +0,0 @@ -"""Parse prices of an item from gearbest.""" -from datetime import timedelta -import logging - -from gearbest_parser import CurrencyConverter, GearbestParser -import voluptuous as vol - -from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import CONF_CURRENCY, CONF_ID, CONF_NAME, CONF_URL -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity -from homeassistant.helpers.event import track_time_interval -from homeassistant.util import Throttle - -_LOGGER = logging.getLogger(__name__) - -CONF_ITEMS = "items" - -ICON = "mdi:coin" -MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=2 * 60 * 60) # 2h -MIN_TIME_BETWEEN_CURRENCY_UPDATES = timedelta(seconds=12 * 60 * 60) # 12h - - -_ITEM_SCHEMA = vol.All( - vol.Schema( - { - vol.Exclusive(CONF_URL, "XOR"): cv.string, - vol.Exclusive(CONF_ID, "XOR"): cv.string, - vol.Optional(CONF_NAME): cv.string, - vol.Optional(CONF_CURRENCY): cv.string, - } - ), - cv.has_at_least_one_key(CONF_URL, CONF_ID), -) - -_ITEMS_SCHEMA = vol.Schema([_ITEM_SCHEMA]) - -PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - {vol.Required(CONF_ITEMS): _ITEMS_SCHEMA, vol.Required(CONF_CURRENCY): cv.string} -) - - -def setup_platform(hass, config, add_entities, discovery_info=None): - """Set up the Gearbest sensor.""" - - currency = config.get(CONF_CURRENCY) - - sensors = [] - items = config.get(CONF_ITEMS) - - converter = CurrencyConverter() - converter.update() - - for item in items: - try: - sensors.append(GearbestSensor(converter, item, currency)) - except ValueError as exc: - _LOGGER.error(exc) - - def currency_update(event_time): - """Update currency list.""" - converter.update() - - track_time_interval(hass, currency_update, MIN_TIME_BETWEEN_CURRENCY_UPDATES) - - add_entities(sensors, True) - - -class GearbestSensor(Entity): - """Implementation of the sensor.""" - - def __init__(self, converter, item, currency): - """Initialize the sensor.""" - - self._name = item.get(CONF_NAME) - self._parser = GearbestParser() - self._parser.set_currency_converter(converter) - self._item = self._parser.load( - item.get(CONF_ID), item.get(CONF_URL), item.get(CONF_CURRENCY, currency) - ) - if self._item is None: - raise ValueError("id and url could not be resolved") - - @property - def name(self): - """Return the name of the item.""" - return self._name if self._name is not None else self._item.name - - @property - def icon(self): - """Return the icon for the frontend.""" - return ICON - - @property - def state(self): - """Return the price of the selected product.""" - return self._item.price - - @property - def unit_of_measurement(self): - """Return the currency.""" - return self._item.currency - - @property - def entity_picture(self): - """Return the image.""" - return self._item.image - - @property - def device_state_attributes(self): - """Return the state attributes.""" - attrs = { - "name": self._item.name, - "description": self._item.description, - "currency": self._item.currency, - "url": self._item.url, - } - return attrs - - @Throttle(MIN_TIME_BETWEEN_UPDATES) - def update(self): - """Get the latest price from gearbest and updates the state.""" - self._item.update() diff --git a/requirements_all.txt b/requirements_all.txt index 90a2a87df1f..b60a60be24f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -612,9 +612,6 @@ gTTS-token==1.1.3 # homeassistant.components.garmin_connect garminconnect==0.1.13 -# homeassistant.components.gearbest -gearbest_parser==1.0.7 - # homeassistant.components.geizhals geizhals==0.0.9