Remove history_graph integration (#32028)

* Remove history_graph integration

* Update codeowners file
This commit is contained in:
Franck Nijhof 2020-02-20 18:01:29 +01:00 committed by GitHub
parent 1c2bce9292
commit 1c81e8ad68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 148 deletions

View File

@ -147,7 +147,6 @@ homeassistant/components/hikvision/* @mezz64
homeassistant/components/hikvisioncam/* @fbradyirl
homeassistant/components/hisense_aehw4a1/* @bannhead
homeassistant/components/history/* @home-assistant/core
homeassistant/components/history_graph/* @andrey-git
homeassistant/components/hive/* @Rendili @KJonline
homeassistant/components/homeassistant/* @home-assistant/core
homeassistant/components/homekit_controller/* @Jc2k

View File

@ -196,22 +196,6 @@ async def finish_setup(hass, config):
switches = sorted(hass.states.async_entity_ids("switch"))
lights = sorted(hass.states.async_entity_ids("light"))
# Set up history graph
await bootstrap.async_setup_component(
hass,
"history_graph",
{
"history_graph": {
"switches": {
"name": "Recent Switches",
"entities": switches,
"hours_to_show": 1,
"refresh": 60,
}
}
},
)
# Set up scripts
await bootstrap.async_setup_component(
hass,

View File

@ -1,84 +0,0 @@
"""Support to graphs card in the UI."""
import logging
import voluptuous as vol
from homeassistant.const import ATTR_ENTITY_ID, CONF_ENTITIES, CONF_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
_LOGGER = logging.getLogger(__name__)
DOMAIN = "history_graph"
CONF_HOURS_TO_SHOW = "hours_to_show"
CONF_REFRESH = "refresh"
ATTR_HOURS_TO_SHOW = CONF_HOURS_TO_SHOW
ATTR_REFRESH = CONF_REFRESH
GRAPH_SCHEMA = vol.Schema(
{
vol.Required(CONF_ENTITIES): cv.entity_ids,
vol.Optional(CONF_NAME): cv.string,
vol.Optional(CONF_HOURS_TO_SHOW, default=24): vol.Range(min=1),
vol.Optional(CONF_REFRESH, default=0): vol.Range(min=0),
}
)
CONFIG_SCHEMA = vol.Schema(
{DOMAIN: cv.schema_with_slug_keys(GRAPH_SCHEMA)}, extra=vol.ALLOW_EXTRA
)
async def async_setup(hass, config):
"""Load graph configurations."""
_LOGGER.warning(
"The history_graph integration has been deprecated and is pending for removal "
"in Home Assistant 0.107.0."
)
component = EntityComponent(_LOGGER, DOMAIN, hass)
graphs = []
for object_id, cfg in config[DOMAIN].items():
name = cfg.get(CONF_NAME, object_id)
graph = HistoryGraphEntity(name, cfg)
graphs.append(graph)
await component.async_add_entities(graphs)
return True
class HistoryGraphEntity(Entity):
"""Representation of a graph entity."""
def __init__(self, name, cfg):
"""Initialize the graph."""
self._name = name
self._hours = cfg[CONF_HOURS_TO_SHOW]
self._refresh = cfg[CONF_REFRESH]
self._entities = cfg[CONF_ENTITIES]
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def name(self):
"""Return the name of the entity."""
return self._name
@property
def state_attributes(self):
"""Return the state attributes."""
attrs = {
ATTR_HOURS_TO_SHOW: self._hours,
ATTR_REFRESH: self._refresh,
ATTR_ENTITY_ID: self._entities,
}
return attrs

View File

@ -1,9 +0,0 @@
{
"domain": "history_graph",
"name": "History Graph",
"documentation": "https://www.home-assistant.io/integrations/history_graph",
"requirements": [],
"dependencies": ["history"],
"codeowners": ["@andrey-git"],
"quality_scale": "internal"
}

View File

@ -1 +0,0 @@
"""Tests for the history_graph component."""

View File

@ -1,37 +0,0 @@
"""The tests the Graph component."""
import unittest
from homeassistant.setup import setup_component
from tests.common import get_test_home_assistant, init_recorder_component
class TestGraph(unittest.TestCase):
"""Test the Google component."""
def setUp(self): # pylint: disable=invalid-name
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
def tearDown(self): # pylint: disable=invalid-name
"""Stop everything that was started."""
self.hass.stop()
def test_setup_component(self):
"""Test setup component."""
self.init_recorder()
config = {"history": {}, "history_graph": {"name_1": {"entities": "test.test"}}}
assert setup_component(self.hass, "history_graph", config)
assert dict(self.hass.states.get("history_graph.name_1").attributes) == {
"entity_id": ["test.test"],
"friendly_name": "name_1",
"hours_to_show": 24,
"refresh": 0,
}
def init_recorder(self):
"""Initialize the recorder."""
init_recorder_component(self.hass)
self.hass.start()