1.9.0 • Published 2 years ago

smartthings-phevctl v1.9.0

Weekly downloads
773
License
Apache-2.0
Repository
github
Last release
2 years ago

Smartthings and SMS Remote control for Outlander PHEV

SMS and Smartthings application wrapper over phevctl

  • Node.js CI
  • docker
  • NPM
  • donate

smartthings.gif smartthings.gif Charger.pngdoorLock.pngnpm.io

Features:

comparison of installation types

Installation TypeExecute action(heating/cooling/headlights and etc...)Smartthings Hub requiredInternet connection requiredcan send/receive SMShuawei e3372h-320(CL4E3372HM) / MikroTik LtAP mini LTE kitRaspberry Pi must be installedSend Push Notifications
Cloud Installation (run smartthings-phevctl on the cloud)ImmediatelyNoYesNoYesNoYes
Cloud Installation with rapberry Pi(Cloud is forwarded smartthings-phevctl)ImmediatelyNoNoYesYesYesYes
Сontrol over SMS without smartthings1-2 minutes delayNoNoYesYesYesNo
Local Network Installation(under NAT)ImmediatelyYesYesNoYesNoYes
Run without cloud and without Smartthings Hub2-5 minutes delayNoNoYesYesYesYes

Cloud Installation

Without cloud installation

Outlander PHEV Registration

Installation Steps

  1. Install Server using Docker or raspberry Pi zero or Manual Installation
  2. create Device Handler
  3. create smartapp
  4. Configure smartthings application on android or apple
  5. Get "Smartthings Application Id" and "Smartthings Application Secret"
  6. Configure Server
  7. Add Smartthings devices

Server Docker Installation

  • Install docker
sudo su
curl -sSL https://get.docker.com | bash
usermod -aG docker $USER
  • Supported Architectures: amd64,x86-64,arm64,ppc64le,arm/v7
docker -d run --name=smartthings-phevctl  -p 8080:8080 -p 8099:8099 -p 8098:8098 --restart=always vassio/smartthings-phevctl

or

echo "{}">/opt/remote-ctrl-gsm.json
docker -d run --name=smartthings-phevctl  -p 8080:8080 -p 8099:8099 -p 8098:8098 -v /opt/config/remote-ctrl-gsm.json:/opt/remote-ctrl-gsm.json --restart=always vassio/smartthings-phevctl

Raspberry Pi Zero installation

  1. Download Raspberry Pi OS Lite
  2. write the Raspberry Pi OS image to the SD card using balenaEtcher or analog
  3. write empty "ssh" and wpa_supplicant.conf files on sdcard (boot)
  4. install phevctl, node(>=12) and smartthings-phevctl
sudo su
apt-get upgrade -y && apt-get -y install build-essential cmake git python3-distutils
mkdir /opt/phevctl
cd /opt/phevctl && git clone https://github.com/papawattu/msg-core
cd /opt/phevctl &&  git clone https://github.com/vzakharchenko/phevcore.git
cd /opt/phevctl && git clone https://github.com/DaveGamble/cJSON.git
cd /opt/phevctl && git clone https://github.com/vzakharchenko/phevctl
cd /opt/phevctl/cJSON && mkdir build && cd build && cmake .. && make && make install
cd /opt/phevctl/msg-core && mkdir build && cd build && cmake .. && make && make install
cd /opt/phevctl/phevcore && mkdir build && cd build && cmake .. && make && make install
cd /opt/phevctl/phevctl && mkdir -p build && cd build && cmake .. && make
rm -f /usr/bin/phevctl
ln -sf /opt/phevctl/phevctl/build/phevctl /usr/bin/phevctl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
source ~/.bashrc
nvm install --lts
# You can go drink coffee)
npm i pm2 -g
env PATH=$PATH:/usr/bin pm2 startup systemd -u root --hp ${HOME}
pm2 startup -u root
npm i smartthings-phevctl -g
pm2 start `npm root -g`/smartthings-phevctl/smartthings-phevctl.js
pm2 save

Server Manual Installation

sudo su
apt-get upgrade -y && apt-get -y install build-essential cmake git
mkdir /opt/phevctl
cd /opt/phevctl && git clone https://github.com/papawattu/msg-core
cd /opt/phevctl &&  git clone https://github.com/vzakharchenko/phevcore.git
cd /opt/phevctl && git clone https://github.com/DaveGamble/cJSON.git
cd /opt/phevctl && git clone https://github.com/vzakharchenko/phevctl
cd /opt/phevctl/cJSON && mkdir build && cd build && cmake .. && make && make install
cd /opt/phevctl/msg-core && mkdir build && cd build && cmake .. && make && make install
cd /opt/phevctl/phevcore && mkdir build && cd build && cmake .. && make && make install
cd /opt/phevctl/phevctl && mkdir -p build && cd build && cmake .. && make
rm -f /usr/bin/phevctl
wget -qO- https://getpm2.com/install.sh | bash
env PATH=$PATH:/usr/bin pm2 startup systemd -u ${currentUser} --hp ${HOME}
npm i smartthings-phevctl -g
pm2 start `npm root -g`/smartthings-phevctl/smartthings-phevctl.js
pm2 save

Smartthings installation

Create Custom DHT

  1. open https://graph.api.smartthings.com/
  2. open your location/ or create a new one npm.io
  3. open "My Device Handler" and "create New Device Handler"npm.io
  4. select from code and add Outlander PHEV Action.groovy(./dht/Outlander PHEV Action.groovy), Outlander PHEV Battery.groovy(./dht/Outlander PHEV Battery.groovy), Outlander PHEV Thermostat.groovy(./dht/Outlander PHEV Thermostat.groovy) and Outlander PHEV Doors.groovy(./dht/Outlander PHEV Doors.groovy) npm.io
  5. click save

Create SmartApp

  1. open https://graph.api.smartthings.com/
  2. open your location npm.io
  3. create a new SmartApp npm.io
  4. select from code and add remote-ctrl-gsm.groovy npm.io
  5. open smartapp application and click "App Settings" npm.io npm.io
  6. enable "OAuth" npm.io
  7. Save and publish application npm.io

Configure Smartthings application

  1. open smartthings application in Phone Android or Apple
  2. select location npm.io
  3. add SmartApp npm.io
  4. add "remote-ctrl-gsm" npm.io
  5. set IP and port of server and click save npm.io

Get "Smartthings Application Id" and "Smartthings Application Secret"

  1. open https://graph.api.smartthings.com/
  2. select smartapps in your location npm.io
  3. select your smartapp npm.io
  4. get "Smartthings Application Id" and "Smartthings Application Secret" from the page npm.io

Configure Server

  1. open server http://<IP>:8080
  2. default login/password: admin/admin
  3. configure "Smartthings Application Id", "Smartthings Application Secret" and mac address npm.io
  4. click save

Add a new Smartthings device

  1. select devices->add Device npm.io
  2. Device will be appear om Smartthings App

Local Network Installation(under NAT)

Run without cloud and without Smartthings Hub

Authentication

Local authentication (default)

default login/password: admin/admin

change password for user

npm.io

add a new User

npm.io

Keycloak authentication

npm.io

restart Application

Keycloak authorization

npm.io restart Application

Thermostat operation state

npm.io npm.io npm.io

Push Notification

npm.io npm.io npm.io

EVSE Electric Vehicle (EV) Charging Stations

Scripts for energy star charging stations

npm.io

  • Slow charging(slowCharge.sh)
curl --header "application/x-www-form-urlencoded"   --request POST   --data 'cur_set=7&charge_start=1&adaptive_mode_status=1&adaptive_mode_voltage=220&timer=0&timer_start=0'   http://192.168.4.1/ajax
  • Normal charging(fastCharge.sh)
curl --header "application/x-www-form-urlencoded"   --request POST   --data 'cur_set=16&charge_start=1&adaptive_mode_status=0&adaptive_mode_voltage=220&timer=0&timer_start=0'   http://192.168.4.1/ajax
  • Disable charging(disableCharge.sh)
curl --header "application/x-www-form-urlencoded"   --request POST   --data 'cur_set=7&charge_start=0&adaptive_mode_status=1&adaptive_mode_voltage=220&timer=0&timer_start=0'   http://192.168.4.1/ajax
  • Mikrotik Configuration
/interface wireless security-profiles
add authentication-types=wpa2-psk group-ciphers=tkip mode=dynamic-keys name=EVSE supplicant-identity=MikroTik unicast-ciphers=tkip wpa-pre-shared-key=<EVSE_PASSWORD> wpa2-pre-shared-key=<EVSE_PASSWORD>
/interface wireless
set [ find default-name=wlan1 ] disabled=no frequency=2447 mode=station-pseudobridge name=EVSE_CHARGER security-profile=EVSE ssid=<EVSE_SSID>

/interface bridge
add dhcp-snooping=yes fast-forward=no igmp-snooping=yes name=bridgeEVSE
/interface bridge port
add bridge=bridgeEVSE broadcast-flood=no edge=no-discover interface=EVSE_CHARGER multicast-router=disabled trusted=yes unknown-multicast-flood=no unknown-unicast-flood=no
/interface bridge settings
set allow-fast-path=no

/ip dhcp-client
add add-default-route=no disabled=no interface=bridgeCar use-peer-dns=no use-peer-ntp=no
add add-default-route=no disabled=no interface=bridgeEVSE use-peer-dns=no use-peer-ntp=no

add authorization for EVSE Charging

  • start proxy application
npm i pm2 -g
env PATH=$PATH:/usr/bin pm2 startup systemd -u root --hp ${HOME}
pm2 startup -u root
npm i smartthings-phevctl -g
pm2 start `npm root -g`/smartthings-phevctl/evse-proxy.js
pm2 save
  • configure evse-proxy
nano ~/.remote-ctrl-gsm/config.json
{
 "evseServer": {
  "/": "https://192.168.4.1",
  "style.css": "https://192.168.4.1/style.css",
  "es.js": "https://192.168.4.1/es.js",
  "ajax": "https://192.168.4.1/ajax"
 },
 "users": [
  {
   "id": "0",
   "username": "admin",
   "password": "admin"
  }
 ],
 "port": 8011,
 "role":"<KEYCLOAK_REALM>:<KEYCLOAK_CLIENT>"
}
  • Keycloak authorization example keycloak.json:
{
  "realm": "<REALM>",
  "auth-server-url": "https://<KEYCLOAK_URL>/auth/",
  "ssl-required": "external",
  "resource": "<CLIENT_ID>",
  "credentials": {
    "secret": "<CLIENT_SECRET>"
  },
  "confidential-port": 0
}

Keycloak security role:

{
 "evseServer": {
  ...
 }
 ],
 "role":"<KEYCLOAK_REALM>:<KEYCLOAK_CLIENT>"
}
1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.9.0

2 years ago

1.8.9

2 years ago

1.8.10

2 years ago

1.8.8

2 years ago

1.8.11

2 years ago

1.8.7

2 years ago

1.8.6

2 years ago

1.8.5

2 years ago

1.8.4

2 years ago

1.8.3

2 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.7.0

2 years ago

1.6.0

3 years ago

1.5.9

3 years ago

1.5.8

3 years ago

1.5.10

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.4.2

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.4.0

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.13

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.10

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago