Пример #1
0
def vehicle_state(server, data):
    tesladata.influx_write(
        servername=server,
        measurement="vehicle_state",
        entity="odometer",
        vin=data["vin"],
        value=data["odometer"],
        ms=data["timestamp"],
    )
Пример #2
0
def vehicle(server, data):
    sleeping = 0

    if data["state"] == "asleep":
        sleeping = 1

    tesladata.influx_write(
        servername=server,
        measurement="vehicle_state",
        entity="sleeping",
        vin=data["vin"],
        value=sleeping,
        ms=data["timestamp"],
    )
Пример #3
0
def charge_state(server, data):
    tesladata.influx_write(
        servername=server,
        measurement="charge_state",
        entity="battery_level",
        vin=data["vin"],
        value=data["battery_level"],
        ms=data["timestamp"],
    )

    tesladata.influx_write(
        servername=server,
        measurement="charge_state",
        entity="ideal_battery_range",
        vin=data["vin"],
        value=float(data["ideal_battery_range"] * 1.609344),
        ms=data["timestamp"],
    )
Пример #4
0
def climate_state(server, data):
    tesladata.influx_write(
        servername=server,
        measurement="climate_state",
        entity="inside_temp",
        vin=data["vin"],
        value=data["inside_temp"],
        ms=data["timestamp"],
    )

    tesladata.influx_write(
        servername=server,
        measurement="climate_state",
        entity="outside_temp",
        vin=data["vin"],
        value=data["outside_temp"],
        ms=data["timestamp"],
    )
Пример #5
0
def custom_data(server, data):
    if 'sleepy' in data:
        if data["sleepy"] is True:
            tesladata.influx_write(
                servername=server,
                measurement="custom_data",
                entity="sleepy",
                vin=data["vin"],
                value=1,
                ms=data["timestamp"],
            )

    if 'est_ideal_maxrange' in data:
        tesladata.influx_write(
            servername=server,
            measurement="custom_data",
            entity="est_ideal_maxrange",
            vin=data["vin"],
            value=data["est_ideal_maxrange"],
            ms=data["timestamp"],
        )
Пример #6
0
def drive_state(server, data):
    if data["power"] is None:
        data["power"] = 0
    tesladata.influx_write(
        servername=server,
        measurement="drive_state",
        entity="power",
        vin=data["vin"],
        value=data["power"],
        ms=data["timestamp"],
    )

    if data["speed"] is None:
        data["speed"] = 0
    tesladata.influx_write(
        servername=server,
        measurement="drive_state",
        entity="speed",
        vin=data["vin"],
        value=data["speed"],
        ms=data["timestamp"],
    )

    tesladata.influx_write(
        servername=server,
        measurement="drive_state_txt",
        entity="shift_state",
        vin=data["vin"],
        value=data["shift_state"],
        ms=data["timestamp"],
    )