albertogeniola / MerossIot

Async Python library for controlling Meross devices
https://albertogeniola.github.io/MerossIot/
MIT License
478 stars 88 forks source link

Is the local.py example correct ? #260

Closed joyrider3774 closed 1 year ago

joyrider3774 commented 1 year ago

Hi,

I've tested the local.py example by addinf this same line to my script i was already using

manager.transport_mode = TransportMode.LAN_HTTP_FIRST

but i noticed it still seemed to get MQTT responses so i got suspicious and enabled debug logging and i noticed i never saw any of these debug loggings from here

https://github.com/albertogeniola/MerossIot/blob/0.4.X.X/meross_iot/manager.py#L796

So i looked further and only when changed the line to this

manager.default_transport_mode = TransportMode.LAN_HTTP_FIRST

I started to see those messages about attempting and doing HTTP requests appear so i'm guessing the example script might have a fault or something else is not going correct.

https://github.com/albertogeniola/MerossIot/blob/0.4.X.X/examples/local.py#L18

the newly added property in that commit actually also is default_transport_mode so i'm guessing the local.py example contains a typo.

Could you verify that please as by default people won't notice its still not doing http requests if they only look at the examples as the messages about http only appear with loglevel debug

albertogeniola commented 1 year ago

Hi @joyrider3774 , great spot. The library itself is working, the problem was in the local.py example. In particular, the following line:

manager.transport_mode = TransportMode.LAN_HTTP_FIRST

shou.d be changed to:

manager.default_transport_mode = TransportMode.LAN_HTTP_FIRST

Thanks a lot for having reported that!