mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Drop single-use service name constants in amberelectric (#164152)
This commit is contained in:
@@ -16,8 +16,6 @@ ATTRIBUTION = "Data provided by Amber Electric"
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
SERVICE_GET_FORECASTS = "get_forecasts"
|
||||
|
||||
GENERAL_CHANNEL = "general"
|
||||
CONTROLLED_LOAD_CHANNEL = "controlled_load"
|
||||
FEED_IN_CHANNEL = "feed_in"
|
||||
|
||||
@@ -22,7 +22,6 @@ from .const import (
|
||||
DOMAIN,
|
||||
FEED_IN_CHANNEL,
|
||||
GENERAL_CHANNEL,
|
||||
SERVICE_GET_FORECASTS,
|
||||
)
|
||||
from .coordinator import AmberConfigEntry
|
||||
from .helpers import format_cents_to_dollars, normalize_descriptor
|
||||
@@ -101,7 +100,7 @@ def async_setup_services(hass: HomeAssistant) -> None:
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
handle_get_forecasts,
|
||||
GET_FORECASTS_SCHEMA,
|
||||
supports_response=SupportsResponse.ONLY,
|
||||
|
||||
@@ -5,7 +5,7 @@ import re
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.amberelectric.const import DOMAIN, SERVICE_GET_FORECASTS
|
||||
from homeassistant.components.amberelectric.const import DOMAIN
|
||||
from homeassistant.components.amberelectric.services import ATTR_CHANNEL_TYPE
|
||||
from homeassistant.const import ATTR_CONFIG_ENTRY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -30,7 +30,7 @@ async def test_get_general_forecasts(
|
||||
await setup_integration(hass, general_channel_config_entry)
|
||||
result = await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{ATTR_CONFIG_ENTRY_ID: GENERAL_ONLY_SITE_ID, ATTR_CHANNEL_TYPE: "general"},
|
||||
blocking=True,
|
||||
return_response=True,
|
||||
@@ -59,7 +59,7 @@ async def test_get_controlled_load_forecasts(
|
||||
await setup_integration(hass, general_channel_and_controlled_load_config_entry)
|
||||
result = await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{
|
||||
ATTR_CONFIG_ENTRY_ID: GENERAL_AND_CONTROLLED_SITE_ID,
|
||||
ATTR_CHANNEL_TYPE: "controlled_load",
|
||||
@@ -91,7 +91,7 @@ async def test_get_feed_in_forecasts(
|
||||
await setup_integration(hass, general_channel_and_feed_in_config_entry)
|
||||
result = await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{
|
||||
ATTR_CONFIG_ENTRY_ID: GENERAL_AND_FEED_IN_SITE_ID,
|
||||
ATTR_CHANNEL_TYPE: "feed_in",
|
||||
@@ -130,7 +130,7 @@ async def test_incorrect_channel_type(
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{
|
||||
ATTR_CONFIG_ENTRY_ID: GENERAL_ONLY_SITE_ID,
|
||||
ATTR_CHANNEL_TYPE: "incorrect",
|
||||
@@ -153,7 +153,7 @@ async def test_unavailable_channel_type(
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{
|
||||
ATTR_CONFIG_ENTRY_ID: GENERAL_ONLY_SITE_ID,
|
||||
ATTR_CHANNEL_TYPE: "controlled_load",
|
||||
@@ -178,7 +178,7 @@ async def test_service_entry_availability(
|
||||
with pytest.raises(ServiceValidationError) as err:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{
|
||||
ATTR_CONFIG_ENTRY_ID: mock_config_entry2.entry_id,
|
||||
ATTR_CHANNEL_TYPE: "general",
|
||||
@@ -192,7 +192,7 @@ async def test_service_entry_availability(
|
||||
with pytest.raises(ServiceValidationError) as err:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_FORECASTS,
|
||||
"get_forecasts",
|
||||
{ATTR_CONFIG_ENTRY_ID: "bad-config_id", ATTR_CHANNEL_TYPE: "general"},
|
||||
blocking=True,
|
||||
return_response=True,
|
||||
|
||||
Reference in New Issue
Block a user