Giter VIP home page Giter VIP logo

emt_madrid's Introduction

Please โญ this repo if you find it useful

EMT Madrid bus platform for Home Assistant

This is a custom sensor for Home Assistant that allows you to have the waiting time for a specific Madrid-EMT bus stop. Each sensor will provide the arrival time for the next 2 buses of the line specified in the configuration.

Thanks to EMT Madrid MobilityLabs for providing the data and documentation.

Example

Prerequisites

To use the EMT Mobilitylabs API you need to register in their website. You have to provide a valid email account and a password that will be used to configure the sensor. Once you are registered you will receive a confirmation email to activate your account. It will not work until you have completed all the steps.

Manual Installation

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).

  2. If you do not have a custom_components directory (folder) there, you need to create it.

  3. In the custom_components directory (folder) create a new folder called emt_madrid.

  4. Download all the files from the custom_components/emt_madrid/ directory (folder) in this repository.

  5. Place the files you downloaded in the new directory (folder) you created.

  6. Restart Home Assistant

  7. Add emt_madrid sensor to your configuration.yaml file:

    # Example configuration.yaml entry
    sensor:
      - platform: emt_madrid
        email: !secret EMT_EMAIL
        password: !secret EMT_PASSWORD
        stop: "72"
        line: "27"
        name: "Bus 27 en Cibeles"
        icon: "mdi:fountain"

Configuration Variables

email:
(string) (Required)
Email account used to register in the EMT Madrid API.

password:
(string) (Required)
Password used to register in the EMT Madrid API.

stop:
(string) (Required)
Bus stop ID.

line:
(string) (Required)
Bus line that stops at the previous bus stop.

name:
(string) (Optional)
Name to use in the frontend. Default value: "Bus <bus_line> at <bus_stop>"

icon:
(string) (Optional)
Icon to use in the frontend. Default value: "mdi:bus"

Sensor status and attributes

Once you have you sensor up and running it will update the data automatically every 30 seconds and you should have the following data:

state:
(int)
Arrival time in minutes for the next bus. It will show "-" when there are no more buses coming and 30 when the arrival time is over 30 minutes.

Attributes

later_bus:
(int)
Arrival time in minutes for the second bus. It will show "-" when there are no more buses coming and 30 when the arrival time is over 30 minutes.

bus_stop_id:
(int)
Bus stop id given in the configuration.

bus_line:
(int)
Bus line given in the configuration.

Second bus sensor

If you want to have a specific sensor to show the arrival time for the second bus, you can add the following lines to your configuration.yaml file below the emt_madrid bus sensor. See the official Home Assistant template sensor for more information.

# Example configuration.yaml entry
- platform: template
  sensors:
    siguiente_27:
      friendly_name: "Siguiente bus 27"
      unit_of_measurement: "min"
      value_template: "{{ state_attr('sensor.bus_27_en_cibeles', 'later_bus') }}"

emt_madrid's People

Contributors

fermartv avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.