This custom integration adds availability sensors for a single PubliBike station in Switzerland.
- Interactive setup flow:
- Type part of the station name, city, or address to search.
- Search includes stations from both the new Velospot response and legacy PubliBike stations.
- Legacy PubliBike stations are shown with a
(legacy)suffix in the selection list. - If multiple stations match (e.g., “Bahnhof”), pick the right one from a dropdown.
- Sensors provided:
- Bikes available
- E-bikes available
- Station state (e.g., Active, Active (empty), Inactive)
- Rich attributes on all sensors: station ID, name, city, address, ZIP, coordinates, and capacity.
- Options flow to change the selected station later without re-adding the integration.
- Cloud polling of the PubliBike public API every 5 minutes.
- Unique IDs for all entities.
See below for examples, troubleshooting, and notes.
You can install manually or as a custom repository in HACS.
- Copy the
custom_components/publibike_stationsfolder into your Home Assistantcustom_componentsdirectory. - Restart Home Assistant.
- Open HACS → Integrations.
- Click the three-dots menu → Custom repositories.
- Add your repository URL and select category “Integration”.
- Install the integration.
- Restart Home Assistant.
Now you are ready to add one or more instances of the integration.
- Open Home Assistant Settings → Devices & Services.
- Click “Add Integration”.
- Search for “PubliBike Stations” and proceed.
- Enter a search term for your station (you can type part of the name, city, or address).
- If more than one station matches, you will get a dropdown to select the exact station.
- Finish the setup. Your sensors are created immediately.
Tip: You can later change the station via the integration’s “Configure” option (Options Flow).
- Search API:
- GET https://rest.publibike.ch/v1/public/all/stations
- Used during setup/options to find your station by name across:
velospot.responseData(new)publibike.stations(legacy, labeled(legacy)in search results)
- Background on this transition: Net Harmonization
- Station detail API (polled every 5 minutes):
- GET https://rest.publibike.ch/v1/public/stations/[STATIONID]
- Used to determine:
- Bikes available
- E-bikes available
- Station state
E-bikes are detected from the vehicle type information provided by the API.
You will get three sensors (the exact entity IDs depend on your chosen station name):
- Bikes available
- Example:
sensor.piazza_molino_nuovo_bikes_available
- Example:
- E-bikes available
- Example:
sensor.piazza_molino_nuovo_e_bikes_available
- Example:
- Station state
- Example:
sensor.piazza_molino_nuovo_station_state
- Example:
All sensors include attributes such as station ID, city, address, ZIP, latitude/longitude, and capacity.
alias: Notify when e-bike available
trigger:
- platform: numeric_state
entity_id: sensor.publibike_station_e_bikes_available
above: 0
condition: []
action:
- service: notify.mobile_app_your_phone
data:
message: "An e-bike is now available at your PubliBike station."
title: "PubliBike"
mode: singleReplace sensor.publibike_station_e_bikes_available with your actual entity ID.
template:
- sensor:
- name: "PubliBike total vehicles"
unique_id: publibike_total_vehicles_example
state: >-
{{
(states('sensor.publibike_station_bikes_available')|int(0)) +
(states('sensor.publibike_station_e_bikes_available')|int(0))
}}Replace the entity IDs to match your station’s sensors.
This integration ships with local brand assets so the integration tile shows a proper logo/icon:
custom_components/publibike_stations/icon.svg(square icon)custom_components/publibike_stations/logo.svg(horizontal logo)
If distributing publicly (e.g., via HACS default), consider contributing the same assets to the official brands repository so users get consistent branding without local files:
- https://github.com/home-assistant/brands
- Path:
custom_integrations/publibike_stations/(includeicon.svg/icon.png,logo.svg/logo.png).
- “Unknown error occurred” during station selection:
- Make sure you’re on version 0.1.2 or newer. The selection step uses a simple, widely compatible dropdown (no special UI selectors required).
- API/network issues:
- The PubliBike API is polled every 5 minutes. If the service is down or unreachable, sensors may briefly show unavailable.
- Enable debug logging:
logger:
default: warning
logs:
aiohttp.client: debug
custom_components.publibike_stations: debugThen restart Home Assistant and check your logs.
- Switching stations:
- Use the integration’s “Configure” → search and pick a new station. No need to remove or re-add the integration.
- Entities and unique IDs:
- Entities come with stable unique IDs. If you rename entities, the names will persist across updates.
This integration calls the public PubliBike API:
- https://rest.publibike.ch
- No credentials or personal information are sent.
- Only the selected station ID is used during polling.
- Issues and feature requests: open an issue in your repository (e.g., GitHub issues for this integration).
© Your Name or Organization. Not affiliated with PubliBike.