Giter VIP home page Giter VIP logo

reactive-home's Introduction

Reactive home deno runtime

My goal is it to provide a declarative automation experience for home assistant.

Installation

  1. Add this repo to your home assistant installation:

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

  1. Install Reactive Home from the addon store
  2. (Optional, but recommend) Install the Studio Code Server addon. After you installed the addon, go to the Studio Code Server addon and add this command to the init_commands list:

code --install-extension denoland.vscode-deno && curl -fsSL https://deno.land/x/install/install.sh | sh && echo "export DENO_INSTALL=\"/root/.deno\"" >> ~/.zshrc && echo "export PATH=\"\$DENO_INSTALL/bin:\$PATH\"" >> ~/.zshrc && mkdir -p /config/.vscode/ && echo "{\"deno.enable\":true,\"deno.unstable\":true,\"deno.importMap\":\"./reactive-home/import_map.json\"}" > /config/.vscode/settings.json

In yaml mode it should look like this:

init_commands:
  - >-
    code --install-extension denoland.vscode-deno && curl -fsSL
    https://deno.land/x/install/install.sh | sh && echo "export
    DENO_INSTALL=\"/root/.deno\"" >> ~/.zshrc && echo "export
    PATH=\"\$DENO_INSTALL/bin:\$PATH\"" >> ~/.zshrc && mkdir -p /config/.vscode/
    && echo "{\"deno.enable\":true,\"deno.unstable\":
    true,\"deno.importMap\":\"./reactive-home/import_map.json\"}" >
    /config/.vscode/settings.json
packages: []

You can also just replace the yaml content with this.

Now you need to start Studio Code Server. I recommen to enable Show in sidebar for quick access.

  1. Start the reactive-home addon
  2. Now you can start writing your scripts

Usage

Reactive Home will load all .ts script files beginning with script. inside the reactive-home directory (gets created automatically).

Example:

  • reactive-home/my-script.ts โŒ wrong
  • reactive-home/script.my-script.ts โœ… correct

This ensures that only files you want to run as standalone script get loaded.

The easiest way to edit your scripts is to use the Studio Code Server addon (Follow the installation in 3.).

Tip: If the IntelliSense in Studio Code Server stops working press Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux) and search for deno: Restart Language Server. Also make sure the dependencies are cached. If they are not cached, Studio Code Server will underline all missing dependencies with red. You can go with the coursor to the dependency and press Command+. (Mac) / Ctrl+. (Windows/Linux) and select Cache "dependency" and its dependencies. After a few seconds it should be cached and the underline should go away. Note: This has no effect on the script itself. This is just for Studio Code Server.

Scripts

This addon creates an importa_map.json file in reactive-home/ with an import alias for you to use. The alias is reactive-home and gets updated to the current addon version at every startup.

You can use it like this:

import { useAsyncState } from 'reactive-home';

const state = await useAsyncState('some entity id');
//    ^? state is a reactive value

Utilities

Currently, there is no real documentation. You can use the example scripts from test-modules in this repo and the auto generated deno documentation.

Everything here is based on @vue/reactivity. You can find more informations here.

reactive-home's People

Contributors

thenoim avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.