-- | Implements
module HomeAssistant.Common.HomeAssistant (
    check,
    reloadAll
) where

--------------------------------------------------------------------------------

import Data.Aeson
import qualified Data.Text as T

import HomeAssistant.Client ( HA, callService )
import HomeAssistant.Types ( Config )

--------------------------------------------------------------------------------

-- | The name of the Home Assistant service.
serviceName :: T.Text
serviceName :: Text
serviceName = Text
"homeassistant"

--------------------------------------------------------------------------------

-- | 'notify' @device notification@ is a wrapper around `callService` that uses
-- the notifications service to send @notification@ to @device@.
check :: HA (Result Config)
check :: HA (Result Config)
check = Value -> Result Config
forall a. FromJSON a => Value -> Result a
fromJSON (Value -> Result Config) -> ClientM Value -> HA (Result Config)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Text -> Maybe Value -> ClientM Value
callService Text
serviceName Text
"check_config" Maybe Value
forall a. Maybe a
Nothing

reloadAll :: HA Value
reloadAll :: ClientM Value
reloadAll = Text -> Text -> Maybe Value -> ClientM Value
callService Text
serviceName Text
"reload_all" Maybe Value
forall a. Maybe a
Nothing

--------------------------------------------------------------------------------