一个处理meross设备的简单库。目前MSS110、MSS210、MSS310、MSS310H智能插头和MSS425E电源板。其他Meross设备可能会在功能有限的情况下开箱即用。尝试一下,如果有问题,在github上打开一个问题让开发人员知道。

meross-iot的Python项目详细描述


azure DevOps生成(分支)部署测试状态pypi versiondownloadspypi-downloadsbeerpay

Meross物联网库

一个基于python的纯库,提供api来控制互联网上的meross iot设备。

要查看当前支持的设备,请查看当前支持的设备部分。 但是,某些设备可能会按预期工作,即使它们未在支持的设备中列出。 在这种情况下,您将被邀请打开问题并报告设备的工作/非工作状态。 这将帮助我们跟踪新设备和库的当前支持状态。

此库仍在工作中,请谨慎使用。

安装

由于图书馆很受欢迎,我决定把它公开列在pipy索引上。 因此,安装只需键入以下命令即可:

pip install meross_iot==0.3.1.3 --upgrade

用法

下面的脚本演示如何使用此库。

frommeross_iot.managerimportMerossManagerfrommeross_iot.meross_eventimportMerossEventTypefrommeross_iot.cloud.devices.light_bulbsimportGenericBulbfrommeross_iot.cloud.devices.power_plugsimportGenericPlugfrommeross_iot.cloud.devices.door_openersimportGenericGarageDoorOpenerimporttimeimportosEMAIL=os.environ.get('MEROSS_EMAIL')or"YOUR_MEROSS_CLOUD_EMAIL"PASSWORD=os.environ.get('MEROSS_PASSWORD')or"YOUR_MEROSS_CLOUD_PASSWORD"defevent_handler(eventobj):ifeventobj.event_type==MerossEventType.DEVICE_ONLINE_STATUS:print("Device online status changed: %s went %s"%(eventobj.device.name,eventobj.status))passelifeventobj.event_type==MerossEventType.DEVICE_SWITCH_STATUS:print("Switch state changed: Device %s (channel %d) went %s"%(eventobj.device.name,eventobj.channel_id,eventobj.switch_state))else:print("Unknown event!")if__name__=='__main__':# Initiates the Meross Cloud Manager. This is in charge of handling the communication with the remote endpointmanager=MerossManager(meross_email=EMAIL,meross_password=PASSWORD)# Register event handlers for the manager...manager.register_event_handler(event_handler)# Starts the managermanager.start()# You can retrieve the device you are looking for in various ways:# By kindbulbs=manager.get_devices_by_kind(GenericBulb)plugs=manager.get_devices_by_kind(GenericPlug)door_openers=manager.get_devices_by_kind(GenericGarageDoorOpener)all_devices=manager.get_supported_devices()# Print some basic specs about the discovered devicesprint("All the bulbs I found:")forbinbulbs:print(b)print("All the plugs I found:")forpinplugs:print(p)print("All the garage openers I found:")forgindoor_openers:print(g)print("All the supported devices I found:")fordinall_devices:print(d)# You can also retrieve devices by the UUID/name# a_device = manager.get_device_by_name("My Plug")# a_device = manager.get_device_by_uuid("My Plug")# Or you can retrieve all the device by the HW type# all_mss310 = manager.get_devices_by_type("mss310")# ------------------------------# Let's play the garage openers.# ------------------------------forgindoor_openers:ifnotg.online:print("The garage controller %s seems to be offline. Cannot play with that..."%g.name)continueprint("Opening door %s..."%g.name)g.open_door()print("Closing door %s..."%g.name)g.close_door()# ---------------------# Let's play with bulbs# ---------------------forbinbulbs:# type: GenericBulbifnotb.online:print("The bulb %s seems to be offline. Cannot play with that..."%b.name)continueprint("Let's play with bulb %s"%b.name)ifnotb.supports_light_control():print("Too bad bulb %s does not support light control %s"%b.name)else:# Let's make it red!b.set_light_color(rgb=(255,0,0))b.turn_on()time.sleep(1)b.turn_off()# ---------------------------# Let's play with smart plugs# ---------------------------forpinplugs:# type: GenericPlugifnotp.online:print("The plug %s seems to be offline. Cannot play with that..."%p.name)continueprint("Let's play with smart plug %s"%p.name)channels=len(p.get_channels())print("The plug %s supports %d channels."%(p.name,channels))foriinrange(0,channels):print("Turning on channel %d of %s"%(i,p.name))p.turn_on_channel(i)time.sleep(1)print("Turning off channel %d of %s"%(i,p.name))p.turn_off_channel(i)usb_channel=p.get_usb_channel_index()ifusb_channelisnotNone:print("Awesome! This device also supports USB power.")p.enable_usb()time.sleep(1)p.disable_usb()ifp.supports_electricity_reading():print("Awesome! This device also supports power consumption reading.")print("Current consumption is: %s"%str(p.get_electricity()))# At this point, we are all done playing with the library, so we gracefully disconnect and clean resources.print("We are done playing. Cleaning resources...")manager.stop()print("Bye bye!")

当前支持的设备

从v0.2.0.0开始,这个库应该支持市场上的大多数meross设备。 测试设备列表如下:

  • MSL120
  • MSS110
  • MSS210
  • MSS310
  • MSS310H
  • MSS425E
  • MSS530H
  • msg100

我要感谢所有为图书馆早期发展做出贡献的人, 是谁激励我继续开发并使这个库支持更多设备:

感谢Danonekid、Virtualdj、Sobestadt、Sobestadt、Sobestadt、Sobestadt、Sobestadt、Sobestadt。ping本地主机

协议详细信息

这个库是通过反向工程实现的,即插头和meross网络之间的网络通信。 任何人都可以同样,只需在中间安装一个man-in-middle代理,并通过嗅探器路由android模拟器的ssl流量即可。

如果您想了解Meross协议的工作原理,请查看wiki。请注意:此操作仍在进行中,因此wiki的某些页面可能仍为空白/正在构建中。

家庭助理集成

是的,发生了。我一开始开发这个图书馆,就发现了家庭助理的世界。 因此,我决定花些时间来开发一个功能齐全的Homeassistant自定义组件,您可以在这里找到它。 感谢@troykelly,他许下了一个愿望,并支持我开发这种组件的努力!

捐献!

我喜欢逆向工程和协议检查,我认为它能让你的思维得到训练和健康。 但是,如果你喜欢或欣赏工作,为什么不给我买杯啤酒呢? 这将真正激励我继续开发这个存储库,以改进文档、代码和扩展受支持的meross设备。

此外,捐款将使我筹集资金用于其他Meross设备。 到目前为止,我已经购买了以下设备:

  • MSL120
  • MSS210
  • MSS310
  • MSS425E
  • MSS530H
  • msg100

通过捐款,您将:

  1. 让我有机会购买新设备并在此库中支持它们
  2. 支付一部分电费,用于24/7不间断地运行插头 (注意,当有人推一个pr时,它们用于连续集成引擎上的单元测试……我喜欢玩游戏!)
  3. 你可以用免费啤酒来提高我的编码质量!

给我买杯啤酒

beerpaybeerpay

当对这个存储库执行pull请求时,ci管道负责构建代码, 在python 3.5/3.6/3.7上测试它,依赖于一些junit测试,如果所有测试都像预期的那样通过,那么库 在PYPI上发布。但是,为了确保代码真正有效, 管道将针对真正的设备发出开/关命令,这些设备24/7专用于测试。 这些设备是我自己买的(捐赠者收到捐款)。 然而,保持这样的设备24/7的连接是有代价的,我很高兴图书馆的成功维持了这一点。 不管怎样,你可以通过捐款来捐款!

更改日志

0.3.1.5

0.3.1.3

0.3.0.2

0.3.0.1

0.3.0.0rc4

0.3.0.0rc3

0.3.0.0rc2

0.3.0.0rc1

0.3.0.0b1

0.2.2.1

0.2.1.1

0.2.1.0

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
主类中的java访问方法   Javalog4j不读取它的log4j。属性文件   雅加达ee通过Java(web应用程序)使用iText/任何其他使用现成数据的库生成PDF报告   lua使用java阅读TeamSpeak 3消息   将日期转换为BST java   java Spring引用ProxyFactoryBean中带有ref的protoyype bean   如何使java只打印一条带有if语句的消息   java如何通过JavaMail从雅虎服务器发送电子邮件?   使用百分比和BigDecimal的java测试   java如何对字符串数组排序   java验证器+MVC+REST::更新问题   java如何阻止eclipse如此频繁地挂起?   java从AsyncTask(片段内)访问TextView   IDEJava:制作可调整大小和拖动的组件