ha_api 0.1.1 copy "ha_api: ^0.1.1" to clipboard
ha_api: ^0.1.1 copied to clipboard

Dart client library for the Home Assistant REST API and covers 100% of public API endpoints.

Home Assistant API client for Dart #

An API client for Home Assistant automation framework. If you ever wanted to control your home from your Dart application, this is the package for you. The client covers following Home Assistant APIs:

GET

  • /api/
  • /api/config
  • /api/events
  • /api/services
  • /api/history/period/<timestamp>
  • /api/logbook/<timestamp>
  • /api/states
  • /api/states/<entity_id>
  • /api/error_log
  • /api/camera_proxy/<camera entity_id>
  • /api/calendars
  • /api/calendars/<calendar entity_id>

POST

  • /api/states/<entity_id>
  • /api/events/<event_type>
  • /api/services/<domain>/<service>
  • /api/template
  • /api/config/core/check_config
  • /api/intent/handle

More documentation can be found here.

Usage #

To add this package as a dependency, add the following to your pubspec.yaml file:

dependencies:
  ha_api: ^0.1.0
copied to clipboard

Examples #

Here are small examples that show you how to use the API.

Get list of services #

import 'package:ha_api/ha_api.dart';

void main() async {
  final haClient = HaApi(
    url: 'yourIpAndPort',
    token: 'yourBearerToken',
  // make sure you call init() before using the client
  )..init();

  final (services, failure) = await service.getServices();
}

copied to clipboard

If the request was successful, the services variable will contain the result. If the request failed, the failure variable will contain the error.

6
likes
150
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.26 - 2025.04.10

Dart client library for the Home Assistant REST API and covers 100% of public API endpoints.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

http, json_annotation

More

Packages that depend on ha_api