Skip to content

christophmoar/abrpTelemetrySmartInjector

Repository files navigation

abrpTelemetrySmartInjector

Contributors Forks Stargazers Issues Apache License

This script will fetch vehicle data from a smart-eq api adapter provider on an iobroker installation with a iobroker simple-api rest adapter to push it forward to the iternio abrp (aBetterRoutePlanner) telemetry api. The script will fetch the data from the upstream iobroker adapter every ten seconds, but you should configure your iobroker smart-eq api adapter to fetch the data from the smart api only every few minutes. I suggest something around 5-10 minutes only. Be conservative on this, do not overload the smart #1 api endpoints.

The script will then compare the fetched data with the previous data and decide (depending on various patterns) if the data is considered interesting enough/new enough to be sent to abrp telemetry api. If yes, data is being sent over a http rest call to the abpr telemetry server. The main script remains in an endless loop, repeating every ten seconds. It can/should be launched with the provided docker image, for example.

Getting Started

Public docker image

You can find a prepackaged docker image here https://hub.docker.com/r/christophmoar/smart-hashtag-one-abrp-injector

Installation

The installation should be straight forward for everybody using the provided docker image, for example with the following command.

docker run --env-file .env --name smart-hashtag-one-abrp-injector -d christophmoar/smart-hashtag-one-abrp-injector

Configuration

You will need to setup a few environment variables for the docker. This is usally done with a .env file as you see in the above docker command. The .env file should contain your setup data.

ABRP_TOKEN={your abrp vehicle token, can be created in the abrp app}
PREFIX_IOBROKER_STATE={prefix for your vehicle state data in your iobroker, see example below}
PREFIX_IOBROKER_URL={prefix for the iobroker simple-api rest url, see example below}

You can check the prefix of your iobroker smart-eq adapter and your vehicle identification number (VIN) to setup the PREFIX_IOBROKER_STATE variable. In the usual case that you only have a single smart-eq adapter on iobroker, it will have the number 0, so your PREFIX_IOBROKER_STATE value will be

PREFIX_IOBROKER_STATE=smart-eq.0.HES**************.

where HES**************. is your VIN followed by a single closing period.

The PREFIX_IOBROKER_URL is the http url which exposes the simple-api rest adapter activated in your iobroker installation. You will have chosen a port and protocol (http/https) to expose the rest interface, so complete the configuration accordingly. As an example, in my case its:

PREFIX_IOBROKER_STATE=http://{host}:{port}/getBulk/

Check your logfile

Once you launch your abrpTelemetrySmartInjector docker, check its logfile to see that data is correctly fetched for your vehicle and sent to abrp

docker logs -f smart-hashtag-one-abrp-injector

you should see something similar to the following log output, you see the data being sent to abrp.

(1/2/2024, 1:20:09 PM) INFO: Start sending data...
(1/2/2024, 1:20:09 PM) INFO: usr.abrp.status: ABRP::started
(1/2/2024, 1:20:09 PM) INFO: Significant telemetry change
(1/2/2024, 1:20:09 PM) INFO: Sending telemetry to ABRP {"utc":1704201609,"soc":75,"is_charging":false,"is_parked":true,"ext_temp":9,"est_battery_range":279}

Check your abetterrouteplanner

Once telemetry data has been sent to abrp, you should see it in your app.

image

iobroker configuration

Adapters to be installed and configured on iobroker

You will need the following adapters installed on iobroker.

image

Configure the smart-eq adapter instance with your hellosmart identifiers.

image

Configure the simple-api rest adapter as you like (protocol, ip, port).

image

You should then be able to see the smart data in your objects/states.

image

Data acquired via REST from iobroker

The following vehicle states will be fetched from iobroker

  • 'status.additionalVehicleStatus.electricVehicleStatus.chargeIAct', // corresponding for 'v.c.current'
  • 'status.additionalVehicleStatus.electricVehicleStatus.distanceToEmptyOnBatteryOnly', // corresponding for 'v.b.range.ideal'
  • 'status.additionalVehicleStatus.electricVehicleStatus.chargeLevel', // corresponding for 'v.b.soc'
  • 'status.additionalVehicleStatus.electricVehicleStatus.chargerState', // corresponding for 'v.c.state'
  • 'status.parkTime.status', // corresponding for 'v.e.parktime'
  • 'status.additionalVehicleStatus.climateStatus.exteriorTemp', // corresponding for 'v.e.temp'
  • 'status.basicVehicleStatus.engineStatus', // corresponding for 'hx11.v.p.enginestatus'

The data is fetched via the getBulk rest endpoint, such as in:

http://host:port/getBulk/smart-eq.0.{VIN}.remote.conditioner,smart-eq.0.{VIN}.remote.lock

Which yields a json response with this style:

image

Development notes

If you want to generate your own docker image from this repository, go ahead.

Generating docker image

docker system prune -a 
docker build -t {your dockerhub username}/smart-hashtag-one-abrp-injector .

Launching docker

docker run --env-file .env --name smart-hashtag-one-abrp-injector -d {your dockerhub username}/smart-hashtag-one-abrp-injector

Publishing docker

docker login -u {your dockerhub username} 
docker push {your dockerhub username}/smart-hashtag-one-abrp-injector

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Christoph Moar - @christophmoar.bsky.social

Project Link: https://github.com/christophmoar/abrpTelemetrySmartInjector

Acknowledgments

This project relies on or is based on code from the following fine projects:

About

abrp telemetry injector for smart #1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published