Skip to content

Bialson/solarenergy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solarenergy

This tool provides interaction with energy consumption data from Poland's Central Statistical Office (GUS) provided by API DBW, created also by GUS.

Features

  • Decoding data returned from API DBW
  • Sorting results by region name
  • Filtering results with region name and character
  • Displaying results in custom CLI
  • Serving API over TLS
  • Routing gRPC-web requests directly to gRPC Go Server

Roadmap

  • More filtering parameters
  • Stats for eco power sources

Tech Stack

Client CLI: Go + urfave cli v2

Server: Go + gRPC


Installation

Make sure you have installed Go. Next configure Go paths in your profile files.

Linux ~/.profile

  export GOPATH=$HOME/go
  export PATH=$PATH:$GOPATH/bin
  export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin

Verify path by following command (if path contains above paths everything is fine)

  $GOPATH

Windows

Check your enviromental variable

  $env:GOPATH

If everything is ok you should get the following path in you console

  C:\Users\[username]\go

Add the workspace’s bin subdirectory to your $PATH. You can do this using the setx command in PowerShell

  setx PATH "$($env:path);$GOPATH\bin"

Docker

Change directory to main folder solarenergy and then build image

  docker build --pull --rm -f "Dockerfile" -t solarenergy:latest "." 

CLI's installation

Clone repository to your local folder

  git clone https://github.com/Bialson/solarenergy.git

Your folder structure will be looking like this

.
└── solarenergy/
    ├── proto/
    │   ├── energy_grpc.pb.go
    │   ├── energy.pb.go
    │   └── energy.proto
    ├── solarenergy-cli/
    │   ├── bin/
    │   │   └── solarenergy-cli
    │   ├── main.go
    │   └── service.go
    ├── solarenergy-server/
    │   ├── bin/
    │   │   └── solarenergy-server
    │   │── gRPC_classic/
    │   │   └── main.go
    │   │── gRPC_web/
    │   │   └── main.go
    │   ├── service_test.go
    │   ├── service.go
    │   ├── test_server.go
    │   ├── tools.go
    │   ├── variables.go
    │   └── web_tls.go
    ├── .gitignore
    ├── Dockerfile
    ├── go.mod
    ├── go.sum
    ├── Makefile
    ├── README.md
    └── run.sh

To install client and server CLI change directory to solarenergy-cli and solarenergy-server folders and run go install command in each folder

  cd solarenergy-cli
  go install
  cd ../solarenergy-server
  go install

Note Package provides builded files ready to install, if you want to add some changes and then rebuild the preffered CLI, run go build -o bin/[file_name] command in it's folder.


Run Locally

Start server

  solarenergy-server

On your you will be receiving log's from server, request, response status.

Run client

  solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME -ch REGION_CHARACTER -a AMOUNT_VALUE

If you run solarenergy-cli command without params, you should see help page with all params supported by this command.

Run tests

  cd solarenergy-server
  go test

Run docker image

  docker run --rm -it  solarenergy:latest 

Client CLI Reference

Note If you don't provide any optional params, data request will be executed with default values

Parameter Type Value
Year int 2020
Response amount int 0
Region string ""
Region character string ""

Get all data

  solarenergy-cli gp -y YEAR_VALUE
Parameter Type Description
get-power, gp string Required. Get power consumption command
--year, -y int Optional. Get power consumption from given year

Get data from region

  solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME
Parameter Type Description
--year, -y int Optional. Get power consumption from given year
--region, -r string Optional. Precise power consumption by region

Get data by region character

  solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME -ch REGION_CHARACTER
Parameter Type Description
--year, -y int Optional. Get power consumption from given year
--region, -r string Optional. Precise power consumption by region
--character, -ch string Optional. Precise power consumption by region character

Get data and precise their amount

  solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME -ch REGION_CHARACTER -a AMOUNT_VALUE
Parameter Type Description
--year, -y string Optional. Get power consumption from given year
--region, -r string Optional. Precise power consumption by region
--character, -ch string Optional. Precise power consumption by region character
--amount, -a int Optional. Limit power consumption records

Params reference

Parameter Type Value
Year int <2000; 2020>
Response amount int <0; 204>
Region string POLSKA
MAŁOPOLSKIE
ŚLĄSKIE
LUBUSKIE
WIELKOPOLSKIE
ZACHODNIOPOMORSKIE
DOLNOŚLĄSKIE
OPOLSKIE
KUJAWSKO-POMORSKIE
POMORSKIE
WARMIŃSKO-MAZURSKIE
ŁÓDZKIE
ŚWIĘTOKRZYSKIE
LUBELSKIE
PODKARPACKIE
PODLASKIE
MAZOWIECKIE
Region character string Ogółem
Miasto
Wieś

About

gRPC API for analyzing power consumption from Poland

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages