albertogeniola / meross-homeassistant

Custom component that leverages the Meross IoT library to integrate with Homeassistant
MIT License
727 stars 83 forks source link

msh300hk object has no attribute 'get_subdevice #400

Closed sirhaplo closed 6 months ago

sirhaplo commented 1 year ago

I've bought a Meross MTS150 Kit, with a thermostat ( MTS150 ) and a hub ( MSH300HK ). The integration see my hub, but no devices, and there isn't a hub device.

Here a piece of log that continue spawning on my logs :

2022-11-12 21:47:12.448 ERROR (MainThread) [meross_iot.manager] An unhandled exception occurred while handling push notification
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/meross_iot/manager.py", line 693, in _async_dispatch_push_notification
await dev.async_handle_push_notification(
File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/mixins/system.py", line 69, in async_handle_push_notification
parent_handled = await super().async_handle_push_notification(namespace=namespace, data=data)
File "/usr/local/lib/python3.10/site-packages/meross_iot/controller/mixins/hub.py", line 175, in async_handle_push_notification
subdev = self.get_subdevice(subdevice_id=subdev_id)
AttributeError: 'msh300hk:4.0.0:4.5.22' object has no attribute 'get_subdevice'
2022-11-12 21:47:12.456 WARNING (MainThread) [meross_iot.manager] Uncaught push notification Namespace.HUB_MTS100_TEMPERATURE. Raw data: {"temperature": [{"room": 190, "id": "03004B52"}]}

and here the init logs :

2022-11-12 11:40:15.126 WARNING (MainThread) [custom_components.meross_cloud] Skip MQTT cert validation option set to: True
2022-11-12 11:40:18.795 WARNING (MainThread) [custom_components.meross_cloud]
===============================
Meross Cloud Custom component
Developed by Alberto Geniola
Low level library version: 0.4.5.0
-------------------------------
This custom component is under development and not yet ready for production use.
In case of errors/misbehave, please report it here:
https://github.com/albertogeniola/meross-homeassistant/issues
If you like this extension and you want to support it, please consider donating.
-------------------------------
List of devices reported by HTTP API:
- Smart Hub (msh300hk) - OnlineStatus.ONLINE

There is something i can do ? Are these devices supported ?

Thank you a lot for your work, it's really appreciated

albertogeniola commented 1 year ago

Hi @sirhaplo ,

after a bit of digging, I realized that your HUB version (MSH300HK) is the new "home-kit" hub version, which has not yet been tested with this integration and with its low-level python library. Unfortunately I do not own any homekit version of this HUB to test and develop support for.

I'll mark this thread as "feature required" for the moment. Hopefully we'll add support for this device in the near future.

In the meantime, you might be able to simply add this device via the home-kit support in HA.

sirhaplo commented 1 year ago

Hi Alberto, i would like to help on this issue. Can you adress me on the fast way to make some test ? I have experience on python Dev and i could try to build up a pull request for the projects

sirhaplo commented 1 year ago

Hi Alberto, i found in the merros-iot library documentation the section about sniffing data and i've done a brief scan of some commands from the device. I attache here the data.zip results.

data.zip

I hope it will help.

Grazie Daniele

s1dave-web commented 1 year ago

Ah I suspect this answers my issue also - I have the homekit hub.

Homekit integration did work and showed my MTS150 valves but I have a mix of MTS100/150 and the 100s didn't show.

Interestingly the Meross LAN add on worked using meross cloud integration - it found the hub and all mts150/100 valves!

I would like to see this integrated so will keep track so I can move to 1 integration in the future.

albertogeniola commented 1 year ago

Hi! can you please provide a capture with the new version of meross_sniffer and provide the collected logs here?

KiraPC commented 1 year ago

Hello @albertogeniola. I've also the new valve version with HK support and them are not displayed on HA.

Anyway, Homebridge support them, maybe you could look at this repo https://github.com/bwp91/homebridge-meross for reverse eng, maybe they use the same protocol.

Otherwise, let me know if I can help on integrate them.

EDIT: I found this error in HA logs Could not find any specific subdevice class for type mts150. Applying generic SubDevice class.

NB: I had to disable the plugin because my meross app was not working properly since I started your plugin, maybe for too much requests.

sirhaplo commented 1 year ago

Hello @albertogeniola i did a new capture with new sniffer and new API. I attache che zip file here : data.zip

I did some activation, deactivation and temperature settings.

I hope this will help with your software.
Thanks so much

ga11ego commented 8 months ago

Hi all.

First of all, @albertogeniola , thanks a lot for your hard work, it is very appreciated here.

I have bumped with the same error:

File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/home/chris/src/BalmesBot/balmes_lib.py", line 162, in ReadMeross await dev.async_update() File "/home/chris/.local/lib/python3.9/site-packages/meross_iot/controller/mixins/system.py", line 20, in async_update await super().async_update(timeout=timeout, *args, **kwargs) File "/home/chris/.local/lib/python3.9/site-packages/meross_iot/controller/mixins/hub.py", line 81, in async_update target_device = self.get_subdevice(subdevice_id=dev_id) AttributeError: 'msh300hk:4.0.0:5.5.32' object has no attribute 'get_subdevice'

Is there any way I could help to fix this?

albertogeniola commented 6 months ago

Hi @sirhaplo and @ga11ego,

I've released a new beta version, v1.3.2beta1. I believe this version addresses - among all - also the issue you reported. Do you mind testing the new beta and provide feedbacks?

Thanks!

ga11ego commented 6 months ago

Hi @albertogeniola ,

Thanks for your efforts. I will test it and report back to you as soon as possible.

ga11ego commented 6 months ago

Hi @albertogeniola ,

Sorry if I ask something too easy, but I'm a bit confused. I was not ussing homeassistant, but only meross-iot.

The piece of code is this:

http_api_client = await MerossHttpClient.async_from_user_password(api_base_url='https://iotx-eu.meross.com',
                                                                  email=EMAIL, 
                                                                  password=PASSWORD)
manager = MerossManager(http_client=http_api_client)
await manager.async_init()

# Retrieve all the MS100 devices that are registered on this account
await manager.async_device_discovery()
sensors = manager.find_devices(device_type="msh300hk")

if len(sensors) < 1:
    print("No msh300hk plugs found...")
else:
    dev = sensors[0]
    await dev.async_update()
    temp = dev.last_sampled_temperature
    humid = dev.last_sampled_humidity
    time = dev.last_sampled_time
    print(f"Current sampled data on {time.isoformat()}; Temperature={temp}°C, Humidity={humid}%")
manager.close()
await http_api_client.async_logout()

So i don't know how to install or manage the meross-homeassistant (i am on a RaspBerry Pi) I have read the readme.md doc but can't figure out what to do.

albertogeniola commented 6 months ago

Hi @ga11ego , this repository is about the HomeAssistant component. You should have opened the ticket on the MerossIot repository instead. In any case, I believe you just need to upgrade the MerossIot library to v0.4.7.2b3:

pip install meross_iot==0.4.7.2b3

Then you should be able to see the subdevices attached to the MSH300HK hub.

ga11ego commented 6 months ago

Hi @albertogeniola ,

Thanks a lot for your patience. Now I realise I posted the error in the wrong repository. Sorry for that.

Best regards, Christian