TA2k / ioBroker.toyota

ioBroker Adapter for myT Toyota
MIT License
2 stars 2 forks source link

trips month #1

Closed backfisch88 closed 2 years ago

backfisch88 commented 2 years ago

die Zeitspanne des Monatstrips ist zu lang

toyota.0 | 2021-11-05 11:52:46.596 | error | {"timestamp":1636109566583,"status":404,"error":"Not Found","message":"Data Not found","errorCode":"CMA404"} -- | -- | -- | -- toyota.0 | 2021-11-05 11:52:46.596 | error | Error: Request failed with status code 404 toyota.0 | 2021-11-05 11:52:46.595 | error | https://myt-agg.toyota-europe.com/cma/api/v2/trips/541dbaba-06f2-490f-966a-2a6935e315ca toyota.0 | 2021-11-05 11:52:46.574 | error | {"timestamp":1636109566559,"status":400,"error":"Bad Request","message":"Maximum difference between from '2020-01-01' & to '2021-11-05' can be 365 days","errorCode":"CMA400"} toyota.0 | 2021-11-05 11:52:46.573 | error | Error: Request failed with status code 400 toyota.0 | 2021-11-05 11:52:46.572 | error | https://myt-agg.toyota-europe.com/cma/api/v2/trips/summarize?from=2020-01-01&to=2021-11-05&calendarInterval=month
TA2k commented 2 years ago

fixed in github

backfisch88 commented 2 years ago

hab es so gewechselt, da dem 365 inklusive dem heutigen Datum zu viel sind

    const datecalc = new Date();
    const startTimestamp = new Date().setDate(datecalc.getDate() -364);
    const startDate = new Date(startTimestamp);
    const startDateFormatted = startDate.toISOString().split("T")[0];
backfisch88 commented 2 years ago
    const date = new Date().toISOString().split("T")[0];
    const year = new Date().toISOString().split("-")[0];
    const datecalc = new Date();
    const startTimestamp = new Date().setDate(datecalc.getDate() -364);
    const startDate = new Date(startTimestamp);
    const startDateFormatted = startDate.toISOString().split("T")[0];
    const startTimestampday = new Date().setDate(datecalc.getDate() -30);
    const startDateday = new Date(startTimestampday);
    const startDateFormattedday = startDateday.toISOString().split("T")[0];
    const statusArray = [
        {
            path: "status",
            url: "https://myt-agg.toyota-europe.com/cma/api/users/" + this.uuid + "/vehicles/$vin/vehicleStatus",
            desc: "Status of the car",
        },
        {
            path: "addtionalInfo",
            url: "https://myt-agg.toyota-europe.com/cma/api/vehicle/$vin/addtionalInfo",
            desc: "AddtionalInfo of the car",
        },
        {
            path: "remoteControlStatus",
            url: "https://myt-agg.toyota-europe.com/cma/api/vehicles/$vin/remoteControl/status",
            desc: "remoteControlStatus of the car",
        },
        {
            path: "location",
            url: "https://myt-agg.toyota-europe.com/cma/api/users/" + this.uuid + "/vehicle/location",
            desc: "Location of the car",
        },
        {
            path: "trips",
            url: "https://myt-agg.toyota-europe.com/cma/api/v2/trips/" + this.uuid,
            desc: "trips of the car",
        },
        {
            path: "monthly trips",
            url: "https://myt-agg.toyota-europe.com/cma/api/v2/trips/summarize?from=" + startDateFormatted + "&to=" + date + "&calendarInterval=month",
            desc: "monthly trips of the car",
        },
                  {
            path: "daily trips",
            url: "https://myt-agg.toyota-europe.com/cma/api/v2/trips/summarize?from=" + startDateFormattedday + "&calendarInterval=day",
            desc: "daily trips of the car",
        },
                            {
            path: "yearly trips",
            url: "https://myt-agg.toyota-europe.com/cma/api/v2/trips/summarize?from=" + year + "-01-01&to=" + year + "-12-31",
            desc: "yearly trips of the car",
        },
    ];

noch erweitert auf wöchentlich/täglich und das Jahr

TA2k commented 2 years ago

Habe ich hinzugefügt