-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[suggestion] LAN_HTTP_FIRST : why not have a DeviceRegistry stored on disk ? #255
Comments
Hi @MichelRabozee , that's actually one of the feature I wanted to add in the near future. One of the ways I can think of it is to add two methods on the manager/device registry: export and import (both as json). Then it's up to the library user to handle storage on the disk and to load them when needed. Feel free to open a PR for that, I'll try to have a look at that! |
Hello, sadly, I am not so savvy with JSON to create such a pull request with the relevant code (if that is what you mean by PR). The way you mention it seems easy, but it need to have a good knowledge of the data needed to be exported and imported and at which point in your code; I fear it is out of my league, though I wanted to help :-( Anyway, I guess I will first take a look locally, I guess the best is to create the methods export_registry and import_registry using json.dump and json.load. Due to the involved objects complexity, I think the best is to use the "jsonpickle" module. But it implies to need to install that module. --edit-- I guess this operation requires more deep knowledge of the contents of that array, and a more "item by item" way of exporting/importing the data. Just staying at the DeviceRegistry object won't work. |
HI @albertogeniola, I REALLY would like you to make it so I can dump the devices to a json and load them from there rather than running async_device_discovery() every time, as @MichelRabozee says. (Bump! 🎸) Your library kicks ass, so I really want to use it, and here's my plug for implementing the above! The next best thing I could do to flip a meross device on or off from python would be to install Home Assistant on a VM I keep running all the time, or get an odroid or raspberry pi and set it up there. TON of work. So I'm going to be sitting here eagerly waiting! 😁 🙌 I can't wait :) |
Hi! You can dump the device list with the following command: manager.dump_device_registry("test.dump") At the same time, you can reload that dump with this: manager.load_devices_from_dump("test.dump") Have a look at the |
Hello, I am currently testing the dump functionality. I have a question: in the dump.py example, the second time a manager is created, there is no "manager.close()" nor "await http_api_client.async_logout()". Is it normal ? Will this not risk to exhaust the number of allowed tokens from Meross because the second manager also use "http_api_client = await MerossHttpClient.async_from_user_password(email=EMAIL, password=PASSWORD)" hence it is unclear if a "login" is really made or not.
Also, I found a typo in the dump.py example:
should be:
Regarding the dump system, it seems this works very well and in combination with "manager.default_transport_mode = TransportMode.LAN_HTTP_FIRST", we do gain the "discovery" process. I think to have the discovery then dumping done every morning , just in case, and use the dumped file for the recurrent calls to get the energy readings. |
Hi @MichelRabozee , Thanks! I'm closing the issue as you reported it's working as intended. |
The thing is, if "manager.close()" is called, you always get an error:
Calling "await http_api_client.async_logout()" is fine though in the second instance as well. |
Have you tried invoking |
Yes, I tried, to no avail. As soon as "manager.close()" is called, the above error appears. Looks like when no access to the Meross cloud is needed, something is not created/initialised in the manager, or rather, something is tried to be closed but was never started as no access to the Meross cloud was needed. |
I see. It looks like there still was a call to the Would you mind testing the 0.4.5.4rc1 which adds that features to the library and let me know if setting that flag to false solves the issue? |
Hello, sorry, I did not see you answered :-( I tested the 0.4.5.4rc1 in full "local" mode, as it seems a problem appeared in "async_device_discovery()" (see #274). There is no more error calling "manager.close()" is "manager.auto_discovery_on_connection = False" in the case of a full local situation ! Thank you ! |
Hi,
First, thank you for your incredible work !
Today, I ran into the "You have issued too many tokens without logging out." problem. I suspect this was because one of the MSS310 was offline, leading to some manager.close and http_api_client.async_logout not being performed, so I added a try/catch (as seen elsewhere) to correctly close and logout.
Anyway, this made me think about the "LAN_HTTP_FIRST" feature. However, this one requires anyway to log onto the cloud to retrieve the devices and build the DeviceRegistry, each time the script runs.
It is possible to have that DeviceRegistry written to disk and read from it for the stored data to be used instead of getting them each time from the cloud ?
My setup is 6 MSS310 to read the power consumption every minute, so every means to reduce the probability of a temporary account lock (for 5 hours!) is welcome!
Michel
The text was updated successfully, but these errors were encountered: