Skip to content

Microservices using rabbitMQ message broker for controll and logging IOT device

Notifications You must be signed in to change notification settings

ajiaja38/Home-Automation-Microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HIOTO LOCAL WORKER 🚀

Developed by M. Aji Perdana GitHub


What is this worker ?

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.


How to use this worker ?

  1. Clone this repository.
  2. Install Golang Go
  3. Install RabbitMQ RabbitMQ
  4. Enable RabbitMQ Management Plugin and RabbitMQ MQTT Plugin.
  5. Create database file for this worker in your local machine, the database using SQLite in this project SQLite
  6. COPY .env.example to .env ENV
  7. Fill in the .env file.ENV
  8. If you want to run the worker with Hot Reloading, please install air first, and generate the .air.toml file with air init command
  9. To build the worker, run go build ./src/main.go command.

What's the features of this worker ?

  1. Register, Control Device, update and delete device. This feature is can be used from local and cloud publisher rabbitmq.
  2. Create Rules for control device SENSOR and ACTUATOR. Rules pattern have max 8 pattern with binary number combinations.
  3. 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.
  4. This worker integrate with cloud publisher rabbitmq, so you can control device from cloud publisher client (Website).
  5. Cron job for get all log and log aktuator every 10 minutes and publish to RabbitMQ cloud.

Design System

Registration Device Design System

Alt Registration


Control Device Design System

Alt Control


Rules Design System

Alt Rules 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"
  ]
}

Rules Explanation

  1. input_guid is a unique GUID that represents the IoT SENSOR device.
  2. output_guid is an array of unique GUID that represents the IoT ACTUATOR device.

Example of the result

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

About

Microservices using rabbitMQ message broker for controll and logging IOT device

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages