ZERO Motocycles Integrations in Home Assistant

Like a TESLA you can integrate ZERO Motocycles in Home Assistant:
Turns out you can also use a plain URL in your browser :
https://mongol.brono.com/mongol/api.php?commandname=get_units&format=json&user= yourusername &pass= yourpass

to get your unitnumber you have to use in the URL below

https://mongol.brono.com/mongol/api.php?commandname=get_last_transmit&format=json&user= yourusername &pass= yourpass &unitnumber= 0000000

obviously you would have to alter :
yourusername to the username you have entered in the NextGen app
yourpass to the password you ised in the nextgen app

you can change the format=json to format is CSV for CSV response, or to format=XML for XML respone, or to format=HTTP for also comma seperated values. And possibly there are more formats you can use.

In HomeAssistant coniguration.yaml:

ZERO SR/F

  • platform: rest
    name: Zero SR/F
    resource: https://mongol.brono.com/mongol/api.php?commandname=get_last_transmit&format=json&user=USERNAME&pass=TopSecret123&unitnumber=123456
    scan_interval: 120
    json_attributes:
    • unitnumber
    • name
    • mileage
    • main_voltage
    • longitude
    • latitude
    • altitude
    • soc
    • address
    • tipover
    • charging
    • chargecomplete
    • pluggedin
    • chargingtimeleft
      value_template: ‘{{ states.sensor.zero_sr_f.attributes[“address”] }}’
  • platform: template
    sensors:
    zero_unitnumber:
    friendly_name: Unitnummer
    value_template: ‘{{ states.sensor.zero_sr_f.attributes[“unitnumber”] }}’
    zero_name:
    friendly_name: Seriennummer
    value_template: ‘{{ states.sensor.zero_sr_f.attributes[“name”] }}’
    zero_mileage:
    friendly_name: Kilometerstand
    icon_template: mdi:counter
    value_template: ‘{{ states.sensor.zero_sr_f.attributes[“mileage”] }}’
    unit_of_measurement: ‘km’

1 Like

I am not able to copy paste this into configuration.yaml it says duplicate keys errors. Is there a way you can share it in proper code form and indention. Or is it because it’s and old way of doing this and it needs to be re-written. Just stumbled on this would be cool to have this data in HA.
Thanks in advance. :slight_smile:

sensor:
  # ZERO SR/F
  - platform: rest
    name: Zero SR/F
    resource: https://mongol.brono.com/mongol/api.php?commandname=get_last_transmit&format=json&user=USERNAME&pass=PASSWORD&unitnumber=UNITNUMBER
    scan_interval: 90
    json_attributes:
      - unitnumber
      - name
      - mileage
      - software_version
      - main_voltage
      - longitude
      - latitude
      - altitude
      - soc
      - address
      - tipover
      - charging
      - chargecomplete
      - pluggedin
      - chargingtimeleft
    value_template: '{{ states.sensor.zero_sr_f.attributes["address"] }}'
  - platform: template
    sensors:
      zero_unitnumber:
        friendly_name: Unitnummer
        value_template: '{{ states.sensor.zero_sr_f.attributes["unitnumber"] }}'
      zero_name:
        friendly_name: Seriennummer
        value_template: '{{ states.sensor.zero_sr_f.attributes["name"] }}'
      zero_mileage:
        friendly_name: Meilenstand
        icon_template: mdi:counter
        value_template: '{{ states.sensor.zero_sr_f.attributes["mileage"] }}'
        unit_of_measurement: 'miles'
      zero_km:
        friendly_name: Odometer
        icon_template: mdi:counter
        value_template: '{{ (states.sensor.zero_sr_f.attributes["mileage"] | float * 1.08194939878576) | round(2) }}'
        unit_of_measurement: 'km'
      zero_software_version:
        friendly_name: Zero SW-Version
        icon_template: mdi:microsoft-windows-classic
        value_template: '{{ states.sensor.zero_sr_f.attributes["software_version"] }}'
      zero_main_voltage:
        friendly_name: Zero Batterie
        icon_template: mdi:car-battery
        value_template: '{{ states.sensor.zero_sr_f.attributes["main_voltage"] }}'
        unit_of_measurement: 'V'
      zero_longitude:
        friendly_name: Zero Longitude
        value_template: '{{ states.sensor.zero_sr_f.attributes["longitude"] }}'
      zero_latitude:
        friendly_name: Zero Latitude
        value_template: '{{ states.sensor.zero_sr_f.attributes["latitude"] }}'
      zero_altitude:
        friendly_name: Zero Altitude
        value_template: '{{ states.sensor.zero_sr_f.attributes["altitude"] }}'
        unit_of_measurement: 'm ü. M.'
      zero_soc:
        friendly_name: Akkustand
        value_template: '{{ states.sensor.zero_sr_f.attributes["soc"] }}'
        unit_of_measurement: '%'
        device_class: battery
      zero_address:
        friendly_name: Adresse
        icon_template: mdi:map-marker
        value_template: '{{ states.sensor.zero_sr_f.attributes["address"] }}'
      zero_tipover:
        friendly_name: Km seit aufgeladen
        value_template: '{{ states.sensor.zero_sr_f.attributes["tipover"] }}'
        unit_of_measurement: 'km'
      zero_charging:
        friendly_name: Laden
        value_template: '{{ states.sensor.zero_sr_f.attributes["charging"] }}'
      zero_chargecomplete:
        friendly_name: Laden beendet
        value_template: '{{ states.sensor.zero_sr_f.attributes["chargecomplete"] }}'
      zero_pluggedin:
        friendly_name: Eingesteckt
        value_template: '{{ states.sensor.zero_sr_f.attributes["pluggedin"] }}'
      zero_chargingtimeleft:
        friendly_name: Laden beendet in
        value_template: '{{ states.sensor.zero_sr_f.attributes["chargingtimeleft"] }}'
        icon_template: mdi:clock-end
        unit_of_measurement: 'Minuten'

Change:
user=Your USERNAME
pass=Your PASSWORD
unitnumber=Your UNITNUMBER

Thanks man, for taking time to change the layout, much appreciated. :slight_smile: Look forward to test this later.
Perhaps I should look into learning how to create something for HACS so there be a nice integration for Zero stuff.
Update: Works great. I just don’t have no luck saying that’s it’s home, despite my app on my phone says I am home, so it knows!
also is this Zero’s own public API we are calling or some third party in front ?
How did you create the card ‘Wo ist Zero’ It’s cool to know as well. :slight_smile:
Thanks again.

I’m running into an error every time I try to use the link you provided. It keeps giving me “601 Unauthorized user (…)”. I’m using the same username for my Zero NG app. Any ideas how to fix that? Thanks.

Be sure you have the right Unitnumber. To get this Number use this link in a borwser:

https://mongol.brono.com/mongol/api.php?commandname=get_units&format=json&user=YOURUSER&pass=YOURPASS

Change:
YOURUSER=Your USERNAME
YOURPASS=Your PASSWORD

so you can get the Unitnumber (6 digit)

Then use this Link:

https://mongol.brono.com/mongol/api.php?commandname=get_last_transmit&format=json&user=YOURUSER&pass=YOURPASS&unitnumber=UNITNUMBER

I’m still getting an error 601 authorized user with that link.

My username in the NG app is an email, would that be causing the problem?

I created a package file to bundle up all of the sensors plus device tracker automation I’ve created, based on the information provided in this thread, and tossed it up on GitHub as a Gist.

The markdown file explains how to install it, and how to enable the Package function in Home Assistant if you haven’t already.

I figure this is the next best thing to an actual integration in Home Assistant, since I keep bouncing off the Python every time I try to write one. I can’t quite wrap my head around dealing with asyncio objects.

Works like a charm, thanks a lot!
I’ve combined this with the Google Sheets integration. Wtih an added entity (see below) and a couple of automations I’m now keeping track of every trip I make (address from-to, milage, etc), removing the need to do this by hand.

- name: Zero driving
        unique_id: zero_driving
        state: "{{states('sensor.zero_speed')|float > 0 and states('binary_sensor.zero_on')}}"
        device_class: running
        delay_on:
          minutes: 1
        delay_off:
          minutes: 5
        attributes:
          unitnumber: "{{ state_attr('sensor.zero_sr_s', 'unitnumber') }}"

@mobiustorr I had problems logging in as well. Ended up having to change my password, but that solved it.

Thanks for sharing your implementation. I’ve made an integration for this including device_tracker. That way you can just add the git repo to hacs and then add it without having to worry about the API or sensor templates.

The only reason it’s not submitted to the default repository is because that requires me to submit branding first and I know from earlier experience that zero actively kills anything not official.

Reviving this old thread in case future nerds run into this issue like we did.

My username in the NG app is an email, would that be causing the problem?

In short; yes that is exactly what’s causing your problem. Fortunately the fix is simple, and obvious after I thought about it.

You need to utilize URL encoding for your ASCII symbols. So if your email address has an “@” then you need to replace it with “%40”. So if your login is [email protected] then you would need to use: &user=username%40example.com

I did the same thing for the symbols in my password as well. At any rate, it works!