RavenSystem / esp-homekit-devices

Advanced firmware to add native Apple HomeKit and custom configurations, compatible with any SoC based on ESP32, ESP32-S, ESP32-C and ESP8266 series. (Shelly, Sonoff, Electrodragon, Tuya...)
Other
2.7k stars 357 forks source link

Sonoff Basic - GPIO does not work #2163

Closed Przylepzwm closed 9 months ago

Przylepzwm commented 9 months ago

Homekit does not control GPIO Outputs for the built-in LED and relay. The built-in button does not change the state of the switch in homekit.

Detailed steps to reproduce it

-flesh fullhaaboot.bin using NEMUMCU FIRMWARE PROGRAMMER - success. -configure wifi network and install HAA - success -adding MEPLHAA Script configuration - success -adding the homekit accessory - success -Relay control - does not work (only changes state in homekit)

As a test, I used a simple project created in the Arduino IDE to check the hardware - everything works (LED and relay).

MEPLHAA Script {"c":{"io":[[[12,13],2],[[0],6]],"l":13,"b":[[0,5]]},"a":[{"0":{"r":[[12]]},"1":{"r":[[12,1]]},"b":[[0]]}]} Used device

HAA version 12.9.1 iOS/iPadOS version 17.1.1 Logs

Verifying Result OK *** FINISHING

  • HAAMAIN 12.9.1 installed *** REBOOTING rm match del if0 usl sul 0 0

ets Jan 8 2013,rst cause:1, boot mode:(3,6)

load 0x40100000, len 2292, room 16 tail 4 chksum 0x57 load 0x3ffe8000, len 772, room 4 tail 0 chksum 0x0b csum 0x0b

rBoot v1.4.0 - richardaburton@gmail.com Flash Size: 8 Mbit Flash Mode: unknown Flash Speed: 26.7 MHz rBoot Option: Big flash rBoot Option: RTC data

Booting rom 0. pp_task_hdl : 3ffefd98, prio:14, stack:512 pm_task_hdl : 3ffef650, prio:1, st

Screen-shots or videos showing issue

xrust83 commented 9 months ago

Read WIKI, invert "i": in "c":{...}

Przylepzwm commented 9 months ago

Thank you for the suggestion. According to WIKI for sonoff, Invert LED should be "1"- and this is the default value. Do you suggest changing to 0?

I will add that the JSONs I tested (there were several of them) come from WIKI device database or HAA Json Configurator

It looks as all GPIO does not want to work with this software. Earlier there was Ravencore v1 (for thermostat) and it was fine. Using another simple project I am able to control GPIO out on pin 12 and 13 as well.

xrust83 commented 9 months ago

Yes. Invert from default. Default is invert. Set "i":0

Przylepzwm commented 9 months ago

Relay and build-in button works! Thank you so much I have one more question: right now the status of the LED is always On. I tried to add output config to make the LED ON only as relay is controlled:

{"c":{"io":[[[12,13],2],[[0],6]],"l":13,"b":[[0,5]],"i":0},"a":[{"0":{"r":[[12],**[13]**]},"1":{"r":[[12,1],**[13,1]**]},"b":[[0]]}]}

But still the diode is always On. Can you take a look at what I am doing wrong? Thx!

xrust83 commented 9 months ago

gpio13 in Sonoff basic uses as notification LED. if you need to make it status on/off then take it from sonfig "c": there is another option. diode 2-contact red/green. connect it to gpio2 or gpio14 from the boards version.

https://tasmota.github.io/docs/devices/Sonoff-Basic/#serial-flashing

simultaneous use as a diode for errors and for relay status is not possible, this may cause interruptions in operation and code

{"c":{"io":[[[12,13],2],[[0],6]],"b":[[0,5]]},"a":[{"0":{"r":[[12],[13]]},"1":{"r":[[12,1],[13,1]]},"b":[[0]]}]}
Przylepzwm commented 9 months ago

Thank you very much for the explanation and best regards.

Topic to close @RavenSystem thank you for your project