tesla-0.1.0.1: Tesla API client.

Safe HaskellNone
LanguageHaskell2010

Tesla.Car

Contents

Description

Access of car-specific APIs.

Synopsis

Car Monad and related types.

type Car = ReaderT CarEnv Source #

Car Monad for accessing car-specific things.

runCar :: MonadIO m => IO AuthInfo -> VehicleID -> Car m a -> m a Source #

Run a Car Monad with the given Vehicle ID

runNamedCar :: MonadIO m => Text -> IO AuthInfo -> Car m a -> m a Source #

Run a Car Monad by looking up a car by name.

type VehicleID = Text Source #

A VehicleID.

Requests

vehicleData :: MonadIO m => Car m VehicleData Source #

Fetch the VehicleData.

nearbyChargers :: MonadIO m => Car m [Charger] Source #

Get the nearby chargers.

Convenience functions for examining VehicleData

type VehicleData = ByteString Source #

Giant blob of VehicleData describing all known state of the vehicle.

This is not separated into discrete A VehicleIDfields because that's easy enough to do with Aeson and Lens when you need it but some convenience methods for common | A VehicleIDaccesses are available in this module.

isUserPresent :: VehicleData -> Bool Source #

True if a user is present in the vehicle.

isCharging :: VehicleData -> Bool Source #

True of the vehicle is currently charging.

teslaTS :: VehicleData -> UTCTime Source #

Get the timestamp from this VehicleData or error if there isn't one.

maybeTeslaTS :: VehicleData -> Maybe UTCTime Source #

Get the timestamp from this VehicleData if present.

data Door Source #

The various doors.

Instances
Bounded Door Source # 
Instance details

Defined in Tesla.Car

Enum Door Source # 
Instance details

Defined in Tesla.Car

Methods

succ :: Door -> Door #

pred :: Door -> Door #

toEnum :: Int -> Door #

fromEnum :: Door -> Int #

enumFrom :: Door -> [Door] #

enumFromThen :: Door -> Door -> [Door] #

enumFromTo :: Door -> Door -> [Door] #

enumFromThenTo :: Door -> Door -> Door -> [Door] #

Eq Door Source # 
Instance details

Defined in Tesla.Car

Methods

(==) :: Door -> Door -> Bool #

(/=) :: Door -> Door -> Bool #

Show Door Source # 
Instance details

Defined in Tesla.Car

Methods

showsPrec :: Int -> Door -> ShowS #

show :: Door -> String #

showList :: [Door] -> ShowS #

data OpenState a Source #

Constructors

Closed a 
Open a 
Instances
Eq a => Eq (OpenState a) Source # 
Instance details

Defined in Tesla.Car

Methods

(==) :: OpenState a -> OpenState a -> Bool #

(/=) :: OpenState a -> OpenState a -> Bool #

Show a => Show (OpenState a) Source # 
Instance details

Defined in Tesla.Car

doors :: VehicleData -> Maybe [OpenState Door] Source #

Return a list of doors and their OpenState.

openDoors :: VehicleData -> [Door] Source #

Return a list of open doors.

Charger Info

data Location Source #

Location, Location, Location.

Constructors

Location 

Fields

Instances
Show Location Source # 
Instance details

Defined in Tesla.Car

Generic Location Source # 
Instance details

Defined in Tesla.Car

Associated Types

type Rep Location :: Type -> Type #

Methods

from :: Location -> Rep Location x #

to :: Rep Location x -> Location #

FromJSON Location Source # 
Instance details

Defined in Tesla.Car

type Rep Location Source # 
Instance details

Defined in Tesla.Car

type Rep Location = D1 (MetaData "Location" "Tesla.Car" "tesla-0.1.0.1-LtDpkbt2h5lFKecjI1fkpO" False) (C1 (MetaCons "Location" PrefixI True) (S1 (MetaSel (Just "_lat") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Double) :*: S1 (MetaSel (Just "_lon") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Double)))

data DestinationCharger Source #

A destination charger (provided by nearbyChargers).

data Supercharger Source #

A supercharger (provided by nearbyChargers).

data Charger Source #

Eitehr a Supercharger or Destination charger.

Instances
Show Charger Source # 
Instance details

Defined in Tesla.Car

superchargers :: [Charger] -> [Supercharger] Source #

Return only the superchargers from a Charger list.

destinationChargers :: [Charger] -> [DestinationCharger] Source #

Return only the destination chargers from a Charger list.

Lenses

name :: HasName s a => Lens' s a Source #

location :: HasLocation s a => Lens' s a Source #

distance_miles :: HasDistance_miles s a => Lens' s a Source #

available_stalls :: HasAvailable_stalls s a => Lens' s a Source #

total_stalls :: HasTotal_stalls s a => Lens' s a Source #

site_closed :: HasSite_closed s a => Lens' s a Source #

Probably uninteresting internals

vehicleURL :: VehicleID -> String -> String Source #

Get the URL for a named endpoint for a given vehicle.

authInfo :: MonadIO m => Car m AuthInfo Source #

Get authInfo from the Car Monad.

vehicleID :: Monad m => Car m VehicleID Source #

Get the current vehicle ID from the Car Monad.