![]() |
Forum Index : Microcontroller and PC projects : Using MMB4L but not an MMB4L problem
Author | Message | ||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3326 |
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 KingdomPosts: 4252 |
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 StatesPosts: 3326 |
Perfect. Thank you. Asked and answered within 15 minutes. This forum cannot be beat. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |