home-assistant-client: Client library for the Home Assistant API.

[ bsd3, library, program, web ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.2.3 && <2.3), base (>=4.7 && <5), bytestring (>=0.12.1 && <0.13), containers (>=0.6.8 && <0.8), deriving-aeson (>=0.2.10 && <0.3), exceptions (>=0.10.9 && <0.11), home-assistant-client, http-client (>=0.7.19 && <0.8), http-client-tls (>=0.3.6 && <0.4), http-types (>=0.12.4 && <0.13), optparse-applicative (>=0.18.0 && <0.20), servant (>=0.20.3 && <0.21), servant-client (>=0.20.3 && <0.21), text (>=2.1.1 && <2.2) [details]
License BSD-3-Clause
Copyright 2025 Michael B. Gale
Author Michael B. Gale
Maintainer github@michael-gale.co.uk
Category Web
Home page https://github.com/mbg/home-assistant-client#readme
Bug tracker https://github.com/mbg/home-assistant-client/issues
Source repo head: git clone https://github.com/mbg/home-assistant-client
Uploaded by mbg at 2025-08-10T11:21:10Z
Distributions
Executables ha-client
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2025-08-10 [all 1 reports]

Readme for home-assistant-client-0.1.0.0

[back to package description]

home-assistant-client: Haskell client for the Home Assistant API

GitHub Haskell Stackage Nightly

A Haskell library for the Home Assistant API, allowing you to write Haskell applications which interact with Home Assistant.

A ha-client program that exposes the library functions as CLI commands is also provided.

Library usage

The Home Assistant API offers fairly general endpoints, for which the HomeAssistant.Client module provides client computations. All API endpoints require authorisation with a long-lived token. For example, to retrieve a list available services from Home Assistant:

import Network.HTTP.Client

defaultAddress :: String
defaultAddress = "http://homeassistant.local:8123/"

main :: IO ()
main = do
    -- `token` should be the long-lived token
    httpManager <- defaultManagerSettings
    address <- parseBaseUrl defaultAddress

    let env = mkHomeAssistantEnv token httpManager address
    result <- runClientM services env
    print result

CLI usage

You must set an environment variable named HA_TOKEN to your long-lived token. The CLI also inspects the HA_ADDRESS environment variable to determine the address of the Home Assistant server. This is optional and will default to http://homeassistant.local:8123/ if no value is set.

The ha-client CLI can be invoked with --help to retrieve usage information. All sub-commands also support the --help flag to retrieve command-specific help.