Sidehistorik
Tip |
---|
You can use https://github.com/DurgNomis-drol/ha_toyota instead, many of the same data (and more) are present. As I am not into python programming, this is kind og of a workaround; I assume that some small python code could extend the tojota code to a custom Home Assistant AddOn. As the output is json, it can be imported into Splunk, Humio, Power BI, E(LK), DataDog Logs etc etc - pretty easy. Most of these just require a collector application/agent on the server. |
Prerequisites
A Linux sever running python 3.6+
...
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 static filename instead:. This must be done every time a new version is pulled from guthub.
These lines are mine (replacing existing lines):
Kodeblok |
---|
# coding=utf-8
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 overwrittingbeing overwritten.
I am running the this code from cron to get the data from MyT:
Kodeblok | ||||
---|---|---|---|---|
| ||||
#!/bin/bash cd /home/bnp source /home/bnp/tojota/bin/activate export PYTHONIOENCODING=utf8 cd /home/bnp/tojota python tojota.py |
Info |
---|
https://github.com/calmjm/tojota also downloads Trips, but I have found no usage for the currently in Home Assistant.. |
Exposing data for the HA Rest service
...
Kodeblok |
---|
- 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 - platform: rest name: Toyota RAV4 Parking resource: http://127.0.0.1/mytoyota/parking.json method: GET value_template: '{{ value_json.result }}' scan_interval: 3000 json_attributes_path: $.event json_attributes: - lat - lon |
Getting the GPS Data on a Device
In known_devices.yaml I create the car:
Kodeblok |
---|
rav4:
hide_if_away: false
icon: mdi:car
name: Toyota Rav4
track: true |
And an automation set the lat and lon onto the device:
Kodeblok |
---|
alias: Update Car Tracker
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: sensor.toyota_rav4_parking
condition: []
action:
- service: device_tracker.see
data:
dev_id: rav4
gps:
- '{{ state_attr(''sensor.toyota_rav4_parking'', ''lat'') }}'
- '{{ state_attr(''sensor.toyota_rav4_parking'', ''lon'') }}'
mode: single |