mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-05-28 18:43:40 +00:00
fix(docs): correct inaccuracies and add missing documentation
Documentation fixes: - configuration.md: Fix default min period length (30→60 min) - configuration.md: Fix Average Sensor Display location (Step 6→General Settings) - sensors-volatility.md: Add missing price_volatility attribute to table - sensors-trends.md: Document undocumented next_price_trend_change_in sensor - actions.md: Document undocumented get_price service Code quality fixes: - get_price.py: Fix misleading module docstring - timing.py: Remove dead code (unreachable return None) - binary_sensor/core.py: Simplify redundant tomorrow_data logic Impact: Users get accurate documentation. No behavioral changes.
This commit is contained in:
parent
1db86d1766
commit
07117801d2
7 changed files with 89 additions and 18 deletions
|
|
@ -207,11 +207,8 @@ class TibberPricesBinarySensor(TibberPricesEntity, BinarySensorEntity, RestoreEn
|
|||
# Get expected intervals for tomorrow (handles DST)
|
||||
expected_intervals = self.coordinator.time.get_expected_intervals_for_day(tomorrow_date)
|
||||
|
||||
if interval_count == expected_intervals:
|
||||
return True
|
||||
if interval_count == 0:
|
||||
return False
|
||||
return False
|
||||
# True only when ALL intervals are available (partial = not available)
|
||||
return interval_count == expected_intervals
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
|
|
|
|||
|
|
@ -183,9 +183,7 @@ class TibberPricesTimingCalculator(TibberPricesBaseCalculator):
|
|||
return future_periods[1]
|
||||
|
||||
# Default: return first future period
|
||||
return future_periods[0] if future_periods else None
|
||||
|
||||
return None
|
||||
return future_periods[0]
|
||||
|
||||
def _calc_remaining_minutes(self, period: dict) -> int:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
"""
|
||||
Service handler for get_price service.
|
||||
|
||||
This service provides direct access to the interval pool for testing and development
|
||||
purposes. It uses intelligent caching to minimize API calls by fetching only missing
|
||||
intervals from the API.
|
||||
This service fetches raw price interval data for any time range using the
|
||||
interval pool's intelligent caching. Only intervals not already cached are
|
||||
fetched from the Tibber API.
|
||||
|
||||
Functions:
|
||||
handle_get_price: Service handler for fetching price data
|
||||
|
||||
Used for:
|
||||
- Testing interval pool caching logic
|
||||
- Development and debugging of historical data queries
|
||||
- Verifying gap detection and cache hit/miss behavior
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
|
|
|||
|
|
@ -303,6 +303,57 @@ data:
|
|||
|
||||
---
|
||||
|
||||
### tibber_prices.get_price
|
||||
|
||||
**Purpose:** Fetches raw price interval data for any time range. Uses intelligent caching — only intervals not already cached are fetched from the Tibber API.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Parameter | Description | Required |
|
||||
|-----------|-------------|----------|
|
||||
| `entry_id` | Integration entry ID | Yes |
|
||||
| `start_time` | Start of the time range | Yes |
|
||||
| `end_time` | End of the time range | Yes |
|
||||
|
||||
**Example:**
|
||||
|
||||
```yaml
|
||||
service: tibber_prices.get_price
|
||||
data:
|
||||
entry_id: YOUR_CONFIG_ENTRY_ID
|
||||
start_time: "2025-11-01T00:00:00"
|
||||
end_time: "2025-11-02T00:00:00"
|
||||
response_variable: price_data
|
||||
```
|
||||
|
||||
**Response Format:**
|
||||
|
||||
```json
|
||||
{
|
||||
"home_id": "abc-123",
|
||||
"start_time": "2025-11-01T00:00:00+01:00",
|
||||
"end_time": "2025-11-02T00:00:00+01:00",
|
||||
"interval_count": 96,
|
||||
"price_info": [
|
||||
{
|
||||
"startsAt": "2025-11-01T00:00:00+01:00",
|
||||
"total": 0.2534,
|
||||
"energy": 0.1218,
|
||||
"tax": 0.1316
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Use cases:**
|
||||
- Fetching historical price data for analysis
|
||||
- Comparing prices across arbitrary date ranges
|
||||
- Building custom charts with historical data
|
||||
|
||||
**Note:** Times are automatically converted to your Tibber home's timezone. The interval pool caches previously fetched intervals, so repeated calls for the same range are fast.
|
||||
|
||||
---
|
||||
|
||||
## Migration from Chart Data Export Sensor
|
||||
|
||||
If you're still using the `sensor.<home_name>_chart_data_export` sensor, consider migrating to the `tibber_prices.get_chartdata` action:
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ Configure the Coefficient of Variation (CV) boundaries:
|
|||
Configure detection of favorable price windows. Three collapsible sections:
|
||||
|
||||
**Period Settings:**
|
||||
- Minimum period length (default: 30 min)
|
||||
- Minimum period length (default: 60 min)
|
||||
- Maximum price level to include (default: CHEAP)
|
||||
- Gap tolerance: how many expensive intervals to bridge (default: 1)
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ Information page for the legacy chart data export sensor. For new setups, use th
|
|||
|
||||
### Average Sensor Display Settings
|
||||
|
||||
**Location:** Settings → Devices & Services → Tibber Prices → Configure → Step 6
|
||||
**Location:** Settings → Devices & Services → Tibber Prices → Configure → **General Settings**
|
||||
|
||||
The integration allows you to choose how average price sensors display their values. This setting affects all average sensors (daily, 24h rolling, hourly smoothed, and future forecasts).
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,35 @@ A change from `rising` to `strongly_rising` (same direction) is **not** reported
|
|||
|
||||
---
|
||||
|
||||
## Next Price Trend Change In (Countdown)
|
||||
|
||||
**Entity ID:** `sensor.<home_name>_next_price_trend_change_in`
|
||||
|
||||
A **countdown timer** companion to the Next Price Trend Change sensor above. Instead of a timestamp, it shows **how many minutes** remain until the trend changes direction.
|
||||
|
||||
**State:** Duration in minutes until the next trend change (displayed in hours via HA unit conversion). Unavailable if no change is predicted.
|
||||
|
||||
**Use cases:**
|
||||
- Dashboard countdown: "Trend changes in 1.5 h"
|
||||
- Automation trigger: "If trend change is less than 15 minutes away, prepare for price direction change"
|
||||
|
||||
**Example automation:**
|
||||
|
||||
```yaml
|
||||
trigger:
|
||||
- platform: numeric_state
|
||||
entity_id: sensor.<home_name>_next_price_trend_change_in
|
||||
below: 0.25 # 15 minutes (displayed in hours)
|
||||
action:
|
||||
- service: notify.mobile_app
|
||||
data:
|
||||
message: "Price trend is about to change direction!"
|
||||
```
|
||||
|
||||
**Tip:** Use this sensor for "HOW LONG" and the Next Price Trend Change sensor (timestamp) for "WHEN".
|
||||
|
||||
---
|
||||
|
||||
## How to Use Trend Sensors for Decisions
|
||||
|
||||
:::danger Common Misconception — Don't "Wait for Stable"!
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ All volatility sensors provide these attributes:
|
|||
|
||||
| Attribute | Description | Example |
|
||||
|---|---|---|
|
||||
| `price_volatility` | Volatility level (language-independent, always English) | `"moderate"` |
|
||||
| `price_coefficient_variation_%` | The calculated Coefficient of Variation | `23.5` |
|
||||
| `price_spread` | The difference between the highest and lowest price | `12.3` |
|
||||
| `price_min` | The lowest price in the period | `10.2` |
|
||||
|
|
|
|||
Loading…
Reference in a new issue