mirror of
https://github.com/home-assistant/core.git
synced 2025-08-06 06:05:10 +02:00
Remove the ruter integration (#26041)
This commit is contained in:
committed by
Martin Hjelmare
parent
a2589f56e1
commit
ef8bc78c53
@@ -534,7 +534,6 @@ omit =
|
|||||||
homeassistant/components/rtorrent/sensor.py
|
homeassistant/components/rtorrent/sensor.py
|
||||||
homeassistant/components/russound_rio/media_player.py
|
homeassistant/components/russound_rio/media_player.py
|
||||||
homeassistant/components/russound_rnet/media_player.py
|
homeassistant/components/russound_rnet/media_player.py
|
||||||
homeassistant/components/ruter/sensor.py
|
|
||||||
homeassistant/components/sabnzbd/*
|
homeassistant/components/sabnzbd/*
|
||||||
homeassistant/components/satel_integra/*
|
homeassistant/components/satel_integra/*
|
||||||
homeassistant/components/scrape/sensor.py
|
homeassistant/components/scrape/sensor.py
|
||||||
|
@@ -222,7 +222,6 @@ homeassistant/components/repetier/* @MTrab
|
|||||||
homeassistant/components/rfxtrx/* @danielhiversen
|
homeassistant/components/rfxtrx/* @danielhiversen
|
||||||
homeassistant/components/rmvtransport/* @cgtobi
|
homeassistant/components/rmvtransport/* @cgtobi
|
||||||
homeassistant/components/roomba/* @pschmitt
|
homeassistant/components/roomba/* @pschmitt
|
||||||
homeassistant/components/ruter/* @ludeeus
|
|
||||||
homeassistant/components/scene/* @home-assistant/core
|
homeassistant/components/scene/* @home-assistant/core
|
||||||
homeassistant/components/scrape/* @fabaff
|
homeassistant/components/scrape/* @fabaff
|
||||||
homeassistant/components/script/* @home-assistant/core
|
homeassistant/components/script/* @home-assistant/core
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
"""The ruter component."""
|
|
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"domain": "ruter",
|
|
||||||
"name": "Ruter",
|
|
||||||
"documentation": "https://www.home-assistant.io/components/ruter",
|
|
||||||
"requirements": [
|
|
||||||
"pyruter==1.1.0"
|
|
||||||
],
|
|
||||||
"dependencies": [],
|
|
||||||
"codeowners": [
|
|
||||||
"@ludeeus"
|
|
||||||
]
|
|
||||||
}
|
|
@@ -1,93 +0,0 @@
|
|||||||
"""A sensor to provide information about next departures from Ruter."""
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
|
||||||
from homeassistant.const import CONF_NAME
|
|
||||||
from homeassistant.helpers.entity import Entity
|
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
CONF_STOP_ID = "stop_id"
|
|
||||||
CONF_DESTINATION = "destination"
|
|
||||||
CONF_OFFSET = "offset"
|
|
||||||
|
|
||||||
DEFAULT_NAME = "Ruter"
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|
||||||
{
|
|
||||||
vol.Required(CONF_STOP_ID): cv.positive_int,
|
|
||||||
vol.Optional(CONF_DESTINATION): cv.string,
|
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
|
||||||
vol.Optional(CONF_OFFSET, default=0): cv.positive_int,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
|
||||||
"""Create the sensor."""
|
|
||||||
from pyruter.api import Departures
|
|
||||||
|
|
||||||
_LOGGER.warning(
|
|
||||||
"The API used in this sensor is shutting down soon, "
|
|
||||||
"you should consider starting to use the "
|
|
||||||
"'entur_public_transport' sensor instead"
|
|
||||||
)
|
|
||||||
stop_id = config[CONF_STOP_ID]
|
|
||||||
destination = config.get(CONF_DESTINATION)
|
|
||||||
name = config[CONF_NAME]
|
|
||||||
offset = config[CONF_OFFSET]
|
|
||||||
|
|
||||||
session = async_get_clientsession(hass)
|
|
||||||
ruter = Departures(hass.loop, stop_id, destination, session)
|
|
||||||
sensor = [RuterSensor(ruter, name, offset)]
|
|
||||||
async_add_entities(sensor, True)
|
|
||||||
|
|
||||||
|
|
||||||
class RuterSensor(Entity):
|
|
||||||
"""Representation of a Ruter sensor."""
|
|
||||||
|
|
||||||
def __init__(self, ruter, name, offset):
|
|
||||||
"""Initialize the sensor."""
|
|
||||||
self.ruter = ruter
|
|
||||||
self._attributes = {}
|
|
||||||
self._name = name
|
|
||||||
self._offset = offset
|
|
||||||
self._state = None
|
|
||||||
|
|
||||||
async def async_update(self):
|
|
||||||
"""Get the latest data from the Ruter API."""
|
|
||||||
await self.ruter.get_departures()
|
|
||||||
if self.ruter.departures is None:
|
|
||||||
_LOGGER.error("No data received from Ruter.")
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
data = self.ruter.departures[self._offset]
|
|
||||||
self._state = data["time"]
|
|
||||||
self._attributes["line"] = data["line"]
|
|
||||||
self._attributes["destination"] = data["destination"]
|
|
||||||
except (KeyError, IndexError) as error:
|
|
||||||
_LOGGER.debug("Error getting data from Ruter, %s", error)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the sensor."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def state(self):
|
|
||||||
"""Return the state of the sensor."""
|
|
||||||
return self._state
|
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Return the icon of the sensor."""
|
|
||||||
return "mdi:bus"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_state_attributes(self):
|
|
||||||
"""Return attributes for the sensor."""
|
|
||||||
return self._attributes
|
|
@@ -1361,9 +1361,6 @@ pyrecswitch==1.0.2
|
|||||||
# homeassistant.components.repetier
|
# homeassistant.components.repetier
|
||||||
pyrepetier==3.0.5
|
pyrepetier==3.0.5
|
||||||
|
|
||||||
# homeassistant.components.ruter
|
|
||||||
pyruter==1.1.0
|
|
||||||
|
|
||||||
# homeassistant.components.sabnzbd
|
# homeassistant.components.sabnzbd
|
||||||
pysabnzbd==1.1.0
|
pysabnzbd==1.1.0
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user