# use-homeassistant

> Helpers for creating custom Homeassistant dashboards in React

Latest version **0.0.2** (published 2023-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-homeassistant
pnpm add use-homeassistant
yarn add use-homeassistant
bun add use-homeassistant
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-02-01 |
| First published | 2023-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 51.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | tmikoss |
| Maintainers | tmikoss |
| Keywords | homeassistant, react |

## Links

- npm: https://www.npmjs.com/package/use-homeassistant
- npm.io page: https://npm.io/package/use-homeassistant

## Dependencies (2)

- [swr](https://npm.io/package/swr.md) ^2.0.3
- [home-assistant-js-websocket](https://npm.io/package/home-assistant-js-websocket.md) ^8.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2023-02-01
- 0.0.1 — 2023-02-01

## README

# use-homeassistant

Helpers and hooks for building Homeassistant custom dashboards in React. Originally extracted from a personal dashboard. Connects to the Homeassistant websocket API via [home-assistant-js-websocket](https://github.com/home-assistant/home-assistant-js-websocket), and the Homeassistant REST API.

## Usage

Wrap the components that require interaction with Homeassistant in a `HomeassistantProvider`, then use provided hooks to fetch data.

More in-depth [documentation is available here](https://tmikoss.github.io/use-homeassistant/).

```js
import { HomeassistantProvider, useEntity } from 'use-homeassistant'

const url = 'http://homeassistant.local:8123'
const token = '...' // https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token

const Lightbulb = () => {
  const { state, attributes: { friendly_name } } = useEntity('entity.example_light')

  return <div>
    The light with HA name {friendly_name} is currently {state}
  </div>
}

const App = () => {
  return <HomeassistantProvider homeassistantUrl={url} accessToken={token}>
    <Lightbulb>
  </HomeassistantProvider>
}
```

---
_Source: https://npm.io/package/use-homeassistant · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
