Skip to content

Commit

Permalink
Require entity_id to be specified when calling custom pump and light …
Browse files Browse the repository at this point in the history
…services.
  • Loading branch information
djtimca committed Jun 9, 2022
1 parent da721e2 commit f4be46e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion custom_components/omnilogic/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import voluptuous as vol

from homeassistant.components.light import ATTR_EFFECT, SUPPORT_EFFECT, LightEntity
from homeassistant.helpers import entity_platform
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.helpers import config_validation as cv, entity_platform

from .common import OmniLogicEntity, OmniLogicUpdateCoordinator
from .const import COORDINATOR, DOMAIN
Expand Down Expand Up @@ -62,6 +63,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
platform.async_register_entity_service(
SERVICE_SET_V2EFFECT,
{
vol.Required(ATTR_ENTITY_ID): cv.comp_entity_ids,
vol.Optional("brightness"): vol.All(
vol.Coerce(int), vol.Range(min=0, max=4)
),
Expand Down
4 changes: 4 additions & 0 deletions custom_components/omnilogic/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ set_pump_speed:
integration: omnilogic
domain: switch
fields:
entity_id:
name: Entity ID
description: Target pump entity.
required: true
speed:
name: Speed
description: Speed for the VSP between min and max speed.
Expand Down
6 changes: 5 additions & 1 deletion custom_components/omnilogic/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -56,7 +57,10 @@ async def async_setup_entry(

platform.async_register_entity_service(
SERVICE_SET_SPEED,
{vol.Required("speed"): cv.positive_int},
{
vol.Required(ATTR_ENTITY_ID): cv.comp_entity_ids,
vol.Required("speed"): cv.positive_int
},
"async_set_speed",
)

Expand Down

0 comments on commit f4be46e

Please sign in to comment.