Developed by M. Aji Perdana 
Hey, so this is a microservice application designed for home automation with the Internet of Things (IoT). Users can register devices, control their operations, log them, and integrate them with global cloud applications. It's pretty cool because it allows comprehensive data logging from local servers through this worker.
We developed the worker using Go and SQLite, which were chosen for their efficiency. Go offers high performance with minimal resource consumption, which makes it suitable for distributed systems and high-throughput services. SQLite, being a lightweight database without the need for a separate server, ensures optimal data access speed and easy deployment without any additional complexity. This combination makes workers more responsive, lightweight, and easy to manage.
- Clone this repository.
- Install Golang
- Install RabbitMQ
- Enable RabbitMQ Management Plugin and RabbitMQ MQTT Plugin.
- Create database file for this worker in your local machine, the database using SQLite in this project
- COPY .env.example to .env
- Fill in the .env file.
- If you want to run the worker with Hot Reloading, please install air first, and generate the .air.toml file with
air initcommand - To build the worker, run
go build ./src/main.gocommand.
- Register, Control Device, update and delete device. This feature is can be used from local and cloud publisher rabbitmq.
- Create Rules for control device SENSOR and ACTUATOR. Rules pattern have max 8 pattern with binary number combinations.
- This worker have API endpoint for get all device, get detail device for checking device status, and control device from local server, check this API Documentation.
- This worker integrate with cloud publisher rabbitmq, so you can control device from cloud publisher client (Website).
- Cron job for get all log and log aktuator every 10 minutes and publish to RabbitMQ cloud.
To manage rules, the client needs to publish a payload to the local rabbitMQ with a routingKey Rules on the amq.direct exchange. Here's the JSON format to use:
{
"input_guid": "68ea3da6-c04a-41ce-815e-a18392921f8b",
"output_guid": [
"e7dd51bd-32cf-4ca2-9bed-1efa36e21e38",
"04e89950-271d-48e2-9111-5d1b04a75e71"
]
}- input_guid is a unique GUID that represents the IoT SENSOR device.
- output_guid is an array of unique GUID that represents the IoT ACTUATOR device.
If the given length of the actuators is 2, then the possible combinations are:
| Sensor | Actuator 1 | Actuator 2 |
|---|---|---|
| 00 | 1 | 1 |
| 01 | 1 | 0 |
| 10 | 0 | 1 |
| 11 | 0 | 0 |
Best regards, M. Aji Perdana

