Meross wi-fi Plug

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

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

Meross wi-fi Plug

Post by CLEMENT99 »

Anybody is using this Meross wi-fi plug ?
1-1P5301F411338.png
1-1P5301F411338.png (55.19 KiB) Viewed 11090 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: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 »

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: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Meross wi-fi Plug

Post by heggink »

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...
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 »

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 11024 times
Next step it be the ability to access the device directly.
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by jluc2808 »

hi , i started to intsall the same material under my domoticz , but the code above doesn't seem to work to create a plugin.py understadable as a plugin domoticz (i couldn't see any device to set as Meross plugin) , i surely miss some code in the plugin to set so !
Marv
Posts: 1
Joined: Thursday 10 January 2019 14:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by Marv »

@CLEMENT99

Any chance you could elaborate on how you got this working, i am just setting up a Domoticz server and i have a few of these around the house.

TIA
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Meross wi-fi Plug

Post by emme »

I've setted up a script based on Meross IOT Api ( https://github.com/albertogeniola/MerossIot )
a simple python script that can interact with them

Unfortunately I do not receive back the status... just ON and OFF commands
her eis the link
https://www.domoticz.com/forum/viewtopi ... ss#p200291
The most dangerous phrase in any language is:
"We always done this way"
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 »

Marv wrote: Thursday 10 January 2019 14:05 @CLEMENT99

Any chance you could elaborate on how you got this working, i am just setting up a Domoticz server and i have a few of these around the house.

TIA
You need to create a dummy device type P1 Smart Meter and set the value with a URL:
# Parsing URL
httpurl = 'http://user:password@domoticz-ip-addres ... idx=Device ID&nvalue=0&svalue='+str(output_h)+';0;0;0;'+str(output_n)+';0'
# Sending data to Domoticz
r = requests.get(httpurl)

This is only to get the value.
To swith on/off with domotics, plese follow emme sample.
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 »

Yes, it's also possbile to use IFTTT
Create a dummy device type switch.
Create 2 applets in IFTTT
In domoticz settings specify your IFTTT credentials
Change dummy device to call applets (see below) with the applet name and key
sample call -> https://maker.ifttt.com/trigger/applet- ... applet-key

Capture.JPG
Capture.JPG (29.99 KiB) Viewed 10194 times
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by jluc2808 »

i tried to use the script to create a material with python plugin and meross_iot is installed in the same folder then the plugin script
i always get an error

2019-01-15 17:02:02.311 Error: (meross) Module Import failed, exception: 'ImportError'
2019-01-15 17:02:02.311 Error: (meross) Module Import failed: ' Name: requests'
2019-01-15 17:02:02.311 Error: (meross) Error Line details not available.

my plugin.py :

Code: Select all

# Author: JLB
#
"""
<plugin key="MerossPlug" name="Meross M310" author="JL" version="1.0.0">
    <params>
     <param field="Mode6" label="Debug" width="75px">
       <options>
          <option label="True" value="Debug"/>
          <option label="False" value="Normal"  default="true" />
       </options>
     </param>
    </params>
</plugin>
"""
import time
import sys
import requests
import Domoticz
from meross_iot.api import MerossHttpClient

if __name__=='__main__':
	httpHandler = MerossHttpClient(email='Myemail', password='MyPassword')

# 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://192.168.1.45/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 = Request.get(httpurl) 
[\code]
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 »

Did you install everything in the folder \Domoticz\scripts\python\Meross ?
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by jluc2808 »

Yes
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by jluc2808 »

do you know the exact http request sent to Meross web server , if so if will be easier to create a dvEvents script with and store the results in virtual devices (or real one if it's better), if you have the log perhaps you could share what is sent .

thanks
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Meross wi-fi Plug

Post by CLEMENT99 »

I'll check that with wireshark but I'm waiting for a new plug (my son left with my plug :( )
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Meross wi-fi Plug

Post by emme »

does Domoticz supports python ver >= 3.6 on the plugin framework?
The most dangerous phrase in any language is:
"We always done this way"
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by jluc2808 »

i have installed python 3.5 because it's on my NAS synology and i have no package of 3.6 for the system.
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by corederoma82 »

CLEMENT99 wrote: Tuesday 15 January 2019 19:10 Did you install everything in the folder \Domoticz\scripts\python\Meross ?
Which things I have to install in this folder?

Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
corederoma82
Posts: 85
Joined: Saturday 14 January 2017 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by corederoma82 »

Can someone explain me the full procedure to install it?

Thanks
Raspberry PI 3, 3x Yeelight bulbs, 1x Yeeligh led strip, 1x Sonoff with ESP826, Controlicz, Kodi
mangoose
Posts: 10
Joined: Saturday 18 November 2017 8:37
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10x
Location: France
Contact:

Re: Meross wi-fi Plug

Post by mangoose »

Hi,

I created a bridge in NodeJS based on Apollon77 allowing to control the plugs from Domoticz and to get the power consumption.
The bridge is available here:
https://github.com/mangoose002/Meross2Domoticz

I am using pm2 to run it.

Hope it can help you.
jluc2808
Posts: 49
Joined: Thursday 18 January 2018 6:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Meross wi-fi Plug

Post by jluc2808 »

great, but sorry i don't understand how you install it ?
create a dummy ?
where is store the code ?
what need to be setted and what files ?
how you launch the application ?
what is needed inside domoticz ?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest