Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brittonhayes/homeassistant-ts
A typescript REST API client for the Home Assistant API. Interact with your Home Assistant instance from TS/JS services..
https://github.com/brittonhayes/homeassistant-ts
homeassistant iot library sdk typescript
Last synced: about 13 hours ago
JSON representation
A typescript REST API client for the Home Assistant API. Interact with your Home Assistant instance from TS/JS services..
- Host: GitHub
- URL: https://github.com/brittonhayes/homeassistant-ts
- Owner: brittonhayes
- License: mit
- Created: 2022-12-05T06:13:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-15T20:05:41.000Z (over 1 year ago)
- Last Synced: 2024-10-31T06:51:34.991Z (8 days ago)
- Topics: homeassistant, iot, library, sdk, typescript
- Language: TypeScript
- Homepage: https://brittonhayes.github.io/homeassistant-ts
- Size: 566 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🏠 Home Assistant - Typescript SDK
[![CI](https://github.com/brittonhayes/homeassistant-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/brittonhayes/homeassistant-ts/actions/workflows/ci.yml)
📚 [SDK Docs](https://brittonhayes.github.io/homeassistant-ts)
📚 [OpenAPI 3.x Spec](https://github.com/brittonhayes/homeassistant-ts/tree/main/openapi.yaml)
This is typescript REST API client for the [Home Assistant](https://www.home-assistant.io/) API. Allows you to interact with your Home Assistant instance from Typescript/JS projects.
## ⚡ Usage
How to use the library
### 📦 Installation
```bash
npm install @brittonhayes/homeassistant-ts
```### 🚀 Quickstart
Create a client
```ts
import * as homeassistant from '@brittonhayes/homeassistant-ts';const ha = new homeassistant.Client({
baseUrl: process.env.HASS_URL,
token: process.env.HASS_TOKEN,
});
```List all home assistant services
```ts
const services = await ha.services.list();
console.log(services);
```List all logbook entries (as plaintext)
```ts
const logs = await ha.logbook.list();
console.log(logs);
```Retrieve all calendar events from a calendar
```ts
const calendar = await ha.calendars.retrieve('calendar.calendar_name');
console.log(calendar);
```### Development
```shell
# Install dependencies
npm install
# Format the code
npm run format
# Build the library
npm run build
```