A Home Assistant custom integration for tracking gaming PC usage statistics per user. Monitor power consumption, session time, and electricity costs โ with a full custom sidebar panel, historical graphs, push notifications, and more.
- Multi-User Tracking: Individual statistics per user, configurable via UI
- Live Session Monitoring: Real-time power (watt gauge), time, and cost tracking
- Monthly Summaries: Automated monthly statistics per user
- Historical Graphs: Daily bar charts for the last 30 days per metric
- Leaderboard: Monthly ranking with ๐ฅ๐ฅ๐ฅ medals
- Push Notifications: Configurable rules with test and repeat support
- InfluxDB Integration: Long-term data storage for historical analysis
- Custom Sidebar Panel: Full-featured UI built directly into Home Assistant
- Dark/Light Theme: Automatically follows your HA theme
- Multi-Language Support: English and Danish translations included
| Metric | Unit | Description |
|---|---|---|
| Session Time | seconds | Active PC usage time for current session |
| Session Energy | kWh | Power consumption for current session |
| Session Cost | DKK | Electricity cost for current session |
| Monthly Time | seconds | Total usage time for current month |
| Monthly Energy | kWh | Total power consumption for current month |
| Monthly Cost | DKK | Total electricity cost for current month |
- Home Assistant: 2024.1 or newer
- InfluxDB: Running and accessible (v1.x)
- Required Sensors:
- User login sensor (returns current username as state)
- Power consumption sensor (PC wattage in W)
- Energy price sensor (DKK per kWh)
- (Optional) Device self-consumption sensor (only needed for plugs that expose it separately)
- Copy the
custom_components/pc_user_statistics/folder to your HA/config/custom_components/directory - Restart Home Assistant
- Go to Settings โ Devices & Services โ + Add Integration
- Search for PC User Statistics
- Enter your InfluxDB connection details
HACS submission pending
| Field | Example | Description |
|---|---|---|
| Host | a0d7b954-influxdb |
InfluxDB hostname or IP |
| Port | 8086 |
InfluxDB port |
| Database | homeassistant |
Database name |
| Username | homeassistant |
InfluxDB username |
| Password | โขโขโขโขโขโขโขโข |
InfluxDB password |
The integration will verify the InfluxDB connection, confirm the database exists, load existing monthly data, and start tracking immediately.
After setup, open the ๐ง Konfiguration tab in the sidebar panel to:
- Edit all 4 sensor entity IDs without touching any files
- Add, edit, or remove user mappings (sensor state โ user ID)
- Reorder sidebar tabs via drag-and-drop
Changes are saved instantly and trigger an automatic integration reload.
The integration adds a ๐ฎ PC Statistik entry to your HA sidebar with 6 tabs:
- Live session cards (tid, energi, pris)
- Donut-diagram med mรฅnedlig fordeling per bruger
- Mรฅnedlige totalkort per bruger
- ๐ Leaderboard med guld/sรธlv/bronze ranking
- Aktiv bruger med LIVE-badge
- Oversigt over alle konfigurerede brugere og sensor-mappings
- Konfigurer modtagerenheder (HA Companion app)
- 4 premade regler klar til brug:
- โฑ๏ธ Pausepรฅmindelse โ gentages hvert 60 min
- ๐ Lang session โ advarsel efter 3 timer
- ๐ฐ Prisgrรฆnse โ notifikation ved 10 kr
- ๐ PC glemt tรฆndt โ gentages hvert 30 min ved inaktivitet
- Opret egne regler med valgfri trigger, besked og repeat-interval
- Test-knap sender รธjeblikkelig push
- SVG sรธjlediagram โ daglige totaler de seneste 30 dage
- Skift mellem Tid / Energi / Pris
- 7-dages tabel med mini-sรธjler per bruger
- Rediger sensor entity IDs
- Administrer bruger-mappings
- Omarranger tabs via drag-and-drop
- System-info og version
- InfluxDB write buffer status
- Bruger-mappings oversigt
The integration requires a smart plug with power monitoring. The plug's watt sensor is read every 60 seconds to track energy consumption and cost.
| Hardware version | 1.0 |
| Firmware version | 1.2.6 |
| HA integration | TP-Link Smart Home (built-in) |
| Local control | Yes โ no cloud account required |
| HA polling | Every 5 seconds |
The HS110 exposes a current_consumption sensor (W) that is used directly for watt tracking. It does not expose a separate device self-consumption sensor โ the "Plug self-power" field in the configuration should be left empty when using HS110.
โ ๏ธ Do not update HS110 firmware. Firmware version 1.1.0 on certain hardware revisions broke local Home Assistant access. Version 1.2.6 on HW 1.0 is stable.
Entity IDs created by HS110 (example device name gamer_pc_power_monitor):
| Sensor | Entity ID | Unit |
|---|---|---|
| Current power | sensor.gamer_pc_power_monitor_current_consumption |
W |
| Total energy | sensor.gamer_pc_power_monitor_total_consumption |
kWh |
Any smart plug that exposes a watt (W) sensor in Home Assistant will work. The "Plug self-power" field is optional and only relevant for plugs that report their own power draw separately (e.g. Shelly Plug S/Plus).
HASS.Agent runs on the Windows gaming PC and reports the currently logged-in Windows username as a HA sensor state.
| Platform | Windows only |
| Sensor type | Logged In Users / Windows User |
| State example | Konge, Lukas, Sebas |
| Entity example | sensor.flemming_gamer_satellite_loggeduser |
The sensor state is matched to a user ID via the mappings configured in the ๐ง Konfiguration tab.
Any sensor returning a float value in DKK per kWh is supported. For Danish users, Energi Data Service (available via HACS) provides real-time spot prices including tariffs.
sensor.statistics_hub_current_usersensor.statistics_hub_current_session_timesensor.statistics_hub_current_session_energysensor.statistics_hub_current_session_cost
sensor.statistics_flemming_monthly_timesensor.statistics_flemming_monthly_energysensor.statistics_flemming_monthly_cost
(Same pattern for each configured user)
Measurement: pc_usage
Write frequency: Every 60 seconds (when user is active)
| Field | Type | Description |
|---|---|---|
power |
float | Current power in watts |
time_delta |
float | Seconds since last write |
energy_delta |
float | kWh since last write |
cost_delta |
float | DKK since last write |
Tags: user (string)
-- Total energy per user this month
SELECT SUM("energy_delta") AS "total_energy"
FROM "pc_usage"
WHERE time >= now() - 30d
GROUP BY "user"The integration uses a DataUpdateCoordinator with a 60-second polling interval.
| Event | What happens |
|---|---|
| State change (user/power sensor) | async_track_state_change_event triggers immediately |
| Every 60 seconds | Coordinator polls, calculates deltas, writes to InfluxDB |
| HA startup | Monthly totals loaded from InfluxDB with exponential backoff (30s / 60s / 120s) |
| InfluxDB write failure | Point buffered (FIFO, max 100) and retried next poll |
| 5+ consecutive failures | RepairIssue raised in HA UI โ visible under Settings โ Repairs |
Deltas (time, energy, cost) are only written to InfluxDB when a user is actively logged in and the power sensor reports a positive value.
- InfluxDB v1.x only โ InfluxDB v2.x / v3.x is not supported
- Single PC โ one integration instance tracks one PC; multi-PC requires multiple config entries (planned for v3.0.0)
- DKK currency โ electricity cost is calculated in Danish Krone (DKK); other currencies require a matching energy price sensor
- No historical import โ data tracking starts from the moment the integration is installed; existing InfluxDB data from other sources is not imported
- HA Companion app required for push notifications โ standard HA notify services are not supported in the notification UI
Check that all required sensors exist and are working. Verify entity IDs in the ๐ง Konfiguration panel tab, or check HA logs filtered by pc_user_statistics.
Verify InfluxDB is running and accessible. Check that the pc_usage measurement exists. Reload the integration: Settings โ Devices & Services โ PC User Statistics โ โฎ โ Reload
- Install the Home Assistant Companion app on your phone
- Open the ๐ Notifikationer tab and select your device
- Enable at least one rule and use the ๐จ Test button to verify
Expected when PC is idle โ the integration clamps negative values to 0.
Restart Home Assistant fully (not just reload). If the panel JS file was updated, clear your browser cache.
- Backup any automations/dashboards using old entity IDs
- Delete old integration (Settings โ Devices & Services โ Spille PC Statistik โ Delete)
- Install new integration and configure with your InfluxDB details
- Update entity ID references (see CHANGELOG.md)
Your historical data in InfluxDB is not affected.
MIT License โ see LICENSE for details.
- Home Assistant community for integration guidelines
- InfluxDB for time-series data storage
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with โค๏ธ for the Home Assistant community