@samip537 an easy way is to add or replace the mqtt discovery messages in the code. instead of ‘switch’, use ‘light’
to create both a switch and light entity, you can replace this code…
client.publish((home_assistant_mqtt_prefix + "/switch/" + deviceName + "/config").c_str(), ("{\"~\":\"" + (botTopic + deviceName) + "\", " +
+ "\"name\":\"" + deviceName + " Switch\"," +
+ "\"device\": {\"identifiers\":[\"switchbot_" + deviceMac + "\"],\"manufacturer\":\"" + manufacturer + "\",\"model\":\"" + botModel + "\",\"name\": \"" + deviceName + "\" }," +
+ "\"avty_t\": \"" + lastWill + "\"," +
+ "\"uniq_id\":\"switchbot_" + deviceMac + "\", " +
+ "\"stat_t\":\"~/state\", " +
+ "\"opt\":" + optiString + ", " +
+ "\"cmd_t\": \"~/set\" }").c_str(), true);
with this…
client.publish((home_assistant_mqtt_prefix + "/switch/" + deviceName + "/config").c_str(), ("{\"~\":\"" + (botTopic + deviceName) + "\", " +
+ "\"name\":\"" + deviceName + " Switch\"," +
+ "\"device\": {\"identifiers\":[\"switchbot_" + deviceMac + "\"],\"manufacturer\":\"" + manufacturer + "\",\"model\":\"" + botModel + "\",\"name\": \"" + deviceName + "\" }," +
+ "\"avty_t\": \"" + lastWill + "\"," +
+ "\"uniq_id\":\"switchbot_" + deviceMac + "\", " +
+ "\"stat_t\":\"~/state\", " +
+ "\"opt\":" + optiString + ", " +
+ "\"cmd_t\": \"~/set\" }").c_str(), true);
client.publish((home_assistant_mqtt_prefix + "/light/" + deviceName + "/config").c_str(), ("{\"~\":\"" + (botTopic + deviceName) + "\", " +
+ "\"name\":\"" + deviceName + " Light\"," +
+ "\"device\": {\"identifiers\":[\"switchbot_" + deviceMac + "\"],\"manufacturer\":\"" + manufacturer + "\",\"model\":\"" + botModel + "\",\"name\": \"" + deviceName + "\" }," +
+ "\"avty_t\": \"" + lastWill + "\"," +
+ "\"uniq_id\":\"switchbot_" + deviceMac + "_light\"," +
+ "\"stat_t\":\"~/state\", " +
+ "\"opt\":" + optiString + ", " +
+ "\"cmd_t\": \"~/set\" }").c_str(), true);
you can remove the switch entity is all your bot devices are lights