txefoedu
Forero Experto
- Vehículo/s
- Corolla 125H AT NG19
Hace poco en un hilo lei que alguien comentó que se había hecho una "web" para obtener datos de su Corolla usando la API de Toyota.
Me quedé con curiosidad de investigar sobre eso, y hace un rato he encontrado en Github un proyecto en Python para tener acceso a esos datos.
GitHub - calmjm/tojota: Functions for interacting with Toyota MyT API
Los requerimientos pueden no ser triviales para quien no sea "medio informático".
Tenía el Python instalado por un curso de Odoo que hice hace un tiempo y he conseguido sacar algunos datos en "bruto". Como mi coche es del 2019 me fallaba al intentar obtener el nivel de combustible. Me he cargado la parte del código que preguntaba por esos datos y funcionando. Con un coche más moderno seguramente funcione sin tener que retocar nada del código.
Estos son los datos que he conseguido de los 2 viajes largos que hice en la vuelta de vacaciones. Pongo en negrita datos que me han llamado la atención.
{"id": "d8ae89a5", "category": 0, "summary": {"length": 204530, "duration": 7076, "durationIdle": 16, "countries": ["ES"], "maxSpeed": 135.0, "averageSpeed": 104.06, "lengthOverspeed": 34897, "durationOverspeed": 1172, "lengthHighway": 182281, "durationHighway": 5885, "fuelConsumption": 8736.0, "startTs": "2024-08-31T12:21:02Z", "endTs": "2024-08-31T14:18:33Z", "nightTrip": false}, "scores": {"acceleration": 94, "braking": 95, "global": 95, "constantSpeed": 89, "advice": 7}, "behaviours": {"ts": "2024-08-31T12:21:40Z", "type": "B", "good": false, "diagnosticMsg": 2, "coachingMsg": 2, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 128}], "context": {"slope": -0.0}, "priority": true, "severity": 46.82}, {"ts": "2024-08-31T12:21:45Z", "type": "B", "good": false, "diagnosticMsg": 2, "coachingMsg": 2, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 108}], "context": {"slope": -0.23114729872510126}, "priority": true, "severity": 35.8}, {"ts": "2024-08-31T14:11:50Z", "type": "A", "good": true, "diagnosticMsg": 40, "coachingMsg": 1, "context": {"slope": 6.251540929867111}, "priority": true, "severity": 191.4}, {"ts": "2024-08-31T14:10:05Z", "type": "B", "good": false, "diagnosticMsg": 6, "coachingMsg": 6, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 123}], "context": {"slope": -1.0632393558708426}, "priority": true, "severity": 214.7}, {"ts": "2024-08-31T12:29:00Z", "type": "C", "good": true, "diagnosticMsg": 50, "coachingMsg": 31, "context": {"slope": -0.002059022484849148}, "priority": true, "severity": 10000.0}], "hdc": {"evTime": 1910, "evDistance": 45136}}
{"id": "594158d1", "category": 0, "summary": {"length": 311952, "duration": 10843, "durationIdle": 129, "countries": ["ES"], "maxSpeed": 131.0, "averageSpeed": 103.57, "lengthOverspeed": 34984, "durationOverspeed": 1129, "lengthHighway": 299925, "durationHighway": 9864, "fuelConsumption": 14166.0,: -6.0509, "startTs": "2024-08-31T08:45:58Z", "endTs": "2024-08-31T11:45:40Z", "nightTrip": false}, "scores": {"acceleration": 98, "braking": 97, "global": 98, "constantSpeed": 78, "advice": 2}, "behaviours": [{"ts": "2024-08-31T08:56:50Z", "type": "B", "good": false, "diagnosticMsg": 2, "coachingMsg": 2, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 132}], "context": {"slope": 0.0}, "priority": true, "severity": 264.31}, {"ts": "2024-08-31T11:44:10Z", "type": "B", "good": false, "diagnosticMsg": 3, "coachingMsg": 3, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 105}], "context": {"slope": 0.0}, "priority": true, "severity": 239.64}, {"ts": "2024-08-31T09:01:25Z", "type": "C", "good": true, "diagnosticMsg": 50, "coachingMsg": 31, "context": {"slope": 0.0}, "priority": true, "severity": 10000.0}, {"ts": "2024-08-31T08:50:15Z", "type": "B", "good": true, "diagnosticMsg": 33, "coachingMsg": 1, "context": {"slope": 0.0}, "priority": true, "severity": 10000.0}, {"ts": "2024-08-31T11:43:53Z", "type": "B", "good": true, "diagnosticMsg": 33, "coachingMsg": 1, "context": {"slope": 0.0}, "priority": true, "severity": 10000.0}], "hdc": {"evTime": 1942, "evDistance": 46414}}
Por CLI da un resumen de datos así. En algún otro coche o modelo más moderno tal vez te controle cuánto tiempo has ido en eco/power/charging:
2024-09-02 12:21:16-> 2024-09-02 12:33:34 43.2157 -2.4039: 7.621 km, 34.38 km/h, 2.61 l/100 km, 0.20 l
Time stats: EV: 72% eco: 0% power: 0% charging: 0%
Distance stats: EV: 77% eco: 0% power: 0% charging: 0%
2024-08-31 16:43:09-> 2024-08-31 16:54:13 43.1898 -2.4543: 6.908 km, 36.73 km/h, 3.10 l/100 km, 0.21 l
Time stats: EV: 75% eco: 0% power: 0% charging: 0%
Distance stats: EV: 61% eco: 0% power: 0% charging: 0%
2024-08-31 14:21:02-> 2024-08-31 16:18:33 43.1799 -2.4887: 204.53 km, 104.06 km/h, 4.27 l/100 km, 8.74 l
Time stats: EV: 27% eco: 0% power: 0% charging: 0%
Distance stats: EV: 22% eco: 0% power: 0% charging: 0%
2024-08-31 10:45:58-> 2024-08-31 13:45:40 42.1778 -4.0598: 311.952 km, 103.57 km/h, 4.54 l/100 km, 14.17 l
Time stats: EV: 18% eco: 0% power: 0% charging: 0%
Distance stats: EV: 15% eco: 0% power: 0% charging: 0%
Total distance: 737.724 km, Fuel consumption: 30.54 l, 4.14 l/100 km
La app antigua daba el dato de máxima velocidad del trayecto, y el dato se sigue guardando, solo que la nueva app MyT no lo muestra. También parece que te controla cuánta distancia y tiempo has hecho por autopista. Y lo que más me preocupa. Esos campos de lenghtOverspeed y durationOverspeed... ¿se referirán al tiempo y distancia que has ido por encima de los límites de velocidad? En viajes más cortos sin autopista no me marca nada de Overspeed... ¿Los que tenemos el seguro con Toyota, aunque no creo que sea legal, podrían usar esos datos para penalizarnos o bonificarnos en el seguro?
Si alguien tiene otra manera de acceder a los datos, o hacerlo de una manera más fácil se agradecería que lo comentara.
Me quedé con curiosidad de investigar sobre eso, y hace un rato he encontrado en Github un proyecto en Python para tener acceso a esos datos.
GitHub - calmjm/tojota: Functions for interacting with Toyota MyT API
Los requerimientos pueden no ser triviales para quien no sea "medio informático".
Installation
Usage
- Have Python 3.6+
- Create virtual environment
- Install requirements pip install -r requirements.txt
- Configure your MyT user account, password and vehicle VIN into configs/myt.json
- If your vehicle doesn't support remote control functions, set "use_remote_control": false in the config file
- If you would like to save data to InfluxDB, install InfluxDB ( InfluxDB | Real-time insights at any scale | InfluxData ) and create database 'tojota' and set "use_influxdb": true in the config file (support only for old unsecure no authentication version)
- Run python tojota.py to fetch, save and print data
- Data is saved to cache directory for further usage
Tenía el Python instalado por un curso de Odoo que hice hace un tiempo y he conseguido sacar algunos datos en "bruto". Como mi coche es del 2019 me fallaba al intentar obtener el nivel de combustible. Me he cargado la parte del código que preguntaba por esos datos y funcionando. Con un coche más moderno seguramente funcione sin tener que retocar nada del código.
Estos son los datos que he conseguido de los 2 viajes largos que hice en la vuelta de vacaciones. Pongo en negrita datos que me han llamado la atención.
{"id": "d8ae89a5", "category": 0, "summary": {"length": 204530, "duration": 7076, "durationIdle": 16, "countries": ["ES"], "maxSpeed": 135.0, "averageSpeed": 104.06, "lengthOverspeed": 34897, "durationOverspeed": 1172, "lengthHighway": 182281, "durationHighway": 5885, "fuelConsumption": 8736.0, "startTs": "2024-08-31T12:21:02Z", "endTs": "2024-08-31T14:18:33Z", "nightTrip": false}, "scores": {"acceleration": 94, "braking": 95, "global": 95, "constantSpeed": 89, "advice": 7}, "behaviours": {"ts": "2024-08-31T12:21:40Z", "type": "B", "good": false, "diagnosticMsg": 2, "coachingMsg": 2, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 128}], "context": {"slope": -0.0}, "priority": true, "severity": 46.82}, {"ts": "2024-08-31T12:21:45Z", "type": "B", "good": false, "diagnosticMsg": 2, "coachingMsg": 2, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 108}], "context": {"slope": -0.23114729872510126}, "priority": true, "severity": 35.8}, {"ts": "2024-08-31T14:11:50Z", "type": "A", "good": true, "diagnosticMsg": 40, "coachingMsg": 1, "context": {"slope": 6.251540929867111}, "priority": true, "severity": 191.4}, {"ts": "2024-08-31T14:10:05Z", "type": "B", "good": false, "diagnosticMsg": 6, "coachingMsg": 6, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 123}], "context": {"slope": -1.0632393558708426}, "priority": true, "severity": 214.7}, {"ts": "2024-08-31T12:29:00Z", "type": "C", "good": true, "diagnosticMsg": 50, "coachingMsg": 31, "context": {"slope": -0.002059022484849148}, "priority": true, "severity": 10000.0}], "hdc": {"evTime": 1910, "evDistance": 45136}}
{"id": "594158d1", "category": 0, "summary": {"length": 311952, "duration": 10843, "durationIdle": 129, "countries": ["ES"], "maxSpeed": 131.0, "averageSpeed": 103.57, "lengthOverspeed": 34984, "durationOverspeed": 1129, "lengthHighway": 299925, "durationHighway": 9864, "fuelConsumption": 14166.0,: -6.0509, "startTs": "2024-08-31T08:45:58Z", "endTs": "2024-08-31T11:45:40Z", "nightTrip": false}, "scores": {"acceleration": 98, "braking": 97, "global": 98, "constantSpeed": 78, "advice": 2}, "behaviours": [{"ts": "2024-08-31T08:56:50Z", "type": "B", "good": false, "diagnosticMsg": 2, "coachingMsg": 2, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 132}], "context": {"slope": 0.0}, "priority": true, "severity": 264.31}, {"ts": "2024-08-31T11:44:10Z", "type": "B", "good": false, "diagnosticMsg": 3, "coachingMsg": 3, "coachingMsgParams": [{"name": "distance", "unit": "meter", "value": 105}], "context": {"slope": 0.0}, "priority": true, "severity": 239.64}, {"ts": "2024-08-31T09:01:25Z", "type": "C", "good": true, "diagnosticMsg": 50, "coachingMsg": 31, "context": {"slope": 0.0}, "priority": true, "severity": 10000.0}, {"ts": "2024-08-31T08:50:15Z", "type": "B", "good": true, "diagnosticMsg": 33, "coachingMsg": 1, "context": {"slope": 0.0}, "priority": true, "severity": 10000.0}, {"ts": "2024-08-31T11:43:53Z", "type": "B", "good": true, "diagnosticMsg": 33, "coachingMsg": 1, "context": {"slope": 0.0}, "priority": true, "severity": 10000.0}], "hdc": {"evTime": 1942, "evDistance": 46414}}
Por CLI da un resumen de datos así. En algún otro coche o modelo más moderno tal vez te controle cuánto tiempo has ido en eco/power/charging:
2024-09-02 12:21:16-> 2024-09-02 12:33:34 43.2157 -2.4039: 7.621 km, 34.38 km/h, 2.61 l/100 km, 0.20 l
Time stats: EV: 72% eco: 0% power: 0% charging: 0%
Distance stats: EV: 77% eco: 0% power: 0% charging: 0%
2024-08-31 16:43:09-> 2024-08-31 16:54:13 43.1898 -2.4543: 6.908 km, 36.73 km/h, 3.10 l/100 km, 0.21 l
Time stats: EV: 75% eco: 0% power: 0% charging: 0%
Distance stats: EV: 61% eco: 0% power: 0% charging: 0%
2024-08-31 14:21:02-> 2024-08-31 16:18:33 43.1799 -2.4887: 204.53 km, 104.06 km/h, 4.27 l/100 km, 8.74 l
Time stats: EV: 27% eco: 0% power: 0% charging: 0%
Distance stats: EV: 22% eco: 0% power: 0% charging: 0%
2024-08-31 10:45:58-> 2024-08-31 13:45:40 42.1778 -4.0598: 311.952 km, 103.57 km/h, 4.54 l/100 km, 14.17 l
Time stats: EV: 18% eco: 0% power: 0% charging: 0%
Distance stats: EV: 15% eco: 0% power: 0% charging: 0%
Total distance: 737.724 km, Fuel consumption: 30.54 l, 4.14 l/100 km
La app antigua daba el dato de máxima velocidad del trayecto, y el dato se sigue guardando, solo que la nueva app MyT no lo muestra. También parece que te controla cuánta distancia y tiempo has hecho por autopista. Y lo que más me preocupa. Esos campos de lenghtOverspeed y durationOverspeed... ¿se referirán al tiempo y distancia que has ido por encima de los límites de velocidad? En viajes más cortos sin autopista no me marca nada de Overspeed... ¿Los que tenemos el seguro con Toyota, aunque no creo que sea legal, podrían usar esos datos para penalizarnos o bonificarnos en el seguro?
Si alguien tiene otra manera de acceder a los datos, o hacerlo de una manera más fácil se agradecería que lo comentara.
Última edición: