syssi / nextbike

Nextbike integration for Home Assistant
Apache License 2.0
15 stars 4 forks source link

Get the nearest bikes as geolocation-sensors to display in the map #2

Open hendrikma opened 3 years ago

hendrikma commented 3 years ago

Hey folks,

I loaded the Nexbike integration a few days ago and am very excited! It is part of my daily routine before I leave the house to check where the nearest bikes are, since I am very much on the road with it.

Unfortunately, the addon only allows me to check how many bikes exist in a specified radius. Here in Cologne, no stations are used, but the bikes are everywhere on the streets around.

It would be super helpful if you could display the nearby bikes in the map.

So far I have solved it like this:

sensor:
 - platform: nextbike
    name: Nextbike Radius Home 150
    city_id: !secret nextbike_city
    latitude: !secret nextbike_lat
    longitude: !secret nextbike_lon
    radius: 150

template:
  - binary_sensor:
    - name: Nextbike Closest Bike
      icon: mdi:bike
      state: >
        {% if states('sensor.nextbike_radius_home_150') | float > 0 %} on {% endif %}
      attributes:
        latitude: >
          {% if states('sensor.nextbike_radius_home_150') | float > 0 %}
            {{ state_attr('sensor.nextbike_radius_home_150', 'closest_latitude') }}
          {% else %}
            {{ state_attr('zone.home', 'latitude') }}
          {% endif %}
        longitude: >
          {% if states('sensor.nextbike_radius_home_150') | float > 0 %}
            {{ state_attr('sensor.nextbike_radius_home_150', 'closest_longitude') }}
          {% else %}
            {{ state_attr('zone.home', 'longitutde') }}
          {% endif %}
        bike: >
          {{ state_attr('sensor.nextbike_radius_home_150', 'closest_bikes') }}

Unfortunately, this goes only for the closest bike! But I would like to be able to see, for example, the nearest 5 bikes in the map!

pschonmann commented 2 weeks ago

+1

pschonmann commented 2 weeks ago

Is possible to make sensor use my actual lat/lon for near bikes to change dynamically ? This shows only near bikes in my home