Giter Site home page Giter Site logo

Comments (8)

albertogeniola avatar albertogeniola commented on July 25, 2024

First implementation in 1472ee1.
Needed testers!

from merossiot.

vincenzosuraci avatar vincenzosuraci commented on July 25, 2024

Dear Alberto,
after some days of continuous tests, I can confirm that:

  • MerossEventType.DEVICE_ONLINE_STATUS is never casted;
  • MerossEventType.DEVICE_SWITCH_STATUS is never casted.

I'm wondering if it is my fault (bad coding from my side?). I simply copied your example code, but I'm new with Python and could mess it up.

from merossiot.

albertogeniola avatar albertogeniola commented on July 25, 2024

Hi @vincenzosuraci , that is strange. I can correctly catch such events in my local tests. Can you show me the piece of code where you register the callback to the manager and the callback handler?

from merossiot.

vincenzosuraci avatar vincenzosuraci commented on July 25, 2024

Hi Alberto,
making reference to this repository, these are the pieces of code:

  • registering the callback (within the start_meross_manager method of MerossPlatform class):
    def start_meross_manager(self):

        try:
            # Create the manager
            self._meross_manager = MerossManager(self._username, self._password)

            # Starts the manager
            self._meross_manager.start()

            # Register event handlers for the manager...
            self._meross_manager.register_event_handler(self.meross_event_handler)

        except CommandTimeoutException:
            handle_command_timeout_exception('start_meross_manager()')

        except UnauthorizedException:
            handle_unauthorized_exception('start_meross_manager()')

        except ConnectionError:
            handle_connection_error_exception('start_meross_manager()')

        pass
  • callback hanlder (method of MerossPlatform class):
    def meross_event_handler(self, eventobj):
        _LOGGER.info(str(eventobj.event_type) + " event detected")
        if eventobj.event_type == MerossEventType.CLIENT_CONNECTION:
            # Fired when the MQTT client connects/disconnects to the MQTT broker
            # do nothing...
            pass
        elif eventobj.event_type == MerossEventType.DEVICE_ONLINE_STATUS:
            _LOGGER.info("Device online status changed: %s went %s" % (eventobj.device.name, eventobj.status))
            meross_device_uuid = eventobj.device.uuid
            meross_device_availability = eventobj.status
            if meross_device_uuid in self.meross_plugs_by_uuid:
                # the device has been already discovered >>> update its availability
                meross_plug = self.meross_plugs_by_uuid[meross_device_uuid]
                meross_plug.set_availability(meross_device_availability)
            else:
                # the device has not yet been discovered >>> add it
                self._hass.async_create_task(self.async_discover_plugs())
            pass
        elif eventobj.event_type == MerossEventType.DEVICE_SWITCH_STATUS:
            _LOGGER.info("Switch state changed: Device %s (channel %d) went %s" %
                         (eventobj.device.name, eventobj.channel_id, eventobj.switch_state))
            meross_device_uuid = eventobj.device.uuid
            channel = eventobj.channel_id
            channel_status = eventobj.switch_state
            meross_plug = self.meross_plugs_by_uuid[meross_device_uuid]
            meross_plug.switch_states[channel]['is_on'] = channel_status
        else:
            _LOGGER.warning(str(eventobj.event_type) + " is an unknown event!")
        pass

Regards,
Vincenzo

from merossiot.

 avatar commented on July 25, 2024

Hello @albertogeniola,

First off I use this api a lot and want to thank you for your hard work in creating it.

I am trying to use version 3 of your api but as I run your test script, i get the following error:

Unknown event!
Unknown event!
Unknown event!
Device online status changed: Family Lights went online
Device online status changed: Living Lights went online
Device online status changed: V2 Extra 2 went online
Device online status changed: V1 Extra 1 went online
Device online status changed: Bedroom Lamp went online
Device online status changed: UV Light went online
Traceback (most recent call last):
  File "./test.py", line 54, in <module>
    bed.get_status()
  File "~/git/MerossIot/meross_iot/cloud/devices/power_plugs.py", line 117, in get_status
    self._state = self._get_status_impl()
  File "~/git/MerossIot/meross_iot/cloud/devices/power_plugs.py", line 78, in _get_status_impl
    data = self.get_sys_data()['all']
  File "~/git/MerossIot/meross_iot/cloud/device.py", line 129, in get_sys_data
    return self.execute_command("GET", ALL, {})
  File "~/git/MerossIot/meross_iot/cloud/device.py", line 126, in execute_command
    return self.__cloud_client.execute_cmd(self.uuid, command, namespace, payload, callback=callback, timeout=timeout)
  File "~/git/MerossIot/meross_iot/cloud/client.py", line 300, in execute_cmd
    raise CommandTimeoutException("A timeout occurred while waiting fot the ACK: %d" % timeout)
meross_iot.cloud.exceptions.CommandTimeoutException.CommandTimeoutException: A timeout occurred while waiting fot the ACK: 10

I'm not sure why this is happening as version 2 seems to be working fine (Although for me, version 2 stops working after a day of running which is why I want to test version 3)

from merossiot.

 avatar commented on July 25, 2024

The test script is essentially doing this:

# Initiates the Meross Cloud Manager. This is in charge of handling the communication with the remote endpoint
    manager = MerossManager(meross_email=username, meross_password=password)

    # Register event handlers for the manager...
    manager.register_event_handler(event_handler)

    # Starts the manager
    manager.start()

    # You can retrieve the device you are looking for in various ways:
    # By kind
    devs = manager.get_supported_devices()
    devs[0].get_status()

It happens on the .get_status(), .turn_on(), .turn_off() commands.

Also noteworthy to add that all my devices are mss110 smart plugs

from merossiot.

albertogeniola avatar albertogeniola commented on July 25, 2024

Hi @ace5987 ,

Please create a separate issue regarding your problem. I will delete your comments to this thread.

from merossiot.

albertogeniola avatar albertogeniola commented on July 25, 2024

I can confirm that the library is working as intended. I guess that problem is somehow related with your code.

from merossiot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.