Since a couple people asked for some features I released a v5.1
You can now simulate ON/OFF for bots in PRESS mode using these 3 lists in the code
/*** Bots in PRESS mode to simulate ON/OFF - ESP32 will try to keep track of the ON/OFF state of your device while in PRESS mode***/
// Add bots while in PRESS mode that will simulate ON/OFF. Default state will be used if no MQTT retained on state topic
// false = default state = OFF
// true = default state = ON
static std::map<std::string, bool> botsSimulateONOFFinPRESSmode = {
/*{ "switchbotone", false },
{ "switchbottwo", false }*/
};
//Add bots OFF hold time for simulated ON/OFF, if not in list, the current hold value will be used. Device must be in botsSimulateONOFFinPRESSmode list
static std::map<std::string, int> botsSimulatedOFFHoldTimes = {
/*{ "switchbotone", 3 },
{ "switchbottwo", 10 }*/
};
//Add bots ON hold time for simulated ON/OFF, if not in list, the current hold value will be used. Device must be in botsSimulateONOFFinPRESSmode list
static std::map<std::string, int> botsSimulatedONHoldTimes = {
/*{ "switchbotone", 15 },
{ "switchbottwo", 1}*/
};
/********************************************/
If your deviceās ON/OFF press action hold time would be the same for ON/OFF, simply include the devices in then botsSimulateONOFFinPRESSmode list
If you deviceās ON/OFF uses a different hold time for ON vs OFF, also add your devices to botsSimulatedOFFHoldTimes and/or botsSimulatedONHoldTimes. So when On is pressed it will hold for X seconds, when Off is pressed it will hold for Y seconds
If the state is incorrect, or you want to control the state of the device, you can manually call the set function for āSTATEOFFā or āSTATEONā to correct the state
when the ESP32 boots, it will attempt to grab the last retained state message to set the bot state in ESP32
Note: If you physically push the button (not using switchbot), the ON/OFF state will be wrong. You will need to call set āSTATEOFFā or āSTATEONā to correct the state