This is a very basic Next.js starter for creating custom frontends for Home Assistant.
It includes auth and connection functionality from home-assistant-js-websocket
.
- Authentication
- Connection management
- Entity helper hooks
- Service helpers
- Config helpers
- Clone this repository
$ git clone https://github.com/dangreco/home-assistant-nextjs-starter
- Install dependencies
$ yarn
- Edit
utils/config.ts
with the name of your app:
const APP_NAME = 'app-name'; // <- Edit this!
export {
APP_NAME,
}
- Start the dev server
$ yarn dev
- Open up
localhost:3000
in your browser, you're done!
-
useEntity( entityId: string )
Retrieves an entity for the givenentityId
,undefined
if the entity is not found. -
useEntities( entityIds?: string[] )
Retrives an object of entities matching the givenentityIds
. If a given entity with IDentityId
was not found, the corresponding entrymyEntities[entityId]
will beundefined
. IfentityIds
is undefined, this hook returns all entities. -
useDomain( domain: string )
Retrieves an object of entities matching the givendomain
. E.g.,useDomain('light')
will return all entities with IDs matchinglight.xxxxxxxx
. -
useQuery( query: string )
Searches all available entites byquery
. Matches are based on both theentity_id
andfriendly_name
of the entity. -
TODO
useHistory( entityId: string )
Retrieves the history for an entity given itsentityId
.
-
useDiscovery( max?: number )
Finds Home Assistant servers on the local network. Stops the search oncemax
instances are found. Ifmax
is undefined, this will search forever. -
useAuth()
Retrieves current authentication information. The fieldlogout
is a function to log out of the current auth. -
useHass()
Retrieves the current Home Assistant state, incuding fieldsconnection
,entities
,services
,config
.
-
pages/index.tsx
This is where your "dashboard" should go. The user will be redirected to this route after succesful authentication. -
pages/auth/index.tsx
This is where the user will find a Home Assistant instance and authenticate.