Hi All, Does anybody know how I can pass GetCBusByKW a longer list of args other than just 2 (which seems to work)..? I have a function which pokes the correct data into MQTT auto-discover - works a treat by the way!! As I augment my function to cater for different types of device, I've hit a wall. Code: function mqttdiscover() cbusdump = GetCBusByKW({"MQTT_Light","MQTT_Window","MQTT_Exhaust","MQTT_Blind"}, 'or') -- THIS DOES NOT WORK BEYOND 2 ARGS -- log("MQTT cover/window/exhaust - starting the auto-discovery build") for key1, object in pairs(cbusdump) do objectname = object["name"] objectnet = object["address"][1] objectapp = object["address"][2] objectgroupid = object["address"][3] for key2, keyword in pairs(object["keywords"]) do if keyword == "MQTT_Light" then if debuglog then log("Discovered MQTT_Light: "..objectgroupid) end objectid = "cbus_mqtt_light_" .. objectnet .. "_" .. objectapp .. "_" .. objectgroupid payload = { ["name"] = objectname, ["unique_id"] = objectid, ["cmd_t"] = "cbus/write/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/switch", ["stat_t"] = "cbus/read/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/state", ["bri_stat_t"] = "cbus/read/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/level", ["bri_cmd_t"] = "cbus/write/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/ramp", ["pl_on"] = "ON", ["pl_off"] = "OFF", ["on_cmd_type"] = "brightness" } haintegrationtype = "light" end if keyword == "MQTT_Window" then if debuglog then log("Discovered MQTT_Window: "..objectgroupid) end objectid = "cbus_mqtt_window_" .. objectnet .. "_" .. objectapp .. "_" .. objectgroupid payload = { ["name"] = objectname, ["unique_id"] = objectid, ["dev_cla"] = "window", ["position_topic"] = "cbus/read/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/level", ["set_pos_t"] = "cbus/write/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/ramp", ["pos_open"] = 255, ["pos_clsd"] = 0, ["availability"] = { ["topic"] = "cbus/read/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/availability" } } haintegrationtype = "cover" end if keyword == "MQTT_Exhaust" then if debuglog then log("Discovered MQTT_Exhaust: "..objectgroupid) end objectid = "cbus_mqtt_exhaust_" .. objectnet .. "_" .. objectapp .. "_" .. objectgroupid payload = { ["name"] = objectname, ["unique_id"] = objectid, ["cmd_t"] = "cbus/write/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/switch", ["stat_t"] = "cbus/read/" .. objectnet .. "/" .. objectapp .. "/" .. objectgroupid .. "/state", ["pl_on"] = "ON", ["pl_off"] = "OFF" } haintegrationtype = "fan" end if keyword == "MQTT_Blind" then -- do something end end local jsonpayload = json.encode( payload ) local publishtopic = mqtt_autodiscover_topic .. "/" .. haintegrationtype .. "/" .. objectid .. "/config" if debuglog then log("Complete topic and JSON encoded BLOB for group "..objectgroupid, publishtopic, jsonpayload ) end client:publish(publishtopic, jsonpayload, 1, true) end end Any ideas?!!? Cheers, Tim
i did some testing, i can receive more than 2 args in the GetCBusByKW() function no problem cbusdump = GetCBusByKW({"MQTT_Window", "Fan_Speed", "Bathroom","MQTT_Blind", "Kitchen" }, 'or') log(cbusdump) I dont have any tags called MQTT_Window or MQTT_Blind in my project, but i did receive all other objects with the other valid tags in the cbusdump table. maybe add some logging, to see when the breakdown happens, also objectname = object["name"] dosnt always exist (well not for me anyway) eg for user parameter and measurement application the value "name" in the table is nil you could try commenting this out and see if anything changes? you could also add some checking eg if objectname then -- continue on as there is a value that is not nil inside variable objectname end