mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Remove Social Blade integration (ADR-0004) (#48677)
* Remove Social Blade integration (ADR-0004) * Cleanup coveragerc
This commit is contained in:
parent
2511e1f229
commit
b34cc7ef2c
@ -895,7 +895,6 @@ omit =
|
||||
homeassistant/components/snapcast/*
|
||||
homeassistant/components/snmp/*
|
||||
homeassistant/components/sochain/sensor.py
|
||||
homeassistant/components/socialblade/sensor.py
|
||||
homeassistant/components/solaredge/__init__.py
|
||||
homeassistant/components/solaredge/sensor.py
|
||||
homeassistant/components/solaredge_local/sensor.py
|
||||
|
@ -1 +0,0 @@
|
||||
"""The socialblade component."""
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"domain": "socialblade",
|
||||
"name": "Social Blade",
|
||||
"documentation": "https://www.home-assistant.io/integrations/socialblade",
|
||||
"requirements": ["socialbladeclient==0.5"],
|
||||
"codeowners": []
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
"""Support for Social Blade."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import socialbladeclient
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CHANNEL_ID = "channel_id"
|
||||
|
||||
DEFAULT_NAME = "Social Blade"
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(hours=2)
|
||||
|
||||
SUBSCRIBERS = "subscribers"
|
||||
|
||||
TOTAL_VIEWS = "total_views"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CHANNEL_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Social Blade sensor."""
|
||||
social_blade = SocialBladeSensor(config[CHANNEL_ID], config[CONF_NAME])
|
||||
|
||||
social_blade.update()
|
||||
if social_blade.valid_channel_id is False:
|
||||
return
|
||||
|
||||
add_entities([social_blade])
|
||||
|
||||
|
||||
class SocialBladeSensor(SensorEntity):
|
||||
"""Representation of a Social Blade Sensor."""
|
||||
|
||||
def __init__(self, case, name):
|
||||
"""Initialize the Social Blade sensor."""
|
||||
self._state = None
|
||||
self.channel_id = case
|
||||
self._attributes = None
|
||||
self.valid_channel_id = None
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
if self._attributes:
|
||||
return self._attributes
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
"""Get the latest data from Social Blade."""
|
||||
|
||||
try:
|
||||
data = socialbladeclient.get_data(self.channel_id)
|
||||
self._attributes = {TOTAL_VIEWS: data[TOTAL_VIEWS]}
|
||||
self._state = data[SUBSCRIBERS]
|
||||
self.valid_channel_id = True
|
||||
|
||||
except (ValueError, IndexError):
|
||||
_LOGGER.error("Unable to find valid channel ID")
|
||||
self.valid_channel_id = False
|
||||
self._attributes = None
|
@ -2080,9 +2080,6 @@ smhi-pkg==1.0.13
|
||||
# homeassistant.components.snapcast
|
||||
snapcast==2.1.2
|
||||
|
||||
# homeassistant.components.socialblade
|
||||
socialbladeclient==0.5
|
||||
|
||||
# homeassistant.components.solaredge_local
|
||||
solaredge-local==0.2.0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user