Comments (8)
First implementation in 1472ee1.
Needed testers!
from merossiot.
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.
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.
Hi Alberto,
making reference to this repository, these are the pieces of code:
- registering the callback (within the
start_meross_manager
method ofMerossPlatform
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.
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.
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.
Hi @ace5987 ,
Please create a separate issue regarding your problem. I will delete your comments to this thread.
from merossiot.
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)
- ERROR:Could not parse error code 20101 HOT 4
- refused connection HOT 4
- Check if devices are online or offline HOT 1
- Cannot connect to the Meross Cloud
- using the library without using the meross cloud ? HOT 1
- I'm getting Invalid username/Password combination although they are correct. HOT 2
- Reading if MTS200b is heating? HOT 1
- MST960 reading current values is not possible HOT 3
- Meross changing the cloud api from 2024-01-01 HOT 4
- Logout fail HOT 1
- Meross Cloud API changed begining of January 2024 HOT 2
- Log entries HOT 10
- TypeError: async_from_user_password() missing 1 required positional argument: 'api_base_url'
- Is merossiot no longer working? HOT 4
- MerossManager._update_and_send_push' was never awaited HOT 5
- Incompatible with paho-mqtt 2.0 HOT 2
- hourly consumption MSS310 HOT 6
- https://iotx-eu.meross.com returns error 404 HOT 8
- Meross architecture clarification - recording electricity consumption HOT 2
- Operation of multiple MSS110 smart plugs HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from merossiot.