Fix gateway color adjustment when prefix more than one subtopic
This commit is contained in:
+12
-8
@@ -131,19 +131,22 @@ class Mqtt:
|
|||||||
|
|
||||||
def _mqtt_process_message(self, client, userdata, msg):
|
def _mqtt_process_message(self, client, userdata, msg):
|
||||||
_LOGGER.info("Processing message in " + str(msg.topic) + ": " + str(msg.payload) + ".")
|
_LOGGER.info("Processing message in " + str(msg.topic) + ": " + str(msg.payload) + ".")
|
||||||
parts = msg.topic.split("/")
|
|
||||||
if len(parts) < 4:
|
# need to strip prefix to make parts assignment reliable
|
||||||
|
parts = msg.topic.replace(self.prefix+"/","").split("/")
|
||||||
|
partlen = len(parts)
|
||||||
|
if len(parts) < 3:
|
||||||
# should we return an error message ?
|
# should we return an error message ?
|
||||||
return
|
return
|
||||||
|
|
||||||
model = parts[1]
|
model = parts[0]
|
||||||
query_sid = parts[2] # sid or name part
|
query_sid = parts[1] # sid or name part
|
||||||
param = parts[3] # param part
|
param = parts[2] # param part
|
||||||
method = None
|
method = None
|
||||||
if len(parts) > 4:
|
if len(parts) > 3:
|
||||||
method = parts[4]
|
|
||||||
else:
|
|
||||||
method = parts[3]
|
method = parts[3]
|
||||||
|
else:
|
||||||
|
method = parts[2]
|
||||||
|
|
||||||
name = "" # we will find it next
|
name = "" # we will find it next
|
||||||
sid = query_sid
|
sid = query_sid
|
||||||
@@ -160,6 +163,7 @@ class Mqtt:
|
|||||||
sid = current_sid
|
sid = current_sid
|
||||||
name = sidname
|
name = sidname
|
||||||
isFound = True
|
isFound = True
|
||||||
|
_LOGGER.debug("Found " + sid + " = " + name)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(sidmodel + "-" + sidname + " is not " + model + "-" + query_sid + ".")
|
_LOGGER.debug(sidmodel + "-" + sidname + " is not " + model + "-" + query_sid + ".")
|
||||||
|
|||||||
Reference in New Issue
Block a user