mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 05:13:40 +00:00
refactor(services): rename and reorganize custom services for clarity and functionality
This commit is contained in:
parent
9ee7f81164
commit
294d84128b
5 changed files with 13 additions and 9 deletions
10
AGENTS.md
10
AGENTS.md
|
|
@ -379,7 +379,7 @@ After successful refactoring:
|
|||
2. `TibberPricesDataUpdateCoordinator` (`coordinator.py`) orchestrates updates every 15 minutes, manages persistent storage via `Store`, and schedules quarter-hour entity refreshes
|
||||
3. Price enrichment functions (`utils/price.py`, `utils/average.py`) calculate trailing/leading 24h averages, price differences, and rating levels for each 15-minute interval
|
||||
4. Entity platforms (`sensor/` package, `binary_sensor/` package) expose enriched data as Home Assistant entities
|
||||
5. Custom services (`services.py`) provide API endpoints for integrations like ApexCharts
|
||||
5. Custom services (`services/` package) provide API endpoints for chart data export, ApexCharts YAML generation, and user data refresh
|
||||
|
||||
**Key Patterns:**
|
||||
|
||||
|
|
@ -473,7 +473,13 @@ custom_components/tibber_prices/
|
|||
│ ├── __init__.py # Package exports
|
||||
│ ├── average.py # Trailing/leading average utilities
|
||||
│ └── price.py # Price enrichment, level/rating calculations
|
||||
├── services.py # Custom services (get_price, ApexCharts, etc.)
|
||||
├── services/ # Custom services package
|
||||
│ ├── __init__.py # Service registration
|
||||
│ ├── chartdata.py # Chart data export service
|
||||
│ ├── apexcharts.py # ApexCharts YAML generator
|
||||
│ ├── refresh_user_data.py # User data refresh
|
||||
│ ├── formatters.py # Data transformation utilities
|
||||
│ └── helpers.py # Common service helpers
|
||||
├── sensor/ # Sensor platform (package)
|
||||
│ ├── __init__.py # Platform setup (async_setup_entry)
|
||||
│ ├── core.py # TibberPricesSensor class (1,268 lines)
|
||||
|
|
|
|||
|
|
@ -312,8 +312,7 @@ template:
|
|||
|
||||
The integration provides custom services for advanced use cases:
|
||||
|
||||
- `tibber_prices.get_price` - Fetch price data for specific days/times
|
||||
- `tibber_prices.get_apexcharts_data` - Get formatted data for ApexCharts cards
|
||||
- `tibber_prices.get_chartdata` - Get price data in chart-friendly formats for any visualization card
|
||||
- `tibber_prices.get_apexcharts_yaml` - Generate complete ApexCharts configurations
|
||||
- `tibber_prices.refresh_user_data` - Manually refresh account information
|
||||
|
||||
|
|
|
|||
|
|
@ -163,8 +163,7 @@ async def async_unload_entry(
|
|||
# Unregister services if this was the last config entry
|
||||
if not hass.config_entries.async_entries(DOMAIN):
|
||||
for service in [
|
||||
"get_price",
|
||||
"get_apexcharts_data",
|
||||
"get_chartdata",
|
||||
"get_apexcharts_yaml",
|
||||
"refresh_user_data",
|
||||
]:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ flowchart TB
|
|||
%% Output Components
|
||||
SENSORS["sensor/<br/>TibberPricesSensor<br/><br/>120+ price/level/rating sensors"]
|
||||
BINARY["binary_sensor/<br/>TibberPricesBinarySensor<br/><br/>Period indicators"]
|
||||
SERVICES["services.py<br/><br/>Custom service endpoints<br/>(get_price, ApexCharts)"]
|
||||
SERVICES["services/<br/><br/>Custom service endpoints<br/>(get_chartdata, ApexCharts)"]
|
||||
|
||||
%% Flow Connections
|
||||
TIBBER -->|"Query user data<br/>Query prices<br/>(yesterday/today/tomorrow)"| API
|
||||
|
|
@ -199,7 +199,7 @@ For detailed cache behavior, see [Caching Strategy](./caching-strategy.md).
|
|||
| **Period Calculator** | `coordinator/periods.py` | Best/peak price period calculation with relaxation |
|
||||
| **Sensors** | `sensor/` | 80+ entities for prices, levels, ratings, statistics |
|
||||
| **Binary Sensors** | `binary_sensor/` | Period indicators (best/peak price active) |
|
||||
| **Services** | `services.py` | Custom service endpoints (get_price, ApexCharts) |
|
||||
| **Services** | `services/` | Custom service endpoints (get_chartdata, get_apexcharts_yaml, refresh_user_data) |
|
||||
|
||||
### Sensor Architecture (Calculator Pattern)
|
||||
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ These attributes allow automations to check: "Is the classification meaningful o
|
|||
For advanced configuration patterns and technical deep-dive, see:
|
||||
|
||||
- [Automation Examples](./automation-examples.md) - Real-world automation patterns
|
||||
- [Services](./services.md) - Using the `tibber_prices.get_price` service for custom logic
|
||||
- [Services](./services.md) - Using the `tibber_prices.get_chartdata` service for custom visualizations
|
||||
|
||||
### Quick Reference
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue