https://github.com/pilotak/mqtt-relay
Universal MQTT wifi relay
https://github.com/pilotak/mqtt-relay
arduino dht22 ds18b20 esp32 esp8266 home-automation homeassistant mqtt relay-board sonoff temperature-sensor
Last synced: about 1 year ago
JSON representation
Universal MQTT wifi relay
- Host: GitHub
- URL: https://github.com/pilotak/mqtt-relay
- Owner: pilotak
- License: gpl-3.0
- Created: 2017-05-31T15:07:49.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-02T21:19:27.000Z (almost 9 years ago)
- Last Synced: 2025-03-28T03:41:20.910Z (about 1 year ago)
- Topics: arduino, dht22, ds18b20, esp32, esp8266, home-automation, homeassistant, mqtt, relay-board, sonoff, temperature-sensor
- Language: C++
- Homepage:
- Size: 21.5 KB
- Stars: 7
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MQTT relay
Yet another custom code to control Sonoff and other custom relay boards built around ESP8266 and ESP32.
The main goals are:
- Universal for Sonoff and other custom maed relay boards with ESP8266 and ESP32
- All setting is in one file so you have one file for each device but with completely different behaviour
- Button reading is interrupt based debounce, so you really don't miss a click even with delay used somewhere in code
- Button has a short press and long press
- You can define how many relays it has, also what is ON state wheter ```LOW``` or ```HIGH```
- Different modes state LED indication
- Remember last state during restart
- Clearly MQTT controlled, ready to be controlled by Home Automation server, like [HomeAssistant](https://home-assistant.io/)
In order to compile, you need to install following library
* PubSubClient (Imroy version) https://github.com/Imroy/pubsubclient
Below are examples of HomeAssistant configuration
## Control relay
```yaml
switch:
- platform: mqtt
name: "sonoff_switch"
command_topic: "sonoff/relay0"
state_topic: "sonoff/relay0/state"
payload_on: 'ON'
payload_off: 'OFF'
optimistic: false
qos: 1
```
## Temperature with couple of DS18B20
```yaml
sensor:
- platform: mqtt
state_topic: "sonoff/temp0"
name: "Tepmerature 1"
unit_of_measurement: "°C"
- platform: mqtt
state_topic: "sonoff/temp1"
name: "Tepmerature 2"
unit_of_measurement: "°C"
```
## Temperature and humidity with DHT22/DHT11
```yaml
sensor:
- platform: mqtt
state_topic: "sonoff/temp"
name: "Tepmerature"
unit_of_measurement: "°C"
- platform: mqtt
state_topic: "sonoff/humidity"
name: "Humidity"
unit_of_measurement: "%"
```