letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.27k stars 2.21k forks source link

Weird switch state (state value 4 instead of 1 or 0) #3491

Open carefulcomputer opened 3 years ago

carefulcomputer commented 3 years ago

Using build ESP_Easy_mega_20210114_normal_ESP8266_4M1M , mega-20210114_cdc8a1a, ESP82xx Core 2843a5ac, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support on a D1 Mini clone.

i have connected a touch sensor board TTP223 to GPIO 4 (D2). Enabled Internal Pullup resistor in device config. This GPIO is configured as a switch. It configured to sends a MQTT message (using opehab mqtt controller setting) on state change.

Since it is configured as a switch it should only return 1 or 0. However randomly (not able to explain why and when), it returns payload as 4. Why would payload be 4 instead of 1 or 0 ?

TD-er commented 3 years ago

There are other states possible as well, like long press, double click, etc. Have to check the source to get a list for your.

TD-er commented 3 years ago

I think this is the correct explanation of your return values: https://github.com/letscontrolit/ESPEasy/blob/e25f0d9994677bccb04e704f9ab10aefb567dfa9/src/_P001_Switch.ino#L395-L408

Maybe @giig1967g can shed some more light on this ( documentation ;) )

carefulcomputer commented 3 years ago

Don't see 4 in the code ?