Skip to content

Install NimHA

Thomas T. Jarløv edited this page Aug 7, 2018 · 7 revisions

NimHA is developed with Nim-lang. Nim is a systems and applications programming language. Statically typed and compiled and it provides unparalleled performance.

Requirements

Nim requirements

  • nim >= 0.18.1
  • (nim) bcrypt >= 0.2.1
  • (nim) jester >= 0.4.0
  • (nim) multicast >= 0.1.1
  • (nim) recaptcha >= 1.0.2
  • (nim) websocket >= 0.3.1

Third party requirements

The requirements below are used within NimHA until they can be replaced with pure Nim. Make sure they are installed on your system.

  • curl (Pushbullet)
  • mosquitto (nearly all modules)
  • openssl (ssl)
  • python3 (encrypting token for Xiaomi)
  • pycrypto (encrypting token for Xiaomi)

Install Nim

The official instructions can be found here https://nim-lang.org/install.html

Choosenim

Installing with choosenim is very easy. Just run:

curl https://nim-lang.org/choosenim/init.sh -sSf | sh
choosenim devel

Raspberry Pi

Choosenim does currently (2018 August) not support amd. You need to follow the instructions on https://github.com/nim-lang/Nim#compiling. After compiling Nim symlink your executable:

ln -sf /the/path/to/nim/git/Nim/bin/nim /usr/bin/nim
ln -sf /the/path/to/nim/git/Nim/bin/nimble /usr/bin/nimble

Install Nim packages

The Nim packages can all be installed with Nimble.

Run the following commands:

nimble install bcrypt
nimble install jester
nimble install multicast
nimble install recaptcha
nimble install websocket

Install NimHA

NimHA can be installed in 2 ways - through Nimble or you can compile it.

Nimble

Run:

nimble install nimha

Compiling

Available compile options are shown below

Run:

cd
git clone https://github.com/ThomasTJdev/nim_homeassistant.git
cd nim_homeassistant
nim c nimha.nim

Compile options

When you are compiling NimHA, you have access to the following compile options. Append the parameters to nim c nimha.nim.

  • -d:dev = Run development/debug mode
  • -d:devmailon = Allow sending mails in dev mode
  • -d:logoutput = Enhanced logging
  • -d:rc = Recompile all modules. NimHA will not recompile modules without this if the modules exists. To recompile a single module use the options below.
  • -d:rcwss = Recompile Websocket
  • -d:rccron = Recompile Cron
  • -d:rcwebinterface = Recompile Webinterface
  • -d:rcgatewaywss = Recompile Websocket gateway
  • -d:rcgateway = Recompile Main gateway
  • -d:rcxlistener = Recompile Xiaomi listener

Update config

Your config file (secret.cfg) are located in the config-folder.

Copy the template before editing:

cp config/secret_default.cfg config/secret.cfg

Required config update

It is required that the following details are updated:

  • [MQTT]
  • [Websocket] - only needs update if you are using Nginx/SSL

Add an admin user

To get access to NimHA, you need to add an admin user. Only 1 admin user is allowed.

Run NimHA with following arguments:

./nimha newuser -u:username -p:password -e:my@email.com

Run NimHA

Make sure that your MQTT broker is up and running, e.g. sudo systemctl start mosquitto.

Run NimHA from file:

./nimha

Run NimHA after compile:

nim c -r nimha.nim