OCaml library for controlling Meross smart plugs via local HTTP API
OCaml 97.3%
Dune 0.7%
Other 1.9%
25 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-meross https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-meross
git@git.recoil.org:gazagnaire.org/ocaml-meross git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-meross

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

meross#

Control Meross smart plugs over local HTTP API without cloud.

Overview#

This library provides local control of Meross smart plugs (MSS310, MSS315, etc.) via their HTTP API. No cloud account or internet connection required.

Features#

  • Power control (on/off/toggle/reboot)
  • Real-time electricity monitoring (voltage, current, power)
  • Historical energy consumption
  • Countdown timers
  • Automation triggers
  • LED control (Do Not Disturb mode)
  • WiFi signal monitoring
  • Matter pairing support
  • Device discovery/scanning

Installation#

opam install meross

Usage#

Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
let net = Eio.Stdenv.net env in

(* Get device info *)
match Meross.get_info ~net ~sw "192.168.0.6" with
| Ok info -> Fmt.pr "%a@." Meross.pp_info info
| Error (`Msg e) -> Fmt.epr "Error: %s@." e

(* Control power *)
let _ = Meross.turn_on ~net ~sw "192.168.0.6" in
let _ = Meross.turn_off ~net ~sw "192.168.0.6" in

(* Get electricity reading *)
match Meross.get_electricity ~net ~sw "192.168.0.6" with
| Ok e -> Fmt.pr "Power: %.1f W@." (Meross.Electricity.power e)
| Error _ -> ()

Modules#

  • Meross.Protocol - HTTP protocol and authentication
  • Meross.Device - Device info and power control
  • Meross.Electricity - Real-time power monitoring
  • Meross.Consumption - Historical energy usage
  • Meross.Timers - Countdown timers
  • Meross.Triggers - Automation rules
  • Meross.Dnd - LED control
  • Meross.Runtime - WiFi signal and stats
  • Meross.Abilities - Feature discovery
  • Meross.Commissioning - Matter pairing

Supported Devices#

Tested with:

  • MSS310 (Smart Plug with Energy Monitor)
  • MSS315 (Smart Plug with Energy Monitor, Matter)

Should work with other Meross plugs that support local HTTP API.

This library focuses on local control without cloud dependencies.

Licence#

MIT License. See LICENSE.md for details.