Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable less popular Fronius entities by default #60264

Merged
merged 2 commits into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions homeassistant/components/fronius/sensor.py
Expand Up @@ -21,6 +21,7 @@
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_FREQUENCY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_POWER_FACTOR,
DEVICE_CLASS_TEMPERATURE,
Expand Down Expand Up @@ -145,7 +146,9 @@ async def async_setup_entry(
key="frequency_ac",
name="Frequency AC",
native_unit_of_measurement=FREQUENCY_HERTZ,
device_class=DEVICE_CLASS_FREQUENCY,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="current_ac",
Expand Down Expand Up @@ -183,6 +186,7 @@ async def async_setup_entry(
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_dc",
Expand Down Expand Up @@ -220,11 +224,13 @@ async def async_setup_entry(
key="led_state",
name="LED state",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="led_color",
name="LED color",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_registry_enabled_default=False,
),
]

Expand Down Expand Up @@ -256,48 +262,55 @@ async def async_setup_entry(
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="current_ac_phase_2",
name="Current AC phase 2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="current_ac_phase_3",
name="Current AC phase 3",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_reactive_ac_consumed",
name="Energy reactive AC consumed",
native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
icon="mdi:lightning-bolt-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_reactive_ac_produced",
name="Energy reactive AC produced",
native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
icon="mdi:lightning-bolt-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_real_ac_minus",
name="Energy real AC minus",
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_real_ac_plus",
name="Energy real AC plus",
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_real_consumed",
Expand All @@ -317,6 +330,7 @@ async def async_setup_entry(
key="frequency_phase_average",
name="Frequency phase average",
native_unit_of_measurement=FREQUENCY_HERTZ,
device_class=DEVICE_CLASS_FREQUENCY,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
Expand All @@ -330,45 +344,52 @@ async def async_setup_entry(
native_unit_of_measurement=POWER_VOLT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_apparent_phase_2",
name="Power apparent phase 2",
native_unit_of_measurement=POWER_VOLT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_apparent_phase_3",
name="Power apparent phase 3",
native_unit_of_measurement=POWER_VOLT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_apparent",
name="Power apparent",
native_unit_of_measurement=POWER_VOLT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_factor_phase_1",
name="Power factor phase 1",
device_class=DEVICE_CLASS_POWER_FACTOR,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_factor_phase_2",
name="Power factor phase 2",
device_class=DEVICE_CLASS_POWER_FACTOR,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_factor_phase_3",
name="Power factor phase 3",
device_class=DEVICE_CLASS_POWER_FACTOR,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_factor",
Expand All @@ -382,48 +403,55 @@ async def async_setup_entry(
native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_reactive_phase_2",
name="Power reactive phase 2",
native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_reactive_phase_3",
name="Power reactive phase 3",
native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_reactive",
name="Power reactive",
native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:flash-outline",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_real_phase_1",
name="Power real phase 1",
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_real_phase_2",
name="Power real phase 2",
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_real_phase_3",
name="Power real phase 3",
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="power_real",
Expand All @@ -438,41 +466,47 @@ async def async_setup_entry(
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_ac_phase_2",
name="Voltage AC phase 2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_ac_phase_3",
name="Voltage AC phase 3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_ac_phase_to_phase_12",
name="Voltage AC phase 1-2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_ac_phase_to_phase_23",
name="Voltage AC phase 2-3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_ac_phase_to_phase_31",
name="Voltage AC phase 3-1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
entity_registry_enabled_default=False,
),
]

Expand All @@ -483,20 +517,23 @@ async def async_setup_entry(
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_year",
name="Energy year",
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="energy_total",
name="Energy total",
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
entity_registry_enabled_default=False,
frenck marked this conversation as resolved.
Show resolved Hide resolved
),
SensorEntityDescription(
key="meter_mode",
Expand Down Expand Up @@ -552,11 +589,13 @@ async def async_setup_entry(
key="capacity_maximum",
name="Capacity maximum",
native_unit_of_measurement=ELECTRIC_CHARGE_AMPERE_HOURS,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
SensorEntityDescription(
key="capacity_designed",
name="Capacity designed",
native_unit_of_measurement=ELECTRIC_CHARGE_AMPERE_HOURS,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
SensorEntityDescription(
key="current_dc",
Expand All @@ -581,6 +620,7 @@ async def async_setup_entry(
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:current-dc",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="voltage_dc_minimum_cell",
Expand All @@ -589,6 +629,7 @@ async def async_setup_entry(
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
icon="mdi:current-dc",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="state_of_charge",
Expand Down
18 changes: 17 additions & 1 deletion tests/components/fronius/__init__.py
@@ -1,8 +1,10 @@
"""Tests for the Fronius integration."""
from homeassistant.components.fronius.const import DOMAIN
from homeassistant.const import CONF_HOST
from homeassistant.helpers import entity_registry as er
from homeassistant.util import dt

from tests.common import MockConfigEntry, load_fixture
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture
from tests.test_util.aiohttp import AiohttpClientMocker

MOCK_HOST = "http://fronius"
Expand All @@ -22,6 +24,7 @@ async def setup_fronius_integration(hass):
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
return entry


def mock_responses(
Expand Down Expand Up @@ -70,3 +73,16 @@ def mock_responses(
f"{host}/solar_api/v1/GetStorageRealtimeData.cgi?Scope=System",
text=load_fixture("symo/GetStorageRealtimeData_System.json", "fronius"),
)


async def enable_all_entities(hass, config_entry_id, time_till_next_update):
"""Enable all entities for a config entry and fast forward time to receive data."""
registry = er.async_get(hass)
entities = er.async_entries_for_config_entry(registry, config_entry_id)
for entry in [
entry for entry in entities if entry.disabled_by == er.DISABLED_INTEGRATION
]:
registry.async_update_entity(entry.entity_id, **{"disabled_by": None})
await hass.async_block_till_done()
async_fire_time_changed(hass, dt.utcnow() + time_till_next_update)
await hass.async_block_till_done()