tesla-0.7.4.0: Tesla API client.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tesla.Car

Description

Access of car-specific APIs.

Synopsis

Car Monad and related types.

data Car m a Source #

Car Monad for accessing car-specific things.

Instances

Instances details
MonadFail m => MonadFail (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

fail :: String -> Car m a #

MonadIO m => MonadIO (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

liftIO :: IO a -> Car m a #

Applicative m => Applicative (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

pure :: a -> Car m a #

(<*>) :: Car m (a -> b) -> Car m a -> Car m b #

liftA2 :: (a -> b -> c) -> Car m a -> Car m b -> Car m c #

(*>) :: Car m a -> Car m b -> Car m b #

(<*) :: Car m a -> Car m b -> Car m a #

Functor m => Functor (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

fmap :: (a -> b) -> Car m a -> Car m b #

(<$) :: a -> Car m b -> Car m a #

Monad m => Monad (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

(>>=) :: Car m a -> (a -> Car m b) -> Car m b #

(>>) :: Car m a -> Car m b -> Car m b #

return :: a -> Car m a #

MonadCatch m => MonadCatch (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

catch :: Exception e => Car m a -> (e -> Car m a) -> Car m a #

MonadMask m => MonadMask (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

mask :: ((forall a. Car m a -> Car m a) -> Car m b) -> Car m b #

uninterruptibleMask :: ((forall a. Car m a -> Car m a) -> Car m b) -> Car m b #

generalBracket :: Car m a -> (a -> ExitCase b -> Car m c) -> (a -> Car m b) -> Car m (b, c) #

MonadThrow m => MonadThrow (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

throwM :: Exception e => e -> Car m a #

MonadLogger m => MonadLogger (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> Car m () #

MonadUnliftIO m => MonadUnliftIO (Car m) Source # 
Instance details

Defined in Tesla.Car

Methods

withRunInIO :: ((forall a. Car m a -> IO a) -> IO b) -> Car m b #

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.

vehicleStatus :: MonadIO m => Car m VehicleState Source #

vehicleStatus returns the current status of the current vehicle.

isAwake :: MonadIO m => Car m Bool Source #

isAwake returns true if the current vehicle is awake and online.

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 fields because that's easy enough to do with Aeson and Lens when you need it but some convenience methods for common accesses 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

Instances details
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] #

Show Door Source # 
Instance details

Defined in Tesla.Car

Methods

showsPrec :: Int -> Door -> ShowS #

show :: Door -> String #

showList :: [Door] -> ShowS #

Eq Door Source # 
Instance details

Defined in Tesla.Car

Methods

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

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

data OpenState a Source #

Constructors

Closed a 
Open a 

Instances

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

Defined in Tesla.Car

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

Defined in Tesla.Car

Methods

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

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

_Open :: forall a. Prism' (OpenState a) a Source #

_Closed :: forall a. Prism' (OpenState a) a Source #

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

Instances details
FromJSON 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 #

Show 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.7.4.0-A0Al2DdpZxqCqV9OqkhIhJ" '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).

Instances

Instances details
FromJSON DestinationCharger Source # 
Instance details

Defined in Tesla.Car

Generic DestinationCharger Source # 
Instance details

Defined in Tesla.Car

Associated Types

type Rep DestinationCharger :: Type -> Type #

Show DestinationCharger Source # 
Instance details

Defined in Tesla.Car

type Rep DestinationCharger Source # 
Instance details

Defined in Tesla.Car

type Rep DestinationCharger = D1 ('MetaData "DestinationCharger" "Tesla.Car" "tesla-0.7.4.0-A0Al2DdpZxqCqV9OqkhIhJ" 'False) (C1 ('MetaCons "DestinationCharger" 'PrefixI 'True) (S1 ('MetaSel ('Just "_location") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Location) :*: (S1 ('MetaSel ('Just "_name") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "_distance_miles") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))))

data Supercharger Source #

A supercharger (provided by nearbyChargers).

Instances

Instances details
FromJSON Supercharger Source # 
Instance details

Defined in Tesla.Car

Generic Supercharger Source # 
Instance details

Defined in Tesla.Car

Associated Types

type Rep Supercharger :: Type -> Type #

Show Supercharger Source # 
Instance details

Defined in Tesla.Car

type Rep Supercharger Source # 
Instance details

Defined in Tesla.Car

data Charger Source #

Eitehr a Supercharger or Destination charger.

Instances

Instances details
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/Prisms

vdata :: Prism' VehicleData Value Source #

Prism for viewing VehicleData as an Aeson Value.

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.

currentVehicleID :: MonadReader CarEnv m => m VehicleID Source #

Get the current vehicle ID from the Car Monad.

Orphan instances

(Monad m, MonadIO m, MonadReader CarEnv m) => HasTeslaAuth m Source # 
Instance details