Skip to content

Commit

Permalink
removed some duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunvor Nilsson committed Aug 21, 2019
1 parent b72a269 commit 9a3df6c
Show file tree
Hide file tree
Showing 43 changed files with 532 additions and 862 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ typings/
howto.txt
torasp.txt
*.sqlite
.coveralls.yml

77 changes: 49 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
# bbbnode
[![Build Status](https://travis-ci.org/guni12/bbbnode.svg?branch=master)](https://travis-ci.org/guni12/bbbnode) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/guni12/bbbnode/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/guni12/bbbnode/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/guni12/bbbnode/badges/build.png?b=master)](https://scrutinizer-ci.com/g/guni12/bbbnode/build-status/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b293df61900a45f5afae54b63d759876)](https://www.codacy.com/app/guni12/bbbnode?utm_source=github.com&utm_medium=referral&utm_content=guni12/bbbnode&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/guni12/bbbnode.svg?branch=master)](https://travis-ci.org/guni12/bbbnode) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/guni12/bbbnode/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/guni12/bbbnode/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/guni12/bbbnode/badges/build.png?b=master)](https://scrutinizer-ci.com/g/guni12/bbbnode/build-status/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b293df61900a45f5afae54b63d759876)](https://www.codacy.com/app/guni12/bbbnode?utm_source=github.com&utm_medium=referral&utm_content=guni12/bbbnode&utm_campaign=Badge_Grade) [![Coverage Status](https://coveralls.io/repos/github/guni12/bbbnode/badge.svg?branch=master)](https://coveralls.io/github/guni12/bbbnode?branch=master)

# TODO
# BehovsBoBoxen är ett styrsystem för smarta hem baserad på Raspberry Pi.

* Konfigurera sd-kort
* Ladda hem raspbian
* Enable ssh
* Andra configurationer som tangentbord etc
* Byt lösenord!!!
* Enable 1-Wire
* Enable spi
![detta behöver du](http://www.behovsbo.se/themes/images/bbbmaterial.jpg)

Bom | Antal | Materiallista
--- | ------|--------------
1 | 1 | Raspberry pi 2 eller 3 modell B
2 | 9 | ds18b20 (1-wire eller dallas)
3 | 1 | micro SD kort, gärna minst 32GB
4 | 1 | reläkort med 8 relän
5 | 1 | 5V 2,1A USB laddare
6 | 1 | kopplingsdäck
7 | 1 | knippe kopplingssladdar hane-hane
8 | 1 | knippe kopplingssladdar hona-hona
9 | 1 | Ethernetsladd

Mjukvaran för styrsystemet är byggt med Node.js, Express, React och Sqlite3.

### Gör så här:

- Konfigurera sd-kortet, installera raspbian och konfigurera till svenska förhållanden.
- `https://www.raspberrypi.org/documentation/installation/noobs.md`
- Aktivera ssh.
- Byt lösenord!!!
- Aktivera 1-Wire
- Aktivera spi
- Hämta BehovsBoBoxen med:
```sh
git clone https://github.com/guni12/bbbnode
```
* öppna `/home/pi/bbbnode/scripts/pass.txt` - ändra lösenordet till ditt eget val
* kopiera hela kommandot och kör i en terminal
- Öppna `/home/pi/bbbnode/scripts/pass.txt` och ändra lösenordet till ditt eget val
- Kopiera hela ovan kommando och kör det i en terminal
- Kör sedan
```sh
sudo sh /home/pi/bbbnode/scripts/install.sh
```
* `cd bbbnode`
- Efter reboot gå till boxens katalog:
- `cd bbbnode`
- Kör följande kommandon:

```sh
npm install
Expand All @@ -27,34 +47,35 @@ sqlite3 texts.sqlite
.read migrate.sqlite
.exit
```
* `cd ..`
öppna terminal och kör igång servern:
- Gå tillbaka:
- `cd ..`
- Öppna en terminal och kör igång servern:
```sh
npm start
```
* gå in i webbläsaren med `http://localhost/find`
* sedan `http://localhost/init`
* sedan installera sensorer...
* sedan `http://ditt.ip.n.r:8787/zones`
* Bestäm namn på zonerna
* Koppla aktiva relän till zonerna via `http://ip.nr:8787/rpio`
* hämta spotpriser genom ett pythonscript
- Installera sensorer:
- Gå in i webbläsaren med `http://localhost/find`
- sedan `http://localhost/init`
- sedan `http://ditt.ip.n.r:8787/zones`
- Bestäm namn på zonerna
- Koppla aktiva relän till zonerna via `http://ip.nr:8787/rpio`
- hämta spotpriser genom ett pythonscript
```sh
python3 /home/pi/bbbnode/public/scripts/spot/checkfile.py
```
* `http://localhost:1337/tempupdate`
* `http://localhost:1337/hourcontrol`
* öppna ny terminal:
- `http://localhost:1337/tempupdate`
- `http://localhost:1337/hourcontrol`
- öppna ny terminal:
```sh
sudo crontab -l -u root | cat /home/pi/bbbnode/scripts/cron.txt | sudo crontab -u root -
```
* om du vill se vilka processer som är aktiva:
- om du vill se vilka processer som är aktiva:
```sh
sudo lsof -i -P -n | grep LISTEN
```
* för att släcka server-process och göra omstart:
- för att släcka server-process och göra omstart:
```sh
sudo fuser -k 1337/tcp
```
*
* port forwarding...
- port forwarding...
125 changes: 125 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
"devDependencies": {
"chai": "^4.2.0",
"chai-http": "^4.3.0",
"codecov": "^3.5.0",
"concurrently": "^4.1.1",
"coveralls": "^3.0.6",
"eslint": "^6.1.0",
"eslint-plugin-react": "^7.14.3",
"javascript-style-guide": "^1.0.1",
"mocha": "^6.2.0",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^14.1.1"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/array.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Data type(PR)":"PR","Code(SO,SF)":"SO","Year":"2019","Week":"32","Day of week":"6","Date(dd.mm.yyyy)":"10.08.2019","Area":"SE1","Currency":"EUR","Hour1":"34,87","Hour2":"34,67","Hour3A":"33,92","Hour3B":"","Hour4":"32,73","Hour5":"31,70","Hour6":"31,42","Hour7":"32,17","Hour8":"33,99","Hour9":"35,24","Hour10":"36,05","Hour11":"36,07","Hour12":"35,88","Hour13":"35,54","Hour14":"35,11","Hour15":"34,91","Hour16":"34,82","Hour17":"34,96","Hour18":"35,32","Hour19":"35,13","Hour20":"34,01","Hour21":"34,00","Hour22":"32,43","Hour23":"31,83","Hour24":"32,01","Average":"34,12"}
{"Data type(PR)":"PR","Code(SO,SF)":"SO","Year":"2019","Week":"34","Day of week":"3","Date(dd.mm.yyyy)":"21.08.2019","Area":"SE1","Currency":"EUR","Hour1":"33,07","Hour2":"33,11","Hour3A":"32,01","Hour3B":"","Hour4":"31,23","Hour5":"31,93","Hour6":"33,97","Hour7":"37,43","Hour8":"38,20","Hour9":"39,38","Hour10":"39,08","Hour11":"38,00","Hour12":"37,30","Hour13":"36,60","Hour14":"36,04","Hour15":"35,85","Hour16":"35,69","Hour17":"35,97","Hour18":"37,57","Hour19":"36,98","Hour20":"36,98","Hour21":"36,96","Hour22":"38,71","Hour23":"36,57","Hour24":"35,87","Average":"36,02"}
15 changes: 9 additions & 6 deletions public/javascripts/all-zones.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ const db = require('../../db/database.js');
const reg = require('./status.js');

module.exports = (function () {
function getZones(req, res, next) {
if (req.params.id) {
getOneZone(req, res, next);
} else {
getAllZones(req, res, next);
}
}

function getAllZones(req, res, next) {
let sql = "SELECT * FROM zones;";

db.all(sql,
(err, rows) => {
if (rows) {
//console.log(rows);
//return res.json(rows);
req.zones = rows;
next();
} else {
Expand All @@ -25,12 +31,9 @@ module.exports = (function () {
function getOneZone(req, res, next) {
let sql = "SELECT * FROM zones WHERE id = ?";

//console.log(req.body, req.params);
db.get(sql,
req.params.id, (err, row) => {
if (row) {
//console.log(row);
//return res.json(row);
req.zones = row;

next();
Expand All @@ -48,14 +51,14 @@ module.exports = (function () {
function show(req, res) {
let what = req.zones;

//console.log(what);
return res.json(what);
}


return {
getAllZones: getAllZones,
getOneZone: getOneZone,
getZones: getZones,
show: show
};
}());

0 comments on commit 9a3df6c

Please sign in to comment.