Skip to content
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

MSS560 Dimmer Support.... #39

Closed
shodge12 opened this issue Apr 11, 2019 · 5 comments
Closed

MSS560 Dimmer Support.... #39

shodge12 opened this issue Apr 11, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@shodge12
Copy link

shodge12 commented Apr 11, 2019

Found your code referencing the control of MEROSS devices. I picked up a dimmer from amazon [hoping it was Tasmota compatible - alas no].
https://smile.amazon.com/gp/product/B07KM4P4Z1/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1

I ran your test code on the device and it did turn on and off. This is also a dimmer and seems to have a 'luminance': 60 parameter. Any chance of a small change to add a DIM ability to the device?

Here is my output from the device info....

Listing online devices...
- Kitchen Table (mss560m, 1 channels, HW 3.0.0, FW 3.1.5): Master=Off,

-------------------------------
Playing with device: Kitchen Table (mss560m, 1 channels, HW 3.0.0, FW 3.1.5): Master=Off,
-------------------------------

Getting system data...
{'all': {'digest': {'triggerx': [], 'togglex': [{'channel': 0, 'lmTime': 1555016413, 'onoff': 0}], 'timerx': [], 'light': {'luminance': 60, 'channel': 0, 'temperature': -1, 'rgb': -1, 'capacity': 4}}, 'system': {'hardware': {'uuid': '1812144891717229088234298f196791', 'chipType': 'mt7682', 'type': 'mss560m', 'version': '3.0.0', 'subType': 'us', 'macAddress': 'xx:xx:xx:xx:xx:xx'}, 'firmware': {'port': 2001, 'version': '3.1.5', 'server': 'iot.meross.com', 'compileTime': '2019/03/19 17:22:32 GMT +08:00', 'wifiMac': '60:38:e0:b5:5a:5b', 'userId': 200021, 'innerIp': '192.168.x.xxx'}, 'time': {'timestamp': 1555016654, 'timezone': 'America/New_York', 'timeRule': [[1552201200, -14400, 1], [1572760800, -18000, 0], [1583650800, -14400, 1], [1604210400, -18000, 0], [1615705200, -14400, 1], [1636264800, -18000, 0], [1647154800, -14400, 1], [1667714400, -18000, 0], [1678604400, -14400, 1], [1699164000, -18000, 0], [1710054000, -14400, 1], [1730613600, -18000, 0], [1741503600, -14400, 1], [1762063200, -18000, 0], [1772953200, -14400, 1], [1793512800, -18000, 0], [1805007600, -14400, 1], [1825567200, -18000, 0], [1836457200, -14400, 1], [1857016800, -18000, 0]]}, 'online': {'status': 1}}}}
The device supports 1 channels

Turning channel 0 on...
Unknown/Unsupported namespace/command: Appliance.Control.Light

Turning channel 0 off...

Thanks!

BTW - really looking forward to direct MQTT support...
-Stan

@albertogeniola
Copy link
Owner

Hi Stan,
That device is unfortunately not tested against the library, but it does not seem to be so complicated. As soon as I get my hands on one of those, I will implement the dimmer function. It's just a matter of time.

In the meanwhile, would you please post the output of the following script?

from meross_iot.api import MerossHttpClient
from meross_iot.supported_devices.power_plugs import set_debug_level
from logging import DEBUG
import csv, io

EMAIL = 'YOUR_EMAIL'
PASSWORD = 'YOUR_PASSWORD'

client = MerossHttpClient(email=EMAIL, password=PASSWORD)
devices = client.list_supported_devices()


def sanitize_personal_info(d):
    if isinstance(d, dict):
        for key, value in d.items():
            k = key.lower()

            if isinstance(value, dict):
                sanitize_personal_info(value)
            elif isinstance(value, str) and (k == 'uuid' or k=='macaddress' or k == 'wifimac' or k == 'userid' or k=='bssid' or k =='ssid'):
                d[key] = 'X'
    elif isinstance(d, list):
        for k in d:
            sanitize_personal_info(k)

    return d


if __name__ == '__main__':
    set_debug_level(DEBUG)
    output = io.StringIO()
    writer = csv.writer(output, delimiter=';')

    for d in devices:
        r = []
        r.append(d._type)
        r.append(d._hwversion)
        r.append(d._fwversion)
        r.append(sanitize_personal_info(d.get_sys_data()))
        r.append(sanitize_personal_info(d.get_channels()))

        abilities = d.get_abilities()
        r.append(sanitize_personal_info(abilities))
        r.append(sanitize_personal_info(d.get_channels()))

        writer.writerow(r)

    print("\n\n---------------------------------------")
    print(str(output.getvalue()))

Be aware that you need to update the library to the latest version (0.2.0.1) and to fill in your EMAIL and PASSWORD in the relative script variables. Also, before posting the output of the script, make sure you clean any MAC address/User-Id/Signature.

@albertogeniola albertogeniola added the enhancement New feature or request label Apr 12, 2019
@shodge12
Copy link
Author

Sorry, I was out for a few days... I am tempted to try to reflect this to my mosquito server as I have seen a few others try....
Here is the output of the above:

--> {"payload": {}, "header": {"from": "/app/200021-57e25ec3ab97a7277eb2fe0068098228/subscribe", "sign": "XXXX", "messageId": "268ac24576575c8d74617ba9a9f9ffeb", "payloadVersion": 1, "namespace": "Appliance.System.All", "timestamp": 1555555720, "method": "GET"}}
/app/200021-57e25ec3ab97a7277eb2fe0068098228/subscribe --> b'{"header":{"messageId":"268ac24576575c8d74617ba9a9f9ffeb","namespace":"Appliance.System.All","method":"GETACK","payloadVersion":1,"from":"/appliance/1812144891717229088234298f196791/publish","timestamp":1555555719,"timestampMs":873,"sign":"XXXX"},"payload":{"all":{"system":{"hardware":{"type":"mss560m","subType":"us","version":"3.0.0","chipType":"mt7682","uuid":"1812144891717229088234298f196791","macAddress":"XXXX"},"firmware":{"version":"3.1.5","compileTime":"2019/03/19 17:22:32 GMT +08:00","wifiMac":"XXXX","innerIp":"192.168.0.0","server":"iot.meross.com","port":2001,"userId":200021},"time":{"timestamp":1555555719,"timezone":"America/New_York","timeRule":[[1552201200,-14400,1],[1572760800,-18000,0],[1583650800,-14400,1],[1604210400,-18000,0],[1615705200,-14400,1],[1636264800,-18000,0],[1647154800,-14400,1],[1667714400,-18000,0],[1678604400,-14400,1],[1699164000,-18000,0],[1710054000,-14400,1],[1730613600,-18000,0],[1741503600,-14400,1],[1762063200,-18000,0],[1772953200,-14400,1],[1793512800,-18000,0],[1805007600,-14400,1],[1825567200,-18000,0],[1836457200,-14400,1],[1857016800,-18000,0]]},"online":{"status":1}},"digest":{"togglex":[{"channel":0,"onoff":0,"lmTime":1555206805}],"triggerx":[],"timerx":[],"light":{"capacity":4,"channel":0,"rgb":-1,"temperature":-1,"luminance":60}}}}}'
The following message was unhandled: {'payload': {'all': {'digest': {'triggerx': [], 'timerx': [], 'light': {'rgb': -1, 'temperature': -1, 'channel': 0, 'luminance': 60, 'capacity': 4}, 'togglex': [{'onoff': 0, 'lmTime': 1555206805, 'channel': 0}]}, 'system': {'online': {'status': 1}, 'hardware': {'version': '3.0.0', 'subType': 'us', 'macAddress': 'XXXX', 'chipType': 'mt7682', 'type': 'mss560m', 'uuid': '1812144891717229088234298f196791'}, 'time': {'timestamp': 1555555719, 'timezone': 'America/New_York', 'timeRule': [[1552201200, -14400, 1], [1572760800, -18000, 0], [1583650800, -14400, 1], [1604210400, -18000, 0], [1615705200, -14400, 1], [1636264800, -18000, 0], [1647154800, -14400, 1], [1667714400, -18000, 0], [1678604400, -14400, 1], [1699164000, -18000, 0], [1710054000, -14400, 1], [1730613600, -18000, 0], [1741503600, -14400, 1], [1762063200, -18000, 0], [1772953200, -14400, 1], [1793512800, -18000, 0], [1805007600, -14400, 1], [1825567200, -18000, 0], [1836457200, -14400, 1], [1857016800, -18000, 0]]}, 'firmware': {'version': '3.1.5', 'port': 2001, 'compileTime': '2019/03/19 17:22:32 GMT +08:00', 'server': 'iot.meross.com', 'userId': 200021, 'innerIp': '192.168.0.0', 'wifiMac': 'XXXX'}}}}, 'header': {'sign': 'XXXX', 'from': '/appliance/1812144891717229088234298f196791/publish', 'timestampMs': 873, 'messageId': '268ac24576575c8d74617ba9a9f9ffeb', 'payloadVersion': 1, 'namespace': 'Appliance.System.All', 'timestamp': 1555555719, 'method': 'GETACK'}}
--> {"payload": {}, "header": {"from": "/app/200021-57e25ec3ab97a7277eb2fe0068098228/subscribe", "sign": "XXXX", "messageId": "cb78cd695dae95a7a685d2ba6de61edb", "payloadVersion": 1, "namespace": "Appliance.System.Ability", "timestamp": 1555555721, "method": "GET"}}
/app/200021-57e25ec3ab97a7277eb2fe0068098228/subscribe --> b'{"header":{"messageId":"cb78cd695dae95a7a685d2ba6de61edb","namespace":"Appliance.System.Ability","method":"GETACK","payloadVersion":1,"from":"/appliance/1812144891717229088234298f196791/publish","timestamp":1555555720,"timestampMs":99,"sign":"XXXX"},"payload":{"payloadVersion":1,"ability":{"Appliance.Config.Key":{},"Appliance.Config.WifiList":{},"Appliance.Config.Wifi":{},"Appliance.Config.Trace":{},"Appliance.Config.Calibration":{},"Appliance.System.All":{},"Appliance.System.Hardware":{},"Appliance.System.Firmware":{},"Appliance.System.Debug":{},"Appliance.System.Online":{},"Appliance.System.Time":{},"Appliance.System.Ability":{},"Appliance.System.Runtime":{},"Appliance.System.Report":{},"Appliance.System.Position":{},"Appliance.Control.Multiple":{"maxCmdNum":5},"Appliance.Control.ToggleX":{},"Appliance.Control.TimerX":{"sunOffsetSupport":1},"Appliance.Control.TriggerX":{},"Appliance.Control.Bind":{},"Appliance.Control.Unbind":{},"Appliance.Control.Upgrade":{},"Appliance.Control.Light":{"capacity":4},"Appliance.Digest.TriggerX":{},"Appliance.Digest.TimerX":{}}}}'
The following message was unhandled: {'payload': {'payloadVersion': 1, 'ability': {'Appliance.Control.Bind': {}, 'Appliance.Control.TriggerX': {}, 'Appliance.System.Runtime': {}, 'Appliance.Control.Unbind': {}, 'Appliance.Config.Calibration': {}, 'Appliance.Config.Wifi': {}, 'Appliance.System.Online': {}, 'Appliance.Config.WifiList': {}, 'Appliance.System.Report': {}, 'Appliance.System.Ability': {}, 'Appliance.Control.TimerX': {'sunOffsetSupport': 1}, 'Appliance.Digest.TimerX': {}, 'Appliance.Digest.TriggerX': {}, 'Appliance.Control.Light': {'capacity': 4}, 'Appliance.Control.Multiple': {'maxCmdNum': 5}, 'Appliance.System.All': {}, 'Appliance.Config.Trace': {}, 'Appliance.System.Hardware': {}, 'Appliance.System.Time': {}, 'Appliance.System.Position': {}, 'Appliance.System.Firmware': {}, 'Appliance.System.Debug': {}, 'Appliance.Config.Key': {}, 'Appliance.Control.ToggleX': {}, 'Appliance.Control.Upgrade': {}}}, 'header': {'sign': 'XXXX', 'from': '/appliance/1812144891717229088234298f196791/publish', 'timestampMs': 99, 'messageId': 'cb78cd695dae95a7a685d2ba6de61edb', 'payloadVersion': 1, 'namespace': 'Appliance.System.Ability', 'timestamp': 1555555720, 'method': 'GETACK'}}


mss560m;3.0.0;3.1.5;{'all': {'digest': {'triggerx': [], 'timerx': [], 'light': {'rgb': -1, 'temperature': -1, 'channel': 0, 'luminance': 60, 'capacity': 4}, 'togglex': [{'onoff': 0, 'lmTime': 1555206805, 'channel': 0}]}, 'system': {'online': {'status': 1}, 'hardware': {'version': '3.0.0', 'subType': 'us', 'macAddress': 'X', 'chipType': 'mt7682', 'type': 'mss560m', 'uuid': 'X'}, 'time': {'timestamp': 1555555719, 'timezone': 'America/New_York', 'timeRule': [[1552201200, -14400, 1], [1572760800, -18000, 0], [1583650800, -14400, 1], [1604210400, -18000, 0], [1615705200, -14400, 1], [1636264800, -18000, 0], [1647154800, -14400, 1], [1667714400, -18000, 0], [1678604400, -14400, 1], [1699164000, -18000, 0], [1710054000, -14400, 1], [1730613600, -18000, 0], [1741503600, -14400, 1], [1762063200, -18000, 0], [1772953200, -14400, 1], [1793512800, -18000, 0], [1805007600, -14400, 1], [1825567200, -18000, 0], [1836457200, -14400, 1], [1857016800, -18000, 0]]}, 'firmware': {'version': '3.1.5', 'port': 2001, 'compileTime': '2019/03/19 17:22:32 GMT +08:00', 'server': 'iot.meross.com', 'userId': 200021, 'innerIp': '192.168.0.0', 'wifiMac': 'X'}}}};[{}];{'Appliance.Control.Bind': {}, 'Appliance.Control.TriggerX': {}, 'Appliance.System.Runtime': {}, 'Appliance.Control.Unbind': {}, 'Appliance.Config.Calibration': {}, 'Appliance.Config.Wifi': {}, 'Appliance.System.Online': {}, 'Appliance.Config.WifiList': {}, 'Appliance.System.Report': {}, 'Appliance.System.Ability': {}, 'Appliance.Control.TimerX': {'sunOffsetSupport': 1}, 'Appliance.Digest.TimerX': {}, 'Appliance.Digest.TriggerX': {}, 'Appliance.Control.Light': {'capacity': 4}, 'Appliance.Control.Multiple': {'maxCmdNum': 5}, 'Appliance.System.All': {}, 'Appliance.Config.Trace': {}, 'Appliance.System.Hardware': {}, 'Appliance.System.Time': {}, 'Appliance.System.Position': {}, 'Appliance.System.Firmware': {}, 'Appliance.System.Debug': {}, 'Appliance.Config.Key': {}, 'Appliance.Control.ToggleX': {}, 'Appliance.Control.Upgrade': {}};[{}]

@shodge12
Copy link
Author

OK,

Loaded your last update 0.2.2.1 and started playing.

  1. Your new example tool error's out with undefines for GenericBulb and GenericPlug. I added the following to the top of the example file to correct.

from meross_iot.supported_devices.power_plugs import GenericPlug
from meross_iot.supported_devices.light_bulbs import GenericBulb

  1. It turns out that the changes you made for the bulb support will work on the mss560 dimmer with minor changes. I changed device_factory.py to force my mss560 to be a GenericBulb.

    if device_type.startswith('mss560'):
    return GenericBulb(token, key, user_id, **device_specs)
    elif device_type.startswith('msl'):
    return GenericBulb(token, key, user_id, **device_specs)
    elif device_type.startswith('mss'):
    return GenericPlug(token, key, user_id, **device_specs)
    else:
    return GenericPlug(token, key, user_id, **device_specs)

The mss560 dimmer obviously does not support rgb, but the 'light' payload has it (the mss560 ignores the value). It initially failed with your default of capability=5 and this dimmer is a capability of 4 (This can be seen in the capability dumps above). Using your example code and modifying it to have a capability of 4 works! Here is modified line from my edited example...

        device.set_light_color(rgb=(255, 255, 255), luminance=80, capacity=4)

        input("\nPress the <ENTER> key to continue...\n")


        device.set_light_color(rgb=(255, 255, 255), luminance=60, capacity=4)

        input("\nPress the <ENTER> key to continue...\n")


        device.set_light_color(rgb=(255, 255, 255), luminance=40, capacity=4)

        input("\nPress the <ENTER> key to continue...\n")


        device.set_light_color(rgb=(255, 255, 255), luminance=20, capacity=4)

        input("\nPress the <ENTER> key to continue...\n")

The rgb values are a don't care as the ack response always returns a -1 (same for temperature). The ack which comes back shows the previous luminance value so it you want the current (new) value - you would have to ask for the status after it changed.

Bottom line - If you document it, and make the change to device_factory.py you can say you support the mss560. BTW - you might consider selecting which object to create based upon the existence of the 'Light' payload....

As a last comment, I like a few others would like to control this locally without the use of the meross server. I have gotten it to work to my local Mosquitto server and will moving this direction going forward.

Thanks for your great work...
-Stan

@albertogeniola
Copy link
Owner

Hi @shodge12 ,
Great job. I've uploaded the library in accordance with your information. Now the max capacity is fetched via get_abilities so that it should work with any bulb. The pipeline is now building and releasing the new version, hopefully it'll be available in 5 minutes as meross-iot==0.2.2.2. Try that one and let me know if it's working as you'd expect.

Regarding your comment about using the library locally, there already are people doing so. They simply did not document the way they achieved the goal, but the library should work fine. Anyways, I'm planning to document it, but I have some other tasks in the todo-list that come first (for instance I am currently re-writing the entire library to be more robust, async-ready and easier to use). So, keep in touch since I'll need the help of you people to make sure the new version of the library works as expected!

@shodge12
Copy link
Author

I did a pull against 0.2.2.3 - just reporting that all is well with dimming using capacity=4.

-Stan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants