Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:13 22 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Using MMB4L but not an MMB4L problem

Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3326
Posted: 12:56pm 17 Mar 2025
Copy link to clipboard 
Print this post

On a Pi 5, I'm trying to use MMB4L to retrieve and process the "ENERGY" values for a Sonoff POW R3 16 which has been flashed with Tasmota.

If I run this from the linux command prompt:
curl http://192.168.1.31/cm?cmnd=Status%208


I get this json payload back:
{"StatusSNS":{"Time":"2025-03-17T08:42:25","ENERGY":{"TotalStartTime":"2025-01-14T15:09:38","Total":242.301,"Yesterday":2.520,"Today":0.030,"Power":5,"ApparentPower":10, "ReactivePower":9,"Factor":0.44,"Voltage":123,"Current":0.085}}}


With MMB4L I get a bunch of header information before the data payload.
MMBasic for Linux aarch64 v0.7-alpha.1
Copyright 2011-2025 Geoff Graham
Copyright 2016-2025 Peter Mather
Copyright 2021-2025 Thomas Hugo Williams

> dim m%(100)
> system "curl http://192.168.1.31/cm?cmnd=Status%208",m%()
> longstring print m%()
 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100   233    0   233    0     0   1093      0 --:--:-- --:--:-- --:--:--  1093
{"StatusSNS":{"Time":"2025-03-17T08:42:25","ENERGY":{"TotalStartTime":"2025-01-14T15:09:38","Total":242.301,"Yesterday":2.520,"Today":0.030,"Power":5,"ApparentPower":10, "ReactivePower":9,"Factor":0.44,"Voltage":123,"Current":0.085}}}
>


I realize that the shell you get with MMB4L's "system" command may not be the same shell you have with the linux command prompt, and that is probably what is happening.

I do not see any obvious switch for curl to suppress the headers. Does anyone see how to get just the payload without further processing in MMB4L (e.g., INSTR to find "{" and then MID$ to extract the payload)?

~
Edited 2025-03-17 22:59 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4252
Posted: 01:10pm 17 Mar 2025
Copy link to clipboard 
Print this post

Try adding --no-progress-meter to the curl command within the SYSTEM call.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3326
Posted: 01:20pm 17 Mar 2025
Copy link to clipboard 
Print this post

Perfect. Thank you.

Asked and answered within 15 minutes. This forum cannot be beat.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025