Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Access of car-specific APIs.
Synopsis
- data Car m a
- runCar :: MonadIO m => IO AuthInfo -> VehicleID -> Car m a -> m a
- runNamedCar :: MonadIO m => Text -> IO AuthInfo -> Car m a -> m a
- type VehicleID = Text
- vehicleData :: MonadIO m => Car m VehicleData
- nearbyChargers :: MonadIO m => Car m [Charger]
- vehicleStatus :: MonadIO m => Car m VehicleState
- isAwake :: MonadIO m => Car m Bool
- type VehicleData = ByteString
- isUserPresent :: VehicleData -> Bool
- isCharging :: VehicleData -> Bool
- teslaTS :: VehicleData -> UTCTime
- maybeTeslaTS :: VehicleData -> Maybe UTCTime
- data Door
- data OpenState a
- _Open :: forall a. Prism' (OpenState a) a
- _Closed :: forall a. Prism' (OpenState a) a
- doors :: VehicleData -> Maybe [OpenState Door]
- openDoors :: VehicleData -> [Door]
- data Location = Location {}
- data DestinationCharger = DestinationCharger {}
- data Supercharger = Supercharger {}
- data Charger
- superchargers :: [Charger] -> [Supercharger]
- destinationChargers :: [Charger] -> [DestinationCharger]
- lat :: Lens' Location Double
- lon :: Lens' Location Double
- _SC :: Prism' Charger Supercharger
- _DC :: Prism' Charger DestinationCharger
- vdata :: Prism' VehicleData Value
- name :: HasName s a => Lens' s a
- location :: HasLocation s a => Lens' s a
- distance_miles :: HasDistance_miles s a => Lens' s a
- available_stalls :: HasAvailable_stalls s a => Lens' s a
- total_stalls :: HasTotal_stalls s a => Lens' s a
- site_closed :: HasSite_closed s a => Lens' s a
- vehicleURL :: VehicleID -> String -> String
- currentVehicleID :: MonadReader CarEnv m => m VehicleID
Car Monad and related types.
Car Monad for accessing car-specific things.
Instances
MonadFail m => MonadFail (Car m) Source # | |
MonadIO m => MonadIO (Car m) Source # | |
Applicative m => Applicative (Car m) Source # | |
Functor m => Functor (Car m) Source # | |
Monad m => Monad (Car m) Source # | |
MonadCatch m => MonadCatch (Car m) Source # | |
MonadMask m => MonadMask (Car m) Source # | |
MonadThrow m => MonadThrow (Car m) Source # | |
MonadLogger m => MonadLogger (Car m) Source # | |
Defined in Tesla.Car monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> Car m () | |
MonadUnliftIO m => MonadUnliftIO (Car m) Source # | |
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.
Requests
vehicleData :: MonadIO m => Car m VehicleData Source #
Fetch the VehicleData.
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.
The various doors.
openDoors :: VehicleData -> [Door] Source #
Return a list of open doors.
Charger Info
Location, Location, Location.
Instances
FromJSON Location Source # | |
Defined in Tesla.Car parseJSON :: Value -> Parser Location parseJSONList :: Value -> Parser [Location] | |
Generic Location Source # | |
Show Location Source # | |
type Rep Location Source # | |
Defined in Tesla.Car type Rep Location = D1 ('MetaData "Location" "Tesla.Car" "tesla-0.7.4.0-8rAp9nRjw7z31SQUSkgJUc" '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
data Supercharger Source #
A supercharger (provided by nearbyChargers).
Supercharger | |
|
Instances
Eitehr a Supercharger or Destination charger.
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
_SC :: Prism' Charger Supercharger Source #
_DC :: Prism' Charger DestinationCharger Source #
vdata :: Prism' VehicleData Value Source #
Prism for viewing VehicleData
as an Aeson Value
.
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 # | |