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 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

Fixed the api call to use PyPI package

  • Loading branch information...
UgaitzEtxebarria committed Apr 14, 2019
commit 054eb8915d49a1a6d220bb6c74b710a4b2b333a0
@@ -1,2 +1,2 @@
"""The Bizkaibus, Biscays (Basque Country, Spain)
bus service, bus tracker component."""
# The Bizkaibus, Biscays (Basque Country, Spain)
# bus service, bus tracker component.
@@ -11,6 +11,7 @@
from homeassistant.const import CONF_NAME
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.helpers.entity import Entity
from bizkaibus import BizkaibusData

import xml.etree.ElementTree as ET

@@ -79,7 +80,7 @@ def update(self):

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

def __init__(self, stop, route):
@@ -92,45 +93,6 @@ def __init__(self, stop, route):

def update(self):
"""Retrieve the information from API."""
params = {}
params['callback'] = ''
params['strLinea'] = self.route
params['strParada'] = self.stop

response = requests.get(_RESOURCE, params, timeout=10)

if response.status_code != 200: = [{ATTR_ROUTE_NAME: 'n/a',
ATTR_ROUTE: self.route,
ATTR_DUE_IN: 'n/a'}]

strJSON = response.text[1:-2].replace('\'', '"')
result = json.loads(strJSON)

if str(result['STATUS']) != 'OK': = [{ATTR_ROUTE_NAME: 'n/a',
ATTR_ROUTE: self.route,
ATTR_DUE_IN: 'n/a'}]

root = ET.fromstring(result['Resultado']) = []
for childBus in root.findall("PasoParada"):
route = childBus.find('linea').text
routeName = childBus.find('ruta').text
time = childBus.find('e1').find('minutos').text

if (routeName is not None and time is not None and
route is not None and route == self.route):
bus_data = {ATTR_ROUTE_NAME: routeName,
ATTR_ROUTE: route,
ATTR_DUE_IN: time}

if not = [{ATTR_ROUTE_NAME: 'n/a',
ATTR_ROUTE: self.route,
ATTR_DUE_IN: 'n/a'}]
bridge = BizkaibusData(self.stop, self.route)
status =
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.