Skip to content

Conversation

@nazamhussain
Copy link

What

This PR exposes the electricity_charge and current_power fields returned by
get_energy_usage, which were already present in the device response but not
mapped in the Rust response struct / Python bindings.

Why

Devices such as the P110 and P304M return cost and instantaneous power data
that is currently inaccessible via the Python API. This prevents users from
accessing billing-related information even though the device reports it.

Changes

  • Added missing fields to EnergyUsageResult
  • Updated Python bindings to expose the data
  • No breaking API changes

Tested

  • Verified against TP-Link P110
  • Verified against TP-Link P304M (child plug)
  • Confirmed values match raw device responses

Before

energy_usage:
{'local_time': '2025-12-29T00:23:09',
 'month_energy': 8455,
 'month_runtime': 3503,
 'today_energy': 56,
 'today_runtime': 23}

After

energy_usage:
{'current_power': 151171,
 'electricity_charge': [0, 0, 2238],
 'local_time': '2025-12-29T03:50:48',
 'month_energy': 8961,
 'month_runtime': 3710,
 'today_energy': 562,
 'today_runtime': 230}

Copy link
Owner

@mihai-dinculescu mihai-dinculescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR.

I do agree that we should re-add current_power as quite a few people have been asking about it.

Can you please also add the two fields to https://github.com/mihai-dinculescu/tapo/blob/main/tapo-py/tapo-py/tapo/responses/energy_usage_result.pyi?

/// Current power in Milliwatts (mW).
pub current_power: Option<u64>,
/// Electricity charge/cost data as reported by the device.
pub electricity_charge: Option<Vec<u64>>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any more info to add here? I.e. interval, range, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants