Git Product home page Git Product logo

thomastjdev / nim_homeassistant Goto Github PK

View Code? Open in Web Editor NEW
34.0 6.0 8.0 1.77 MB

Nim Home Assistant (NimHA) is a hub for combining multiple home automation devices and automating jobs.

License: GNU General Public License v3.0

Nim 71.23% CSS 8.94% JavaScript 19.38% Shell 0.32% Makefile 0.13%
xiaomi xiaomi-smart-home mqtt home-automation home-assistant smart-home owntracks pushbullet alarm alarm-system

nim_homeassistant's Introduction

Nim Homeassistant

Nim Home Assistant (NimHA) is a hub for combining multiple home automation devices and automating jobs. Nim Home Assistant is developed to run on a Raspberry Pi with a 7" touchscreen, mobile devices and on large screens.

Wiki

Please visit the Wiki page for more information on installation, requirements and the modules.

Current status

NimHA is currently in BETA.

Work before reaching stable: - Avoid database lock error (multiple connections at the same time - which SQLite does not like)

  • The alarm module's countdown proc() is currently not working (this means that when the alarm has been triggered, it will immediately go into ringing mode)

Blog


Features

Dashboard

  • Interactive dashboard showing all the data in separate cards.
  • Drag and drop the cards in a custom order
  • The dashboard uses websocket, so there is no need for refreshing the page - the data renders continuously
  • Responsive design for PC's, mobile phones and Raspberry Pi 7" touchscreen
  • Alarm system integrated with Xiaomi IOT devices
  • Custom actions when the alarm status changes, e.g. from armed to ringing send mail
  • Custom alarm codes for each user
  • User defined arm time
  • Integrated with Xiaomi Smart Home devices
  • Constantly monitor your devices
  • Send commands to your device, e.g. play sound on the gateway
  • Auto discovery of devices
  • Schedule automatic actions on the minute
  • Utilize actions from the different modules, e.g. send mails, notifications, etc.
  • Monitor the expiration date on your SSL certificates
  • View where each of your Owntrack devices are located
  • Add custom waypoints to the map
  • Use Google maps
  • Connect to your mail server and create mail templates, which can be used in the different modules
  • Define custom MQTT templates (topic and message)
  • Send MQTT message when the alarm changes status or with cronjobs
  • Send test messages via MQTT
  • Create templates which can be used in different modules
  • Test commands from the browser

OS stats

  • Monitor the health of your system

** Compile with -d:rpi to enable **

  • Automate actions using the Raspberry Pi's GPIO
  • Write to the pins
  • Read the values from the pins
  • Keep an eye on your favorite RSS feeds
  • Watch your MJPEG stream from the dashboard
  • Show a static image from URL
  • Get a static image from a LAN url, save the image to NimHA and show it, to avoid exposing LAN url to the internet
  • Stay notified with the Pushbullet integration on all your devices

.. and more to come

Run Nim Home Assistant

1) Ensure that all the requirements are fulfilled: Wiki - Requirements

2) Install and run NimHA: Wiki - Install

nim_homeassistant's People

Contributors

federicoceratto avatar thomastjdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nim_homeassistant's Issues

[Feature] Dynamic adding new modules

Current modules are always included. Goal: Add/Remove modules

  • Make use of macro to include user specified modules at compile time.
  • Define guideline for new modules
  • Document current available procs, which the modules can import, e.g. dates, mail, etc.

Dashboard alarm: Not showing correct status

The dashboard (dashboard.tmpl) has not been updated to use alarm[0] for checking the alarm status.

# Correct
Alarm = tuple[status: string, armtime: string, countdown: string, armedtime: string]

# Bug
<div data-id="cardAlarm" class="cardAlarm item col-12 col-sm-6 col-md-6 col-lg-3">
  <div class="inner">
    # let alarmStatus = getValue(db, sql"SELECT status FROM alarm WHERE id = ?", "1")
    # template alarmClass(status: string): string =
    #   if status == alarmStatus:

Crash test

This crash test was to check for breakdowns over a period of time of 24 hours * 2. No crashes after the refactory.

Module: Pihole

http://[lanip]/admin/api.php?summary

  • type
  • version
  • overTimeData10mins
  • recentBlocked

[Bug] Alarm: Wait for countdown before ringing

When the nimha_gateway receives a message with a trigger, it starts the trigger proc asyncCheck alarmTriggered(). Inside the trigger proc, I would like to run a loop with await sleepAsync. The loop needs to break, if the user changes the alarm status from triggered to disarmed. If the user does not change the alarm status before the countdown time, the loop will set alarm status to ringing and break.

But using await inside this proc does not work. The await never finishes - therefore the alarm will never start ringing.

Trigger proc

proc alarmTriggered*(db: DbConn, trigger, device: string) {.async.} =

Await tries inside the trigger proc

# One of many tries
proc alarmTriggerTimer() {.async.}  = 
  var counter = 0
  while true:
    waitFor sleepAsync(1000)
    inc(counter)
    if counter == countDownTime or alarmStatus != "triggered":
      break

var f = alarmTriggerTimer(countDown)
while not f.finished:
  poll(1000)
    
if f.finished:
  if alarmStatus == "triggered":
    asyncCheck alarmRinging(db, trigger, device)

# Another try
var counter = 0
while true:
  await sleepAsync(100)
  inc(counter)
  if counter == countDownTime and alarmStatus == "triggered":
    alarmRinging(db, trigger, device)
    break
  elif counter == countDownTime and alarmStatus != "triggered":
    break

[Feature] MQTT notifications

Add a MQTT module. Features:

  1. Setup custom topics which the user can subscribe to, e.g. from an Android app. The current message format is specified to the JS fronted
  2. Custom listening topics. Let the user control NimHA with user defined MQTT messages.

MQTT blocking listener crashes

The blocking listener used in all runners breaks in nim 0.18.1 (devel) while callbacks works fine.

Test:
Change runners to use 1 file with callbacks. That will always ease the way to use macros to implement new modules.
Keep websocket in individual file due to blocking waitFor and due to crashed
Keep www browser in individual file

Alarm: Send email does not work

proc alarmAction(db: DbConn, state: string) {.async.} = does not exec asyncCheck sendMailDb(db, row[1]) inside alarm.nim.

Nothing happens inside mail.nim.

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.