Skip to content

Commit

Permalink
remove production env mode, refactor readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ardean committed Feb 1, 2017
1 parent e68e25b commit ca60d62
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 92 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
**A Web Based Sauna Control System written in JavaScript**

I use this package to control my sauna with my **Raspberry pi**.
There is a solid state relay to switch the heater *On* and *Off*, as well as a *temperature* and *humidity* sensor to measure the surroundings.
There is a solid state relay to switch the heater `On` and `Off`, as well as a `temperature` and `humidity` sensor to measure the surroundings.

- DHT Sensor: https://www.adafruit.com/product/393
- Solid State Relay: https://www.sparkfun.com/products/13015
- DHT Sensor: [https://www.adafruit.com/product/393](https://www.adafruit.com/product/393)
- Solid State Relay: [https://www.sparkfun.com/products/13015](https://www.sparkfun.com/products/13015)

![jsSauna - Webapp](docs/images/ui.png)

Pick a `target temperature` and switch the sauna `On` / `Off`.

## Quick Start

Install jsSauna globally:
Expand Down Expand Up @@ -69,11 +71,14 @@ $ npm start

## Production

please set the environment variable for production use:
I'm using [pm2](https://www.npmjs.com/package/pm2) on my production system to start jsSauna.

```sh
NODE_ENV="production" jsSauna --rp 14 --sp 4
```
Make sure you install jsSauna with all optional dependencies!
Otherwise you will use **testdata** for the sensors and On / Off requests will be **ignored** for the relay!

### Troubleshooting

If you have problems installing jsSauna globally as root using `sudo npm i -g jssauna`, you can try the option `--unsafe-perm`.

## TODO

Expand Down
8 changes: 6 additions & 2 deletions dist/server/am2302.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
let dhtSensor;

if (process.env.NODE_ENV === "production") {
var _util = require("util");

let dhtSensor;
try {
dhtSensor = require("node-dht-sensor");
} catch (e) {
(0, _util.log)("node-dht-sensor is not installed! Using test data!");
}

class AM2302 {
Expand Down
75 changes: 0 additions & 75 deletions dist/server/package.json

This file was deleted.

6 changes: 5 additions & 1 deletion dist/server/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _util = require("util");

var _events = require("events");

let Gpio;
if (process.env.NODE_ENV === "production") {
try {
Gpio = require("onoff").Gpio;
} catch (e) {
(0, _util.log)("onoff is not installed! Ignoring On / Off requests!");
}

class Relay extends _events.EventEmitter {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jssauna",
"version": "0.1.3",
"version": "0.1.4",
"description": "A Web Based Sauna Control System written in JavaScript",
"main": "src/index.js",
"author": "ardean",
Expand All @@ -21,8 +21,7 @@
],
"scripts": {
"start": "babel-node src/cli.js --username admin --pw 1234",
"export": "npm run build && npm run export-server && npm run export-html && npm run export-css && npm run export-img",
"export-server": "cpy package.json dist/server",
"export": "npm run build && npm run export-html && npm run export-css && npm run export-img",
"export-html": "cpy public/*.html dist/public",
"export-css": "cpy public/*.css dist/public",
"export-img": "cpy public/*.jpg dist/public",
Expand Down
7 changes: 5 additions & 2 deletions src/am2302.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
let dhtSensor;
import { log } from "util";

if (process.env.NODE_ENV === "production") {
let dhtSensor;
try {
dhtSensor = require("node-dht-sensor");
} catch (e) {
log("node-dht-sensor is not installed! Using test data!");
}

export default class AM2302 {
Expand Down
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Sauna, SaunaControl, AM2302, Relay } from "./";
import program from "commander";

program
.version("0.1.0")
.version("0.1.4")
.option("-p, --port <port>", "override default webserver port", parseInt)
.option("-t, --target-temperature <targetTemperature>", "override default target temperature (50°C)", parseInt)
.option("-m, --max-temperature <maxTemperature>", "override default max temperature (60°C)", parseInt)
Expand Down
5 changes: 4 additions & 1 deletion src/relay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { log } from "util";
import { EventEmitter } from "events";

let Gpio;
if (process.env.NODE_ENV === "production") {
try {
Gpio = require("onoff").Gpio;
} catch (e) {
log("onoff is not installed! Ignoring On / Off requests!");
}

export default class Relay extends EventEmitter {
Expand Down

0 comments on commit ca60d62

Please sign in to comment.