Disassembly to flash the module is not trivial, please follow online tutorials. Flashing with a 3.3V programmer seems to work, even though the low-voltage part of the module operates with 5V.
The hardware button switches socket power by a single press and USB power by a double press.
If inversion is desired, execute command
Be aware that the HLW8032 power measurement component reports invalid readings for values lower than 5W.
To discard low values and report 0W instead, execute command
You might wish to keep USB power active at all times.
Check out the command
ButtonRetain 1 for MQTT based retention.
Furthermore, the red LED to indicate the power status of the module will be illuminated as long as any of the two relays are active.
To ignore USB power and indicate socket power state only, execute command
Important: it is possible that your device will enter a bootloop due to a conflict with UART/serial logging. Fix this using: SerialLog 0