Smart Room Controller
As a controller of A/C, controller.py create a multi-thread socket server to receive control command.
Main API Server will create a socket connection to controller and send payload for controlling A/C.
In our case, controller is running on a Raspberry Pi Zero W.
Socket transfer data type in bytes, the data structure above need to transfer (or encode) to bytes.
Available command set in config.py
- cool mode:
16C
~30C
- (Room 602's AC cannot be set to 30 degrees, only 16 to 29)
- fan mode:
fan
- turn off:
off
Note: AC acts according to the command, so there is no power-on command.
- IR Config Files
- AC IR remote record
JSON string containing Python Dict object
- token: controller token
- 32 bytes random number in hex
- eg.
e8b4ac80acc520ae59686b1c3715281ede9b61c547407a9c90371f1cb5dfeac2
- command: A/C command
- set temperature or turn off
- eg.
25C
,off
{
"token": "TOKEN",
"command": "25C"
}
- python 3.7
- pipenv
- Installing Packages & Running
pipenv install --dev
pipvne run controller.py
- (Optional) Version freeze to generate
requirements.txt
pipenv lock --requirements > requirements.txt
- Test Connection Using
nc
$ nc [hostname] [port] <<< '{"token":"TOKEN","command":"25C"}'