A Home automation sever running on Raspberry Pi 3B with Raspberry Pi OS Lite
- http://{hostname}
- in production mode, there will be 2 ports being listened. 80 for http redirect and 443 for https
- using Certbot to generate certificates, need to renew periodically
- check my running site here: homeautomationbox.com
- What is Alexa?
- Deployed as a privite skill on Alexa under name: Decor light. Access skill here
- utterances:
- turn on/off decor light
- decor light on/off
- decor light switch
- help
- what is this
- what does this do
- ...
- utterances:
- installation:
npm i
- start dev db: use dynamodb-local
- docker installed locally
- cd to
./db
and rundocker-compose up -d
. It will download the docker image if not exists and start the container in the background
- start server and UI dev:
npm run dev
- dev UI: http://localhost:3000
- default login: admin/password (inilized in db setup)
- start server:
npm run start
- DB: AWS DynamoDB (us-east-1)
- create service so can boot with OS https://stackoverflow.com/a/29042953 (Will change once containerized)
- sample service file under
.utils/homeAutomation.service
. Please read thru it for it has token/secret needs to be generated
- sample service file under
- to use aws dynamo db, have the credentials under
~/.aws/credentials
.- to generate users table in the initial load run production with env var:
INIT_DB=true
- to generate users table in the initial load run production with env var:
- Technology:
- REST:
- body:
{ "username": "username", "password": "password }
- login: POST
{hostname}/auth/login
- signup: POST
{hostname}/auth/signup
(TBD) need to improve
- body:
-
preqeq: Install and setup (permission) uhubctl https://github.com/mvp/uhubctl
-
symlink the uhubctl to
/usr/local/bin
so the child_process can accessln -s /usr/sbin/uhubctl /usr/local/bin/uhubctl
- status: GET
{hostname}/api/v1/usbSwitch/status
- turn on/off: GET
{hostname}/api/v1/usbSwitch/on
/ GET{hostname}/api/v1/usbSwitch/off
- status: GET
-
prereq: WOL with magic packet must be enabled on the device prior using this feature. For Windows check here
-
trigger on: POST
{hostname}/api/v1/windowsSwitch/toggle
// body optional. it will override the one defined in env variable when provided { "targetMacAddress": "1A:2B:3C:4D:5E:6F" }
-