{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Tesla.Car.Command.Charging (
startCharging, stopCharging, setLimit, openChargePort, closeChargePort,
setAmps,
scheduledChargingOff, scheduleCharging
) where
import Control.Monad.IO.Class (MonadIO (..))
import Tesla.Car.Command
setLimit :: MonadIO m => Percent -> Car m CommandResponse
setLimit :: forall (m :: * -> *). MonadIO m => Percent -> Car m CommandResponse
setLimit Percent
to = forall (m :: * -> *).
MonadIO m =>
String -> [Pair] -> Car m CommandResponse
runCmd String
"set_charge_limit" [Key
"percent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Percent
to]
setAmps :: MonadIO m => Int -> Car m CommandResponse
setAmps :: forall (m :: * -> *). MonadIO m => Int -> Car m CommandResponse
setAmps Int
to = forall (m :: * -> *).
MonadIO m =>
String -> [Pair] -> Car m CommandResponse
runCmd String
"set_charging_amps" [Key
"charging_amps" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
to]
scheduledChargingOff :: MonadIO m => Car m CommandResponse
scheduledChargingOff :: forall (m :: * -> *). MonadIO m => Car m CommandResponse
scheduledChargingOff = forall (m :: * -> *).
MonadIO m =>
String -> [Pair] -> Car m CommandResponse
runCmd String
"set_scheduled_charging" [ Key
"enable" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
False ]
scheduleCharging :: MonadIO m => Time -> Car m CommandResponse
scheduleCharging :: forall (m :: * -> *). MonadIO m => Time -> Car m CommandResponse
scheduleCharging Time
mins = forall (m :: * -> *).
MonadIO m =>
String -> [Pair] -> Car m CommandResponse
runCmd String
"set_scheduled_charging" [ Key
"enable" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
True, Key
"time" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Time
mins ]
mkNamedCommands [("startCharging", "charge_start"),
("stopCharging", "charge_stop"),
("openChargePort", "charge_port_door_open"),
("closeChargePort", "charge_port_door_close")]