ha-lovelace-ts
v0.3.6
Published
TypeScript-based tool for building Home Assistant Lovelace Interfaces
Downloads
23
Readme
lovelace_ts - HA Lovelace Config as TypeScript
Usage
- Setup a Node devenv - make sure you have
nodejs
andyarn
installed, create a directory, runyarn init
andyarn add ha-lovelace-ts
- Setup your
tsconfig.json
file with at least these parameters:{ "compilerOptions": { "rootDir": ".", "jsx": "react", "jsxFactory": "h", "jsxFragmentFactory": "Fragment", }, }
- Create an
index.tsx
file and start writing your UI. Here's an example:import { render, h } from 'ha-lovelace-ts' async function Blah() { return <area area='Blah' /> } export default render(<dashboard title='Robert'> <view title='Hia' path='phil' type="masonry"> <horizontal_stack> <entities entities={['a', 'b']} /> </horizontal_stack> </view> <view title='Hia' path='phil'> <Blah /> </view> </dashboard>)
- Compile - run
yarn lovelace_ts build index.tsx output.yml
- Copy the generated file to your HA instance
Contributing Card Definitions
Take a look at src/contrib
and look at the existing definitions as examples.