Du ser en gammel version af denne side. Se den nuværende version.

Sammenlign med nuværende Vis sidehistorik

Version 1 Næste »

As I am not into python programming, this is kind og a workaround; I assume that some small python code could extend the tojota code to a custom Home Assistant AddOn


Prerequisites

A Linux sever running python 3.6+

An (apache) web server

Pulling https://github.com/calmjm/tojota to the linux server


Changing the tojota code

I will not go into setting up the https://github.com/calmjm/tojota as such, but as the code does make date-marked files, I am changing the code to make a stic filename instead:

These lines are mine:

odometer_file = odometer_path / 'odometer.json'

parking_file = parking_path / 'parking.json'

remote_control_file = remote_control_path / 'remote_control.json'

making sure is a static file each time, that is just overwritting.


Exposing data for the HA Rest service

I am making the files available on the local apache server; same server where Home Assitant runs:

➜  tojota git:(master) ✗ cd /var/www/html/mytoyota 
➜  mytoyota ls -l
total 4
lrwxrwxrwx 1 root root  45 May  4 19:35 odometer.json -> /home/bnp/tojota/cache/odometer/odometer.json
lrwxrwxrwx 1 root root  43 May  5 07:26 parking.json -> /home/bnp/tojota/cache/parking/parking.json
lrwxrwxrwx 1 root root  57 May  4 19:35 remote_control.json -> /home/bnp/tojota/cache/remote_control/remote_control.json
➜  mytoyota 


Fecthing the data via REST, using sensor.yaml:

- platform: rest
  name: Toyota RAV4 Fuel
  resource: http://127.0.0.1/mytoyota/odometer.json
  method: GET
  value_template: '{{ value_json.1.value }}'
  unit_of_measurement: Pct
  scan_interval: 3000

- platform: rest
  name: Toyota RAV4 Mileage
  resource: http://127.0.0.1/mytoyota/odometer.json
  method: GET
  value_template: '{{ value_json.0.value }}'
  unit_of_measurement: Km
  scan_interval: 3000

- platform: rest
  name: Toyota RAV4 Gasoline Travelable Distance
  resource: http://127.0.0.1/mytoyota/remote_control.json
  method: GET
  value_template: '{{ value_json.VehicleInfo.ChargeInfo.GasolineTravelableDistance }}'
  unit_of_measurement: Km
  scan_interval: 3000

- platform: rest
  name: Toyota RAV4 EV Travelable Distance (with EC)
  resource: http://127.0.0.1/mytoyota/remote_control.json
  method: GET
  value_template: '{{ value_json.VehicleInfo.ChargeInfo.EvDistanceWithAirCoInKm }}'
  unit_of_measurement: Km
  scan_interval: 3000

- platform: rest
  name: Toyota RAV4 EV Travelable Distance (without EC)
  resource: http://127.0.0.1/mytoyota/remote_control.json
  method: GET
  value_template: '{{ value_json.VehicleInfo.ChargeInfo.EvTravelableDistance }}'
  unit_of_measurement: Km
  scan_interval: 3000

- platform: rest
  name: Toyota RAV4 Inside Temperature
  resource: http://127.0.0.1/mytoyota/remote_control.json
  method: GET
  value_template: '{{ value_json.VehicleInfo.RemoteHvacInfo.InsideTemperature }}'
  unit_of_measurement: C
  scan_interval: 3000

- platform: rest
  name: Toyota RAV4 Charging Status
  resource: http://127.0.0.1/mytoyota/remote_control.json
  method: GET
  value_template: '{{ value_json.VehicleInfo.ChargeInfo.ChargingStatus }}'
  scan_interval: 3000

  • Ingen etiketter