robinostlund / volkswagencarnet

A python library for volkswagen carnet
GNU General Public License v3.0
65 stars 36 forks source link

Introduction of API Status sensors #228

Closed stickpin closed 9 months ago

stickpin commented 9 months ago

Introduction of API Status sensors

The default status for the supported APIs is "Unknown".

The following logic applies to provide a status:

        if response_code in [200, 204, 207]:
            status = "Up"
        elif response_code == 401:
            status = "Unauthorized"
        elif response_code == 403:
            status = "Forbidden"
        elif response_code == 429:
            status = "Rate limited"
        elif response_code == 1000:
            status = "Error"
        else:
            status = "Down"

Screenshot 2023-12-08 at 19 52 04

FYI @oliverrahner

stickpin commented 9 months ago

@oliverrahner I think I managed to solve all the edge cases and issues with API status detection. :) Now it's ready for merge.