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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register entity services only once #3042

Merged
merged 2 commits into from
Jan 31, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions custom_components/powercalc/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ async def async_setup_platform(
if CONF_CREATE_GROUP in config:
config[CONF_NAME] = config[CONF_CREATE_GROUP]

register_entity_services()

await _async_setup_entities(
hass,
config,
Expand Down Expand Up @@ -336,8 +338,6 @@ async def _async_setup_entities(
config_entry: ConfigEntry | None = None,
) -> None:
"""Main routine to setup power/energy sensors from provided configuration."""
register_entity_services()

try:
entities = await create_sensors(hass, config, config_entry)
if config_entry:
Expand Down
2 changes: 1 addition & 1 deletion profile_library/tuya/TYC-300mm-Z/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"name": "Tuya Zigbee 3.0 Ceiling Lamp RGB+CW+WW 24W",
"standby_power": 0.36,
"author": "Dr-Seltsam <[email protected]>"
}
}
4 changes: 3 additions & 1 deletion tests/config_flow/test_virtual_power_playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
CalculationStrategy,
SensorType,
)
from tests.common import get_test_config_dir
from tests.common import get_test_config_dir, run_powercalc_setup
from tests.config_flow.common import (
assert_default_virtual_power_entry_data,
create_mock_entry,
Expand Down Expand Up @@ -138,6 +138,8 @@ async def test_state_trigger(hass: HomeAssistant) -> None:
},
)

await run_powercalc_setup(hass, {})

hass.states.async_set("media_player.test", STATE_IDLE)
await hass.async_block_till_done()

Expand Down
Loading