Meross wi-fi Plug

Others (MiLight, Hue, Toon etc...)
Post Reply
CLEMENT99
Posts: 33
Joined: Friday 26 January 2018 10:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Meross wi-fi Plug

Post by CLEMENT99 » Monday 24 September 2018 11:20

Anybody is using this Meross wi-fi plug ?
1-1P5301F411338.png
1-1P5301F411338.png (55.19 KiB) Viewed 379 times
It works fine with IFTTT command to swith on/off devices but I want to retrieve the power usage.
The goal is to create a python script to send energy data from Meross to a Domoticz virtual sensor.


Thanks

Cheers
Clement

CLEMENT99
Posts: 33
Joined: Friday 26 January 2018 10:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 » Tuesday 25 September 2018 19:14

I found this https://github.com/albertogeniola/MerossIot and it's what I was looking for !
After implementation, it seems to work, I get the following for energy data :
Connected with result code {'session present': 0}
Subscribing to topics...
Succesfully subscribed!
Succesfully subscribed!
--> {"payload": {}, "header": {"sign": "e23d225a40a10b7acfc7bf60c33205a3", "namespace": "Appliance.Control.Electricity", "payloadVersion": 1, "from": "/app/58143-afb5195e5fd962bb10d0f881ec66a886/subscribe", "method": "GET", "timestamp": 1537895123, "messageId": "77b0308f7568adc7a78caf7d17b0b0ec"}}
/app/58143-afb5195e5fd962bb10d0f881ec66a886/subscribe --> b'{"header":{"messageId":"77b0308f7568adc7a78caf7d17b0b0ec","namespace":"Appliance.Control.Electricity","method":"GETACK","payloadVersion":1,"from":"/appliance/18071932131318251a0534298f1370ab/publish","timestamp":1537895119,"timestampMs":160,"sign":"a2c890dee095d42e8c03da253ee67963"},"payload":{"electricity":{"channel":0,"current":41,"voltage":2331,"power":4042}}}'
{'electricity': {'channel': 0, 'power': 4042, 'current': 41, 'voltage': 2331}}
The current power is 4,042W

Now find a way to retrieve the value from the string in the python script and send it to a virtual sensor ...

User avatar
heggink
Posts: 599
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V4.9999
Location: NL
Contact:

Re: Meross wi-fi Plug

Post by heggink » Tuesday 25 September 2018 20:22

Interesting devices. My key concern would be the data being retrieved from someone's cloud rather than being able to access the devices directly. I would not want my data to leave my house...
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

CLEMENT99
Posts: 33
Joined: Friday 26 January 2018 10:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 » Friday 28 September 2018 13:23

Well here is the python program to get the power value and set the virtual sensor.
This code is based on the following github: https://github.com/albertogeniola/MerossIot

Just install and create the following python:
import time
import sys
import requests
from meross_cloud import MerossHttpClient

if __name__=='__main__':
httpHandler = MerossHttpClient(email="your meross email", password="your meross password")

# Retrieves the list of supported devices
devices = httpHandler.list_supported_devices()

# Returns the current power consumption and voltage from the plug
# (Note: this is not really realtime, but close enough)
electricity = devices[0].get_electricity()

current_status = devices[0].get_electricity()
str1 = str(current_status)
start1=str1.find('power')+8
end1=str1.find(",",start1)

output_s=str1[start1:end1-1]
output_n=int(output_s)/100
output_h=round(int(output_n))
# Parsing URL
httpurl = 'http://user:password@domoticz ip address/json.htm?type=command&param=udevice&idx=Device ID&nvalue=0&svalue='+str(output_h)+';0;0;0;'+str(output_n)+';0'
# Sending data to Domoticz
r = requests.get(httpurl)
Capture.JPG
Capture.JPG (13.74 KiB) Viewed 313 times
Next step it be the ability to access the device directly.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest