https://github.com/donkaos501/esp32-switch-controller
It allows an ESP32 microcontroller to send button press events to the Switch Controller, which then triggers actions such as turning on a light via Home Assistant.
https://github.com/donkaos501/esp32-switch-controller
arduino esp32 esp32-arduino
Last synced: about 1 month ago
JSON representation
It allows an ESP32 microcontroller to send button press events to the Switch Controller, which then triggers actions such as turning on a light via Home Assistant.
- Host: GitHub
- URL: https://github.com/donkaos501/esp32-switch-controller
- Owner: Donkaos501
- License: apache-2.0
- Created: 2025-03-14T16:36:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-14T16:50:24.000Z (over 1 year ago)
- Last Synced: 2025-03-14T17:37:51.694Z (over 1 year ago)
- Topics: arduino, esp32, esp32-arduino
- Language: C++
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ESP32 Switches
This project is designed to work with the [Switch Controller App](https://github.com/Donkaos501/SwitchController).
It allows an **ESP32 microcontroller** to send button press events to the Switch Controller, which then triggers actions such as turning on a light via **Home Assistant**.
## Wiring Diagram

## Sending Requests from ESP32 to the Switch Controller App
The ESP32 can send HTTP POST requests to the **Switch Controller App** to trigger different switch actions.
```http
# Trigger switch 1 (short press)
POST http://localhost:8080/esp
Content-Type: application/json
{
"uuid": "bd4a6037-0864-4b0e-80e1-8d1c87bf9aa0",
"friendly_name": "Küche hinten",
"ip": "192.168.101.181",
"action": "switch_1_short"
}
# Trigger switch 1 (long press)
POST http://localhost:8080/esp
Content-Type: application/json
{
"uuid": "bd4a6037-0864-4b0e-80e1-8d1c87bf9aa0",
"friendly_name": "Küche hinten",
"ip": "192.168.101.181",
"action": "switch_1_long"
}
# Trigger switch 2 (short press)
POST http://localhost:8080/esp
Content-Type: application/json
{
"uuid": "bd4a6037-0864-4b0e-80e1-8d1c87bf9aa0",
"friendly_name": "Küche hinten",
"ip": "192.168.101.181",
"action": "switch_2_short"
}
# Trigger switch 2 (long press)
POST http://localhost:8080/esp
Content-Type: application/json
{
"uuid": "bd4a6037-0864-4b0e-80e1-8d1c87bf9aa0",
"friendly_name": "Küche hinten",
"ip": "192.168.101.181",
"action": "switch_2_long"
}
```
## How It Works
1. **Button Press on ESP32** → The ESP32 detects the button press event.
2. **Sends an HTTP Request** → The ESP32 sends a request to the **Switch Controller App**.
3. **Action Execution** → The Switch Controller App triggers the appropriate action (e.g., turning on a light in **Home Assistant**).
---
This setup allows for easy integration with **smart home automation**, making it a great way to trigger **Home Assistant scenes, automations, or direct device control** using physical buttons.