Giter Club home page Giter Club logo

clickhouse-hassio's Introduction

Clickhouse Home Assistant add-on repository

This repository contains Clickhouse Home Assistant add-on based on official Clickhouse image.

NB: This is a first(!) step to store history data in ClickHouse

  1. Add the repo in HA addons store https://github.com/apbodrov/clickhouse-hassio.git
  2. Install PostgreSQL, ClickHouse addon from the repo
  3. Setup recorder in configuration.yaml
recorder:
  db_url: "postgresql://homeassistant:homeassistant@homeassistant/homeassistant"
  1. (optional) migrate SQLite
  2. Run SQL in PostgreSQL to create incremental mat view
CREATE EXTENSION pg_ivm;
SELECT 
create_immv('states_view', 'SELECT
CASE WHEN state~E''^\\d+$'' THEN state::integer ELSE 0 END as state_num,
CASE WHEN state~E''^[+-]?([0-9]*[.])?[0-9]+$'' THEN state::float ELSE 0.0 END as state_float,
CASE WHEN NOT (state~E''^[+-]?([0-9]*[.])?[0-9]+$'' OR state~E''^\\d+$''  ) THEN state ELSE '''' END 
AS state_str,
to_timestamp(last_updated_ts) as ts,
sm.entity_id
FROM states
INNER JOIN states_meta sm
using(metadata_id)');
create unique index on states_view (ts);
alter table states_view ALTER COLUMN ts SET NOT NULL;
ALTER TABLE states_view REPLICA IDENTITY USING INDEX states_view_ts_idx;

  1. Run SQL in Clickhouse to create mat view
CREATE DATABASE homeassistant
ENGINE = MaterializedPostgreSQL('HA_IP:5432', 'homeassistant', 'homeassistant', 'homeassistant')


  1. Install Redash and access it on http://HA_IP/
  2. Enjoy ClickHouse!

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.