smart-home

command module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2019 License: MIT Imports: 24 Imported by: 0

README

The program complex Smart House

Project site | Configurator | Node | Development Tools | Smart home Socket | Modbus device controller

Build Status Coverage Status

smart-home logo

Attention! The project is under active development.

Overview

Basic principles Underlying the system being developed, ease of configuration and content, cheapness and availability of the component base. So you can manage a lot of devices based on AVR microcontrollers and not only. A distributed network does not have geographic boundaries and allows you to manage devices anywhere in the Internet through System of nodes - microservices. And you will be able to interact with these devices in the way that they are In your local network. Create scripts, and respond to events in the web interface of the configurator through a flexible scripting system. Manage the state of devices from any subnet where the management server is available.

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
curl -sSL http://e154.github.io/smart-home/server-installer.sh | bash /dev/stdin --install
Configurator
curl -sSL http://e154.github.io/smart-home/configurator-installer.sh | bash /dev/stdin --install
Node
curl -sSL http://e154.github.io/smart-home/node-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;

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

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 &

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

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
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
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