logo elektroda
logo elektroda
X
logo elektroda

Tasmota cmnd=state Missing ENERGY Data on HLW8012, CSE7766, ADE7953, BL0937, PZEM Devices

User question

Why cmnd=state does not report energy ?

Artificial Intelligence Response

Direct answer to the question

  • cmnd/…/State does not contain ENERGY data because the STATE frame in Tasmota is intentionally limited to general device-status fields (relay state, uptime, Wi-Fi, firmware, etc.).
  • All power-monitoring values are delivered in the SENSOR and STATUS8/10 frames.
  • Use cmnd/…/Status 8, cmnd/…/Status 10, or subscribe to tele/…/SENSOR to obtain voltage, current, power and accumulated energy.

Detailed problem analysis

  1. Tasmota’s MQTT / command architecture
    • stat/…/RESULT – immediate acknowledgement of a command
    • tele/…/STATE – periodic or on-demand “system snapshot” (command State)
    • tele/…/SENSOR – periodic sensor/energy block (TelePeriod driven)
    • stat/…/STATUS8 / STATUS10 – sensor/energy on-demand (Status 8/10)

  2. Composition of a STATE payload

    {
    "Time":"2024-03-18T14:03:42",
    "Uptime":"1T00:17:29",
    "Heap":26,
    "SleepMode":"Dynamic",
    "Wifi":{"AP":1,"RSSI":-66,"SSID":"…"}
    }

    No ENERGY object is created in this handler, so it never reaches the JSON encoder.

  3. Where ENERGY is generated
    The ENERGY block is assembled in the sensor-task code path; that path is called only
    • when TelePeriod expires → tele/…/SENSOR
    • when Status 8 or Status 10 is parsed → stat/…/STATUS8/10

  4. Result: cmnd State cannot deliver ENERGY even if a measuring IC (HLW8012, CSE7766, ADE7953, BL0937, PZEM, etc.) is present and calibrated.

Current information and trends

  • Recent Tasmota builds (v13.x, Feb 2024) keep the same separation; no roadmap entry indicates merging ENERGY into STATE.
  • OpenBeken and ESP-based forks copy the same topic layout.
  • Home-automation platforms (Home Assistant, ioBroker, openHAB) therefore bind to tele/…/SENSOR for continuous metering and only use STATE for liveness checks.

Supporting explanations and details

Example commands and expected topics:

Action MQTT command Device reply topic Contains ENERGY?
Quick status cmnd/MyPlug/State tele/MyPlug/STATE
One-shot energy cmnd/MyPlug/Status 8 stat/MyPlug/STATUS8
Full sensor dump cmnd/MyPlug/Status 10 stat/MyPlug/STATUS10
Periodic energy cmnd/MyPlug/TelePeriod 60 tele/MyPlug/SENSOR every 60 s

Typical ENERGY block:

"ENERGY":{
"TotalStartTime":"2024-03-01T00:00:00",
"Total":12.345,
"Yesterday":0.811,
"Today":0.375,
"Power": 63,
"Voltage":229,
"Current":0.275,
"ApparentPower": 71,
"ReactivePower": 27,
"Factor":0.89
}

Ethical and legal aspects

  • Accurate energy data may be used for billing or regulatory reports; verify calibration and local legal requirements before relying on it for invoicing.
  • Ensure safe wiring of current transformers and shunts to avoid electric-shock hazards.

Practical guidelines

  1. Verify hardware: device must contain a supported metering chip.
  2. Apply correct template/module so Tasmota maps GPIOs to that chip.
  3. Calibrate (PowerCal, VoltageCal, CurrentCal) for accuracy.
  4. Choose retrieval method:
    • Continuous → set TelePeriod and subscribe to tele/SENSOR.
    • Sporadic query → Status 8 or Status 10.
  5. If ENERGY block is empty:
    • Check console after reboot for sensor initialization messages.
    • Make sure a non-zero load is connected (some ICs need current flow).

Possible disclaimers or additional notes

  • ENERGY is stored in flash every 200 Wh by default; power loss before that threshold loses part-cycle data.
  • Reflashing with a build lacking energy drivers removes ENERGY reporting.

Suggestions for further research

  • Investigate Tasmota Rule-based publishing of single metrics to reduce MQTT traffic.
  • Explore ESPHome if you need a custom topic structure.
  • Review upcoming ESP32-C3 power-monitoring designs with direct sigma-delta ADC metering (no external IC).

Brief summary

cmnd State never shows energy because ENERGY belongs to the sensor subsystem, not to the STATE snapshot. Use Status 8, Status 10, or subscribe to tele/…/SENSOR, and ensure your hardware and configuration support power monitoring.

User question

[WebApp Cmd 'Status 8' Result] Unknown command

Artificial Intelligence Response

Direct answer to the question

• “[WebApp Cmd 'Status 8' Result] Unknown command” means the firmware that is currently running on your Tasmota-based device was compiled without the energy-monitoring module (USE_ENERGY_SENSOR) or the command was malformed when it reached the device.
• In practice this happens almost exclusively when you flash one of the minimal / lite / display / IR / custom stripped builds or when the WebApp inserts an illegal “ =` ” sign instead of the single space required by Tasmota’s command grammar.
• Flash a build that contains the energy drivers (e.g. tasmota-sensors.bin) and send the command with the exact syntax

Status 8

over the console, MQTT (cmnd/<topic>/Status payload 8) or HTTP (/cm?cmnd=Status%208).

Key points

  1. “Unknown command” = command never found → missing at compile time or corrupted in transmission.
  2. Energy hardware absent or mis-configured would not raise “Unknown command”; you would receive an empty/zero ENERGY block instead.
  3. Upgrade to a full “sensors” build, apply the correct module/template, then retry.

Detailed problem analysis

  1. Tasmota command registration
    • At boot each feature module registers its commands.
    Status is always present, but the sub-handler for index 8 is compiled only if USE_ENERGY_SENSOR is enabled.
    • If absent, the dispatcher returns “Unknown command” the moment you ask for index 8.

  2. Common situations that remove the handler
    a. Pre-compiled binaries with reduced footprint
    – tasmota-lite, tasmota-minimal, tasmota-ir, tasmota-display, many vendor-specific OTA binaries.
    b. DIY custom builds where #undef USE_ENERGY_SENSOR (or #define USE_NO_ENERGY_SENSOR) was set to save flash.
    c. Builds older than ca. v6.6 where energy code was still optional in the core binary.

  3. Less frequent, but possible
    • Transport / syntax error (WebApp silently sends Status=8, %20 missing, extra CR LF, etc.).
    • A proxy-script that strips the space (causes Status8 which is not a legal command).
    • Very exotic edge cases: corrupted flash, run-time memory overwrite, but those will usually spam the log with exceptions before the console is ready.

  4. Symptoms that are not “Unknown command”
    • “Energy shows all zeros” → sensors compiled but no chip found or GPIOs wrong.
    • “STATE command shows no ENERGY block” but 8 works → TelePeriod / retain logic, not compile time.


Current information and trends (2024)

• Since v13 the official release set on OTA contains:
tasmota.bin (standard, still includes energy in 2024 but could be dropped in future to fit ESP8285 1 MB)
tasmota-sensors.bin (guaranteed energy drivers)
tasmota-lite.bin (no energy)
• For ESP32-C3/S3 larger flash sizes allow “universal” builds, but for ESP8266 size pressure keeps energy optional.
• Community trend: use templates from the Blakadder repository to auto-assign GPIOs instead of choosing a fixed “module”.
• Future direction: CMake-based “boards.txt” style-selective build so a single binary can enable drivers at run-time on devices with ≥4 MB flash (experimental in 14.x nightlies).


Supporting explanations and details

Command grammar (official docs):

<COMMAND><index><space><optional data>

No equals sign, no extra spaces. Therefore:
HTTP → /cm?cmnd=Status%208
MQTT → topic cmnd/myPlug/Status payload 8

Firmware variants and compiled-in features (excerpt): Binary (ESP8266) Flash size Energy sensor code Typical use case
tasmota-lite ≤ 448 kB No OTA staging, IR only, 1 MB chips
tasmota-minimal ≤ 350 kB No Mandatory first hop for very old devices
tasmota ≈ 640 kB Yes* (as of 14.0) General purpose
tasmota-sensors ≈ 780 kB Yes All sensor & energy drivers

*May be trimmed in future releases—always check the release notes.


Ethical and legal aspects

• Firmware replacement voids many consumer warranties; ensure compliance with local regulations if the device is used for billing-grade metering.
• Safety: When reflashing mains-powered plugs, work through an isolation barrier and respect the creepage distances.


Practical guidelines

  1. Identify the running binary

    Status 2

    Check the parentheses after the version, e.g. 13.5.0(tasmota-lite)

  2. Pick the correct upgrade path
    • If on minimal, first OTA-flash tasmota-sensors directly (since v12+ allows skipping the two-step).
    • If very old (<8.x), flash minimal → reboot → sensors.

  3. Apply device template
    – Configuration ▸ Configure Other ▸ Template ▸ paste JSON ▸ Activate ▸ Save.

  4. Reboot, open Console, and try

    Status 8

    You should now receive:

    {"StatusSNS":{"Time":"2024-06-01T12:34:56","ENERGY":{ ... }}}
  5. Optional verification

    TelePeriod 10 // shorten for testing

    Watch tele/<dev>/SENSOR messages over MQTT to confirm continuous energy telemetry.


Possible disclaimers or additional notes

• On 1 MB ESP8266 modules (Sonoff Basic R1, some older Gosund plugs) you might simply not have enough flash for a sensors build; compile a custom binary with only your IC driver and MQTT.
• Some proprietary energy ICs (e.g., BL09XX variants) demand correct board-level gain resistor values; mis-soldered boards will give nonsensical readings although the command works.


Suggestions for further research

• Investigate Berry scripting in Tasmota 14.x to post-process energy data locally.
• Explore ESPHome as an alternative if you routinely need custom drivers and already use Home-Assistant.
• Look into the upcoming Matter/Thread branch of Tasmota if you plan to integrate energy monitoring with new smart-home hubs.


Brief summary

“Unknown command” for Status 8 is almost always a compile-time omission: you are running a firmware build that lacks the energy-monitoring module or the WebApp mangled the command syntax.
Flash tasmota-sensors (or another full build), keep the exact Status 8 syntax, configure the correct template, and the command will return the ENERGY JSON block.

User question

how to get power [W] via http

Artificial Intelligence Response

Direct answer to the question

  • Send an HTTP GET request to your Tasmota-based power-monitoring device:
    http://<device-ip>/cm?cmnd=Status%2010 (or the lighter Status%208).
  • The reply is JSON. Read StatusSNS → ENERGY → Power.
  • Works only if the hardware contains a metering IC (e.g. HLW8012, BL09XX) and the firmware you flashed has energy code enabled ( tasmota-sensors.bin or a custom build with USE_ENERGY_SENSOR).

Key points
/cm?cmnd=Status 8/10 are the official REST endpoints for sensor/energy data.
• Space must be URL-encoded as %20.
• If the response lacks an ENERGY block or you get “Unknown command”, the firmware or template is wrong.
• Add user= and password= parameters when Web-UI authentication is enabled.


Detailed problem analysis

  1. Tasmota’s internal command tree
    State → core status (relay, uptime, Wi-Fi) – never carries energy.
    Status 8 → “SENSOR”: all sensor data, minimum overhead (≈ 0.6 kB).
    Status 10 → “STATUS + SENSOR”: full module, network, and sensor report (≈ 1.2 kB).

  2. JSON structure (excerpt)

    {
    "StatusSNS": {
    "Time": "2024-06-18T10:11:12",
    "ENERGY": {
    "TotalStartTime": "2024-06-01T00:00:00",
    "Total": 12.345,
    "Yesterday": 0.987,
    "Today": 0.123,
    "Power": 63, // <- instantaneous power in W
    "Voltage": 229,
    "Current": 0.275,
    "ApparentPower": 71,
    "ReactivePower": 27,
    "Factor": 0.89
    }
    }
    }
  3. Firmware variants

    tasmota-minimal → no sensors, upgrade helper only
    tasmota-lite → small footprint, no energy
    tasmota → generic, may lose energy in future builds
    tasmota-sensors (*) → full sensor & energy support ← recommended
  4. Why an “ENERGY” block may be missing
    • Wrong binary flashed.
    • Template/GPIO table does not map the metering IC pins.
    • Metering IC unpowered, faulty, or not present.


Current information and trends

• Since Tasmota v13.x the preferred query for automation systems is Status 8; older tutorials still cite Status 10. Both remain valid in 2024.
• A new TelePeriod default of 300 s keeps the device from flooding the network; HTTP polling every 30–60 s is common.
• JSONPath extraction is supported directly in Home-Assistant 2024.6+, eliminating custom templates.

Future directions
• Core team is evaluating an “edge-metrics” endpoint returning only key values (power, voltage, current) to cut traffic for low-power IoT radios.
• ESP32-C6 ports add native HTTPS and Matter for secured energy data.


Supporting explanations and details

Practical examples

• Browser test
http://192.168.1.123/cm?cmnd=Status%208

curl + jq one-liner

curl -s "http://192.168.1.123/cm?cmnd=Status%208" | \
jq '.StatusSNS.ENERGY.Power'

• Python snippet

import requests
power = requests.get("http://192.168.1.123/cm?cmnd=Status%208",
timeout=5).json()["StatusSNS"]["ENERGY"]["Power"]
print(f"Power = {power} W")

Advanced (push instead of pull)

Rule1 ON ENERGY#Power DO WebSend [my.server.net] /hook?pw=%value% ENDON
Rule1 1

The device now POSTs the wattage whenever it changes, saving bandwidth.


Ethical and legal aspects

• Network exposure: opening port-80 to the Internet can leak live consumption profiles. Use VPN or MQTT-over-TLS for remote access.
• Electrical safety: never exceed the plug’s rated current; inaccurate readings or overheating can cause fire.
• GDPR / CCPA: power data is personal usage information—treat logs accordingly.


Practical guidelines

Implementation checklist

  1. Flash tasmota-sensors.bin (Web UI → Firmware upgrade, or OTA URL).
  2. Apply the correct template (Configuration → Configure Other).
  3. Reboot, open console, ensure you see a line such as:
    HLW8012: Voltage=229.5V Current=0.27A Power=63W.
  4. Test with Status 8 URL.
  5. Integrate into your automation:
    • Node-RED: HTTP-request → JSON node → msg.payload.StatusSNS.ENERGY.Power.
    • Home-Assistant: RESTful Sensor platform.

Common pitfalls & fixes
• “401 Unauthorized” → supply credentials (http://user:pass@ip/...).
Power always 0 W → load below metering IC’s threshold; calibrate with EnergyCal.
• JSON decode error → configure Content-Type: application/json if using custom HTTP libraries.


Possible disclaimers or additional notes

• Single-value query (cm?cmnd=Power) returns relay state, not wattage—often confused in older blog posts.
• Meter accuracy is typically ±1 % after calibration; cheap plugs may drift.
• HTTP traffic is plain-text; consider MQTT-TLS or HTTPS proxy in security-sensitive environments.


Suggestions for further research

• Explore Tasmota’s Script engine to build custom REST endpoints.
• Investigate ESPHome if YAML-based configuration is preferred.
• Look at IEC 62053-21 class-2 or class-1 certified meters for billing-grade accuracy.
• Study upcoming Matter-Energy spec for unified smart-home power metering.


Brief summary

Query Status%208 or Status%2010 on the /cm endpoint of a Tasmota plug that has energy-capable firmware, parse ENERGY.Power, and you have the instantaneous power in watts. Ensure the correct firmware/template, URL-encode the space, authenticate if needed, and secure the traffic if it leaves your LAN.

Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.