Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamhow to publish total power without decimal places?
In current OpenBeken builds ( ≥ 1.17.223, 2024-05) the quickest way is:
VCPPrecision 0
After reboot, all Voltage-Current-Power telemetry – including Total Power / Energy_Total – is internally rounded to 0 decimal places and is published as an integer through MQTT and the web API.
On older firmware or if you need per-topic control, publish the integer explicitly:
publishMqtt "obk/<devname>/total_power_int" "$CH8|int"
(Replace CH8 with the channel that carries total power on your device).
CHx
). Energy_Total is usually CH8 for BL09xx/CSE7766-based plugs. • VCPPrecision
sets an internal printf-style format string; the payload is rounded, not truncated.
• The expression engine ($CHx|int
, $CHx|round
) is evaluated at publish time, therefore it never alters the stored channel value—only the outward representation.
• Energy dashboards that aggregate daily totals often prefer integer Wh or kWh for smaller JSON payloads.
• Some utility billing integrations reject floats; integer publishing avoids parsing errors.
• VCPPrecision
was merged 2024-05-17 (commit 5608e5d) and is available in the pre-compiled “main” binaries from GitHub Actions or obk.binary.space.
• A companion command VCPDigits
is being discussed to allow distinct precision per quantity (V, A, W).
• Home Assistant’s 2024.6 release auto-creates statistics sensors for integer energy topics; aligning with that avoids duplicate helper entities.
Example: keep three-decimal internal resolution, publish a rounded integer side topic only when the value changes by 1 W h or more:
addChangeHandler CH8 1 DoIntPublish
def DoIntPublish
publishMqtt "obk/plug01/total_kwh_int" "$CH8|round"
enddef
For watt-hours instead of kWh:
publishMqtt "…/total_wh_int" "$CH8*1000|round"
https://…/OpenBK7231T_1.17.223.bin
. VCPPrecision 0
, then restart 2
. /obk/plug01/8/get
now carries 123
instead of 123.456
.Potential challenges & fixes
$CHx|int
method or flash a newer binary. channels
in the console.VCPPrecision
affects voltage and current too; if you still need 2-3 decimals there, prefer the ad-hoc script approach. format("%.0f",$CH8)
inside rule blocks. user-properties
) for transmitting both raw and integer values in one packet.Setting VCPPrecision 0
(firmware ≥ 1.17.223) globally forces OpenBeken to round total power/energy to whole numbers before every publish. On older builds or when finer control is required, publish an additional topic using the expression $CHx|int
or $CHx|round
. Both methods ensure the value reaches your automation system without decimal places while preserving the original high-resolution measurement inside the device.