/zerospy2ha

A simple webhook handler that accepts a trigger from ZeroSpy and passes the state of charge of my Zero Motorcycle's battery to a Home Assistant entity.

Primary LanguageJavaScriptMIT LicenseMIT

zerospy2ha

zerospy2ha is a simple webhook handler that accepts a trigger from ZeroSpy and passes the state of charge of my Zero Motorcycle's battery to a Home Assistant entity.

I wanted to be able to trigger events and notifications about my battery charge level. Since my Zero FXS doesn't have the Cypher III platform on it, I can't get this information from the cloud. I use an old cell phone in the garage which connects to my motorcycle over bluetooth with the ZeroSpy app. ZeroSpy has a trigger set up to report the state of charge at every perentage to zerospy2ha running on an internal docker server. zerospy2ha then reformulates the update into a Home Assistant compatible API call.

Requirements

Setup

  1. Home Assitant
    1. Navigate to your user profile by clicking on your username in the left navigation panel
    2. Go to the 'Long-Lived Access Tokens' section and create a new token
    3. Give it a name and click OK
    4. Copy the token string
    5. HA will automatically create a sensor once the first SOC is POSTed to the API
  2. Docker
    1. Edit index.js and configure the options const to align with your Home Assistant setup
    2. Build the container: docker build -t patfreeman/zerospy2ha .
    3. Run the container: docker run -d --restart=unless-stopped -p 8080:8080 --name zerospy2ha patfreeman/zerospy2ha
  3. ZeroSpy
    1. Once configured to auto-connect to your bike
    2. Click the motorcycle logo in the top bar to get to the Triggers menu
    3. Add a trigger with the + sign
    4. I use 0% + n x 1%, to get a trigger for every percentage of charge change
    5. Set the URL to: http://<your_docker_server>:8080/?soc=%SOC%