mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-04-07 08:03:40 +00:00
All entity descriptions had hardcoded English name= strings that were never used at runtime: HA always prefers translations via translation_key (entity.<platform>.<key>.name in translations/en.json), making the name= fields dead code. Removed 106 lines across all four platforms: - sensor/definitions.py: 85 name= lines - number/definitions.py: 12 name= lines - binary_sensor/definitions.py: 6 name= lines - switch/definitions.py: 3 name= lines No functional change. The unique_id (entry_id + key) and translation_key remain stable, ensuring entity IDs and friendly names are unaffected. Impact: Cleaner definitions, no drift between name= strings and translations. Aligns with HA standard: translations are the single source of truth for entity names.
55 lines
2 KiB
Python
55 lines
2 KiB
Python
"""Binary sensor entity descriptions for tibber_prices."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.components.binary_sensor import (
|
|
BinarySensorDeviceClass,
|
|
BinarySensorEntityDescription,
|
|
)
|
|
from homeassistant.const import EntityCategory
|
|
|
|
# Period lookahead removed - icons show "waiting" state if ANY future periods exist
|
|
# No artificial time limit - show all periods until midnight
|
|
|
|
ENTITY_DESCRIPTIONS = (
|
|
BinarySensorEntityDescription(
|
|
key="peak_price_period",
|
|
translation_key="peak_price_period",
|
|
icon="mdi:clock-alert",
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="best_price_period",
|
|
translation_key="best_price_period",
|
|
icon="mdi:clock-check",
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="connection",
|
|
translation_key="connection",
|
|
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="tomorrow_data_available",
|
|
translation_key="tomorrow_data_available",
|
|
icon="mdi:calendar-check",
|
|
device_class=None, # No specific device_class = shows generic "On/Off"
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=True, # Critical for automations
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="has_ventilation_system",
|
|
translation_key="has_ventilation_system",
|
|
icon="mdi:air-filter",
|
|
device_class=None, # No specific device_class = shows generic "On/Off"
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key="realtime_consumption_enabled",
|
|
translation_key="realtime_consumption_enabled",
|
|
icon="mdi:speedometer",
|
|
device_class=None, # No specific device_class = shows generic "On/Off"
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
)
|