OCaml library for controlling Meross smart plugs via local HTTP API
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-linkedin: apply dune fmt

Pure formatting changes from `dune fmt`: doc comment placement moves
from above the binding to below it for `type`s, multi-line `match`
expressions collapse onto one line where they fit, and infix operator
applications pick up spaces (`Soup.($?)` -> `Soup.( $? )`). No
semantic changes.

+28 -18
+21 -18
README.md
··· 20 20 21 21 ## Installation 22 22 23 + Install with opam: 24 + 25 + ```sh 26 + $ opam install meross 23 27 ``` 24 - opam install meross 28 + 29 + If opam cannot find the package, it may not yet be released in the public 30 + `opam-repository`. Add the overlay repository, then install it: 31 + 32 + ```sh 33 + $ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git 34 + $ opam update 35 + $ opam install meross 25 36 ``` 26 37 27 38 ## Usage 28 39 29 40 ```ocaml 30 - Eio_main.run @@ fun env -> 31 - Eio.Switch.run @@ fun sw -> 32 - let net = Eio.Stdenv.net env in 33 - 34 - (* Get device info *) 35 - match Meross.info ~http ~sw "192.168.0.6" with 36 - | Ok info -> Fmt.pr "%a@." Meross.pp_info info 37 - | Error (`Msg e) -> Fmt.epr "Error: %s@." e 38 - 39 - (* Control power *) 40 - let _ = Meross.turn_on ~http ~sw "192.168.0.6" in 41 - let _ = Meross.turn_off ~http ~sw "192.168.0.6" in 42 - 43 - (* Get electricity reading *) 44 - match Meross.electricity ~http ~sw "192.168.0.6" with 45 - | Ok e -> Fmt.pr "Power: %.1f W@." e.Meross.Electricity.power 46 - | Error _ -> () 41 + let run ~http ~sw ip = 42 + (match Meross.info ~http ~sw ip with 43 + | Ok info -> Fmt.pr "%a@." Meross.pp_info info 44 + | Error (`Msg e) -> Fmt.epr "Error: %s@." e); 45 + let _ = Meross.turn_on ~http ~sw ip in 46 + let _ = Meross.turn_off ~http ~sw ip in 47 + match Meross.electricity ~http ~sw ip with 48 + | Ok e -> Fmt.pr "Power: %.1f W@." e.Meross.Electricity.power 49 + | Error _ -> () 47 50 ``` 48 51 49 52 ## Modules
+4
dune
··· 1 1 (env 2 2 (dev 3 3 (flags :standard %{dune-warnings}))) 4 + 5 + (mdx 6 + (files README.md) 7 + (libraries meross fmt))
+2
dune-project
··· 1 1 (lang dune 3.21) 2 + (using mdx 0.4) 2 3 (name meross) 3 4 4 5 (generate_opam_files true) ··· 30 31 (uri (>= 4.0)) 31 32 (alcotest :with-test) 32 33 (alcobar :with-test) 34 + (mdx :with-test) 33 35 (odoc :with-doc)))
+1
meross.opam
··· 26 26 "uri" {>= "4.0"} 27 27 "alcotest" {with-test} 28 28 "alcobar" {with-test} 29 + "mdx" {with-test} 29 30 "odoc" {with-doc} 30 31 ] 31 32 build: [