Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bizkaibus, Biscays (Spain) bus service component #22934

merged 19 commits into from May 5, 2019
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -53,6 +53,7 @@ omit =
@@ -32,6 +32,7 @@ homeassistant/components/automation/* @home-assistant/core
homeassistant/components/aws/* @awarecan @robbiet480
homeassistant/components/axis/* @kane610
homeassistant/components/bitcoin/* @fabaff
homeassistant/components/bizkaibus/* @UgaitzEtxebarria
homeassistant/components/blink/* @fronzbot
homeassistant/components/bmw_connected_drive/* @ChristianKuehnel
homeassistant/components/braviatv/* @robbiet480
@@ -0,0 +1 @@
"""The Bizkaibus bus tracker component."""
@@ -0,0 +1,8 @@
"domain": "bizkaibus",
"name": "Bizkaibus",
"documentation": "",
"dependencies": [],
"codeowners": ["@UgaitzEtxebarria"],
"requirements": ["bizkaibus==0.1.1"]
@@ -0,0 +1,88 @@
"""Support for Bizkaibus, Biscay (Basque Country, Spain) Bus service."""

import logging

import voluptuous as vol
from bizkaibus.bizkaibus import BizkaibusData
import homeassistant.helpers.config_validation as cv

from homeassistant.const import CONF_NAME
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.helpers.entity import Entity

_LOGGER = logging.getLogger(__name__)

ATTR_DUE_IN = 'Due in'

CONF_STOP_ID = 'stopid'
CONF_ROUTE = 'route'

DEFAULT_NAME = 'Next bus'

vol.Required(CONF_STOP_ID): cv.string,
vol.Required(CONF_ROUTE): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Bizkaibus public transport sensor."""
name = config.get(CONF_NAME)
This conversation was marked as resolved by ludeeus

This comment has been minimized.

Copy link

ludeeus Apr 18, 2019


For required options, you should use dict['key'] instead of dict.get('key')

stop = config[CONF_STOP_ID]
route = config[CONF_ROUTE]

data = Bizkaibus(stop, route)
add_entities([BizkaibusSensor(data, stop, route, name)], True)

class BizkaibusSensor(Entity):
"""The class for handling the data."""

def __init__(self, data, stop, route, name):
"""Initialize the sensor.""" = data
self.stop = stop
self.route = route
self._name = name
self._state = None

def name(self):
"""Return the name of the sensor."""
return self._name

def state(self):
"""Return the state of the sensor."""
return self._state

def unit_of_measurement(self):
"""Return the unit of measurement of the sensor."""
return 'minutes'

def update(self):
"""Get the latest data from the webservice."""
self._state =[0][ATTR_DUE_IN]

This comment has been minimized.

Copy link

MartinHjelmare May 5, 2019


We're trying to move new departure time type sensors over to use the timestamp device class. That means reporting an absolute utc ISO timestamp instead of a relative time as state.

We should keep this in mind for the future development of this platform.

except TypeError:

class Bizkaibus:
"""The class for handling the data retrieval."""

def __init__(self, stop, route):
"""Initialize the data object."""
self.stop = stop
self.route = route = None

def update(self):
"""Retrieve the information from API."""
bridge = BizkaibusData(self.stop, self.route)
bridge.getNextBus() =
@@ -217,6 +217,9 @@ bellows-homeassistant==0.7.2
# homeassistant.components.bmw_connected_drive

# homeassistant.components.bizkaibus

# homeassistant.components.blink

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.