smart-home

command module
v0.0.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2019 License: MIT Imports: 30 Imported by: 0

README

The program complex Smart House

Project site | Configurator | Mobile Gate | Node | Smart home Socket | Modbus device controller | Mobile app

Build Status Go Report Card status

smart-home logo

Attention! The project is under active development.

Overview

With the help of the software package Smart Home you can control many devices. Distributed network of devices based on software package Smart Home has no geographical boundaries and allows manage devices anywhere in the Internet through a system of nodes - microservices. You will be able to interact with these devices as if they were on your local network. Create scripts and reactions to events in the web interface of the configurator through a flexible scripting system.

The system does not require a permanent connection to the Internet, it is completely autonomous and has no dependencies on external services.

The basic principles underlying the system being developed are ease of setup, low cost of content and accessibility of the component base.

Features
  1. The ultimate smart thing solution - server, configurator, nodes, gateway, mobile application
  2. Open API
  3. Cross-platform Linux, MacOS, Windows ...
  4. Convenient WEB-configurator for fine-tuning
  5. Mobile application for equipment management
  6. Role system for separation of access rights
  7. Programs in javaScript, coffeeScript, typeScript
  8. Notification system SMS, Email, Slack, Telegram
  9. If MODBUS is small, you can work through calling external programs / scripts, which greatly expands the possibilities
  10. Autonomous system.
  11. Quick backup of all data, and recovery - literally in two teams
  12. Have Docker images to enhance system security
  13. Minimum consumption of resources.
Demo access

dashboard (https://board.e154.ru)
swagger (https://sh.e154.ru/api/v1/swagger)

user: admin@e154.ru
pass: admin

user: user@e154.ru
pass: user

Supported system
  • macOS 386 10.6
  • macOS amd64 10.6
  • linux 386
  • linux amd64
  • linux arm-5
  • linux arm-6
  • linux arm-7
  • linux arm-64
  • linux mips64
  • linux mips64le
  • windows 386
  • windows amd64

Schematic smart home map

smart-home map
Quick installation

Installation help

Server

on linux

curl -sSL http://e154.github.io/smart-home/server-installer.sh | bash /dev/stdin --install
Configurator

on linux

curl -sSL http://e154.github.io/smart-home/configurator-installer.sh | bash /dev/stdin --install
Node

on linux

curl -sSL http://e154.github.io/smart-home/node-installer.sh | bash /dev/stdin --install
Mobile gate

on linux

curl -sSL http://e154.github.io/smart-home/gate-installer.sh | bash /dev/stdin --install
Database postgresql

System Smart Home works with Postgresql database. Create a database and database user with full rights to this database. Connection parameters to the database must be specified in the configuration file. Updating the server version may require updating the database. , migrations will start automatically, manual intervention is not required.

sudo -u postgres psql
postgres=# create database mydb;
postgres=# create user myuser with encrypted password 'mypass';
postgres=# grant all privileges on database mydb to myuser;
Backup and restore settings

reset setting

./server -reset

backup, in the snapshots directory an archive will be created with a copy of the database, and the downloaded images

./server -backup

restore settings from a previously created archive

./server -restore 2019-08-25T18:13:11.17.zip

Run server

./server

 ___                _     _  _
/ __|_ __  __ _ _ _| |_  | || |___ _ __  ___
\__ \ '  \/ _' | '_|  _| | __ / _ \ '  \/ -_)
|___/_|_|_\__,_|_|  \__| |_||_\___/_|_|_\___|


2019/06/16 17:11:49 Graceful shutdown service started
2019/06/16 17:11:49 database connect dbname=mydb user=myuser password=mypass host=127.0.0.1 port=5432 sslmode=disable
2019/06/16 17:11:49 pq: permission denied to create extension "pgcrypto" handling 20181113_013141_workflow_elements.sql
2019/06/16 17:11:49 Applied 3 migrations!
2019/06/16 17:11:49 Serving server at tcp://[::]:1883
2019/06/16 17:11:49 subscribe get_image_list
2019/06/16 17:11:49 subscribe get_filter_list
2019/06/16 17:11:49 subscribe remove_image
INFO[0000] SRT.server.server.go:49.Start() > Serving server at http://[::]:3000
INFO[0000] SRT.telemetry.telemetry.go:37.Run() > Run
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe dashboard.get.nodes.status
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe t.get.flows.status
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe dashboard.get.telemetry
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe map.get.devices.states
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe map.get.telemetry
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe do.worker
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe do.action

it may happen that you need to grant superuser privileges in the permissions of the database user.

postgres=# alter user myuser with superuser;
bash-3.2$ ./server

 ___                _     _  _
/ __|_ __  __ _ _ _| |_  | || |___ _ __  ___
\__ \ '  \/ _' | '_|  _| | __ / _ \ '  \/ -_)
|___/_|_|_\__,_|_|  \__| |_||_\___/_|_|_\___|


2019/06/16 17:23:45 Graceful shutdown service started
2019/06/16 17:23:45 database connect dbname=mydb user=myuser password=mypass host=127.0.0.1 port=5432 sslmode=disable
2019/06/16 17:23:46 Applied 10 migrations!
2019/06/16 17:23:46 Serving server at tcp://[::]:1883
2019/06/16 17:23:46 subscribe get_image_list
2019/06/16 17:23:46 subscribe get_filter_list
2019/06/16 17:23:46 subscribe remove_image
INFO[0000] SRT.server.server.go:49.Start() > Serving server at http://[::]:3000
INFO[0000] SRT.telemetry.telemetry.go:37.Run() > Run
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe dashboard.get.nodes.status
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe t.get.flows.status
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe dashboard.get.telemetry
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe map.get.devices.states
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe map.get.telemetry
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe do.worker
INFO[0000] SRT.stream.hub.go:155.Subscribe() > subscribe do.action

Server can by run on the port: 3000

Run configurator

/opt/smart-home/configurator/configurator

The configurator console will be available in the browser at http://localhost:8080

Run node

/opt/smart-home/node/node

Run mobile gate

/opt/smart-home/gate/gate

The same commands, but without binding to the console

/opt/smart-home/server/server > /dev/null 2>&1 &
/opt/smart-home/configurator/configurator > /dev/null 2>&1 &
/opt/smart-home/node/node > /dev/null 2>&1 &
/opt/smart-home/gate/gate > /dev/null 2>&1 &

It's all:)

Installation for development
main server install
go get -u github.com/golang/dep/cmd/dep

git clone https://github.com/e154/smart-home $GOPATH/src/github.com/e154/smart-home

cd $GOPATH/src/github.com/e154/smart-home

dep ensure

go build

./smart-home -reset
./smart-home

editing configuration files

cp conf/config.dev.json conf/config.json
cp conf/dbconfig.dev.yml conf/dbconfig.yml

manually create the database and run the command

./smart-home migrate

run server

./smart-home

for test

./examples/scripts/auth.sh
Docker
git clone https://github.com/e154/smart-home
cd smart-home
docker-compose up

connect to the database, create two smart-home databases, smart-home-gate

It's all

Testing

The system supports self-testing of internal components, and is started by the command

go test ./tests -v
Support

Smart home Wiki: e154.github.io/smart-home Bugs and feature requests: GitHub issues

Contributors

All the contributors are welcome. If you would like to be the contributor please accept some rules.

  • The pull requests will be accepted only in "develop" branch
  • All modifications or additions should be tested

Thank you for your understanding!

See also
LICENSE

MIT Public License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
mobile/v1
Smart home This documentation describes APIs found under https://github.com/e154/smart-home BasePath: /api/v1 Version: 1.0.0 License: MIT https://raw.githubusercontent.com/e154/smart-home/master/LICENSE Contact: Alex Filippov <support@e154.ru> https://e154.github.io/smart-home/ Consumes: - application/json Produces: - application/json Security: - BasicAuth - ApiKeyAuth SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header BasicAuth: type: basic swagger:meta
Smart home This documentation describes APIs found under https://github.com/e154/smart-home BasePath: /api/v1 Version: 1.0.0 License: MIT https://raw.githubusercontent.com/e154/smart-home/master/LICENSE Contact: Alex Filippov <support@e154.ru> https://e154.github.io/smart-home/ Consumes: - application/json Produces: - application/json Security: - BasicAuth - ApiKeyAuth SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header BasicAuth: type: basic swagger:meta
server/v1
Smart home This documentation describes APIs found under https://github.com/e154/smart-home BasePath: /api/v1 Version: 1.0.0 License: MIT https://raw.githubusercontent.com/e154/smart-home/master/LICENSE Contact: Alex Filippov <support@e154.ru> https://e154.github.io/smart-home/ Consumes: - application/json Produces: - application/json Security: - BasicAuth - ApiKeyAuth SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header BasicAuth: type: basic swagger:meta
Smart home This documentation describes APIs found under https://github.com/e154/smart-home BasePath: /api/v1 Version: 1.0.0 License: MIT https://raw.githubusercontent.com/e154/smart-home/master/LICENSE Contact: Alex Filippov <support@e154.ru> https://e154.github.io/smart-home/ Consumes: - application/json Produces: - application/json Security: - BasicAuth - ApiKeyAuth SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header BasicAuth: type: basic swagger:meta
server/v2
Smart home This documentation describes APIs found under https://github.com/e154/smart-home BasePath: /api/v2 Version: 2.0.0 License: MIT https://raw.githubusercontent.com/e154/smart-home/master/LICENSE Contact: Alex Filippov <support@e154.ru> https://e154.github.io/smart-home/ Consumes: - application/json Produces: - application/json Security: - BasicAuth - ApiKeyAuth SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header BasicAuth: type: basic swagger:meta
Smart home This documentation describes APIs found under https://github.com/e154/smart-home BasePath: /api/v2 Version: 2.0.0 License: MIT https://raw.githubusercontent.com/e154/smart-home/master/LICENSE Contact: Alex Filippov <support@e154.ru> https://e154.github.io/smart-home/ Consumes: - application/json Produces: - application/json Security: - BasicAuth - ApiKeyAuth SecurityDefinitions: ApiKeyAuth: type: apiKey name: Authorization in: header BasicAuth: type: basic swagger:meta
cmd
pingmq
The following commands will run pingmq as a server, pinging the 8.8.8.0/28 CIDR block, and publishing the results to /ping/success/{ip} and /ping/failure/{ip} topics every 30 seconds.
The following commands will run pingmq as a server, pinging the 8.8.8.0/28 CIDR block, and publishing the results to /ping/success/{ip} and /ping/failure/{ip} topics every 30 seconds.
system
dig
Package dig provides an opinionated way of resolving object dependencies.
Package dig provides an opinionated way of resolving object dependencies.
orm
uuid
Package uuid provides implementation of Universally Unique Identifier (UUID).
Package uuid provides implementation of Universally Unique Identifier (UUID).
validation
Package validation for validations import ( "github.com/astaxie/beego/validation" "log" ) type User struct { Name string Age int } func main() { u := User{"man", 40} valid := validation.Validation{} valid.Required(u.Name, "name") valid.MaxSize(u.Name, 15, "nameMax") valid.Range(u.Age, 0, 140, "age") if valid.HasErrors() { // validation does not pass // print invalid message for _, err := range valid.Errors { log.Println(err.Key, err.Message) } } // or use like this if v := valid.Max(u.Age, 140, "ageMax"); !v.Ok { log.Println(v.Error.Key, v.Error.Message) } } more info: http://beego.me/docs/mvc/controller/validation.md
Package validation for validations import ( "github.com/astaxie/beego/validation" "log" ) type User struct { Name string Age int } func main() { u := User{"man", 40} valid := validation.Validation{} valid.Required(u.Name, "name") valid.MaxSize(u.Name, 15, "nameMax") valid.Range(u.Age, 0, 140, "age") if valid.HasErrors() { // validation does not pass // print invalid message for _, err := range valid.Errors { log.Println(err.Key, err.Message) } } // or use like this if v := valid.Max(u.Age, 140, "ageMax"); !v.Ok { log.Println(v.Error.Key, v.Error.Message) } } more info: http://beego.me/docs/mvc/controller/validation.md
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL