✨ Add the remaining site-level metrics as sensors #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/40-site-metrics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes MateoGreil/homeassistant-comwatt#40.
The Comwatt site time-series API returns ten metric keys but only
autoproductionRateswas surfaced. Expose all ten: production, consumption, injection, withdrawal, charge, discharge, and their rate counterparts (auto-production / auto-consumption / injection / withdrawal).Design
sites_data[site_id]via a single_extract_site_metricshelper. Rates are multiplied by 100 in one place.ComwattAutoProductionRateSensorwith a genericComwattSiteMetricSensordriven by aComwattSiteMetricDescription. Adding a new metric is a one-line addition toSITE_METRICS.site_{site_id}_auto_production_rate). No registry churn for current users.Notes on units and state classes
PERCENTAGE+MEASUREMENT(as before).UnitOfEnergy.WATT_HOUR+MEASUREMENT. Intentionally nodevice_class=ENERGY— each reading is a per-hour delta, not a cumulative counter, and HA rejectsENERGY + MEASUREMENT. Users wanting Energy-dashboard-quality cumulative figures should use the existing{device}_total_energyentity or the newcomwatt:{device}_total_energyexternal statistic from #18.Test plan
test_site_metrics_expose_every_known_keyround-trips every API key to an entity state with the right unit.pytest tests/— 25 passed;ruff+mypyclean.b1dc5f4c609348329645View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.