Here is the config for ESPEasy.
I am using ESPEasy v2.0.0-dev12, which is current the latest. I am using the TEST version of the firmware as it is needed for rotary encoder support - ESPEasy_v2.0.0-dev12_test_1024.bin
Unfortunately ESPEasy does not have a way to export config in ASCII - it only has a binary export format - so I will post a bunch of pictures of all the settings.
If you already have ESPEasy up and running, you can use config.dat and rules1.txt to enter these settings automatically. I cannot post them here (file type constraints) but PM me if you want them…
Note that I discovered that some recent Sonoff devices need to be flashed using DOUT mode due to a change in flash chip - this is a nice guide to use Espressif own tool to achieve this:
https://www.letscontrolit.com/forum/viewtopic.php?f=5&t=3386&p=18240#p18240
ESPEasy Config
#1 Config tab
Set the name of the device. This will be used as the 1st token in the MQTT topics:
#2 Controllers Tab
Here you want to add a OpenHab MQTT controller:
Configure the controller with your MQTT server details:
The %% placeholders are:
%sysname% - the name configured in the config tab
%taskname% - the name of the device that generated the mqtt message (see device tab)
%valname% - the name of the value that the device generates
#3 Controllers tab:
Here you can set two things:
- To use the sonoff LED (GPIO 13) as the WiFi activity LED - useful
- The default state of the relay (GPIO12) on boot - I left as-is and it defaults to ON - i.e. any load will be ON after ESPEasy fully boots.
#4 Devices tab
This is where all the buttons, rotary encoder etc are configured.
I also configured devices to periodically send system parameters e.g. WiFi signal strength
This device is for the Sonoff PCB mounted switch:
This is for the relay:
This is for the rotary encoder:
NB GPIO1 & 3 are the UART tx/rx so the 5 pin header of the Sonoff can be used.
I use 4 pulses per cycle - which counts from 0 to 64 in increments of 4 = 16 steps.
In HA I multiply this to scale to 0 to 255, which is the input range of light brightness.
This is for the rotary encoder push button:
The momentary switch is on GPIO14 - the “spare” GPIO on the sonoff header.
The next four are sending the following system stats every 300 seconds (5 mins):
- Free RAM (bytes)
- WiFi RSSI (dBM)
- System load
- Uptime (minutes)
#5 Rules Tab
I have a single rule currently defined, which switches the relay based on the pcb switch being pushed - i.e. to mimic Sonoff OOB behaviour:
I need to define other rules:
- Send IP address on start up (supported by my HA config)
- Detect a long press of the rotary encoder switch to toggle the relay
#6 Tools tab --> Advanced Settings
Set MQTT retain for retention of last value
Also set the delay to 0ms for as low latency as possible on the dimmer events
I set ntp, but this is optional
Also I disabled the serial port because I am reusing GPIO 1 and 3, but it does not seem to matter if you do this. I recommend to do it as best practice.