1010
1111import paho .mqtt .client as mqtt
1212
13+ from inelsmqtt .utils .core import ProtocolHandlerMapper
14+
1315from .const import (
14- DEVICE_TYPE_DICT ,
1516 DISCOVERY_TIMEOUT_IN_SEC ,
1617 FRAGMENT_DEVICE_TYPE ,
1718 FRAGMENT_STATE ,
@@ -410,7 +411,7 @@ def __on_discover(
410411 topic = msg .topic .split ("/" )[2 :]
411412 topic = "/" .join (topic )
412413
413- if device_type in DEVICE_TYPE_DICT :
414+ if device_type in ProtocolHandlerMapper . DEVICE_TYPE_MAP :
414415 if action == "status" :
415416 self .__discovered [topic ] = msg .payload
416417 self .__last_values [msg .topic ] = msg .payload
@@ -430,6 +431,8 @@ def __on_discover(
430431 self .__last_values [msg .topic ] = copy .copy (msg .topic )
431432 self .__is_subscribed_list [msg .topic ] = True
432433 _LOGGER .info ("Device of type %s found [gw].\n " , device_type )
434+ elif device_type != "gw" :
435+ _LOGGER .error ("No handler found for device_type: %s" , device_type )
433436
434437 def __on_message (
435438 self ,
@@ -450,7 +453,7 @@ def __on_message(
450453
451454 message_type = message_parts [TOPIC_FRAGMENTS [FRAGMENT_STATE ]]
452455
453- if device_type in DEVICE_TYPE_DICT or device_type == "gw" :
456+ if device_type in ProtocolHandlerMapper . DEVICE_TYPE_MAP or device_type == "gw" :
454457 # keep last value
455458 self .__last_values [msg .topic ] = (
456459 copy .copy (self .__messages [msg .topic ]) if msg .topic in self .__messages else msg .payload
0 commit comments