Cleanup unused AlexaPercentageController code (#82880)

This commit is contained in:
Jan Bouwhuis 2022-11-29 10:06:53 +01:00 committed by GitHub
parent 026a222d16
commit fcccc44ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 124 deletions

View File

@ -63,8 +63,8 @@ build.json @home-assistant/supervisor
/tests/components/alarm_control_panel/ @home-assistant/core
/homeassistant/components/alert/ @home-assistant/core @frenck
/tests/components/alert/ @home-assistant/core @frenck
/homeassistant/components/alexa/ @home-assistant/cloud @ochlocracy
/tests/components/alexa/ @home-assistant/cloud @ochlocracy
/homeassistant/components/alexa/ @home-assistant/cloud @ochlocracy @jbouwh
/tests/components/alexa/ @home-assistant/cloud @ochlocracy @jbouwh
/homeassistant/components/almond/ @gcampax @balloob
/tests/components/almond/ @gcampax @balloob
/homeassistant/components/amberelectric/ @madpilot

View File

@ -656,59 +656,6 @@ class AlexaColorTemperatureController(AlexaCapability):
return None
class AlexaPercentageController(AlexaCapability):
"""Implements Alexa.PercentageController.
https://developer.amazon.com/docs/device-apis/alexa-percentagecontroller.html
"""
supported_locales = {
"de-DE",
"en-AU",
"en-CA",
"en-GB",
"en-IN",
"en-US",
"es-ES",
"es-US",
"fr-CA",
"fr-FR",
"hi-IN",
"it-IT",
"ja-JP",
"pt-BR",
}
def name(self):
"""Return the Alexa API name of this interface."""
return "Alexa.PercentageController"
def properties_supported(self):
"""Return what properties this entity supports."""
return [{"name": "percentage"}]
def properties_proactively_reported(self):
"""Return True if properties asynchronously reported."""
return True
def properties_retrievable(self):
"""Return True if properties can be retrieved."""
return True
def get_property(self, name):
"""Read and return a property."""
if name != "percentage":
raise UnsupportedProperty(name)
if self.entity.domain == fan.DOMAIN:
return self.entity.attributes.get(fan.ATTR_PERCENTAGE) or 0
if self.entity.domain == cover.DOMAIN:
return self.entity.attributes.get(cover.ATTR_CURRENT_POSITION, 0)
return 0
class AlexaSpeaker(AlexaCapability):
"""Implements Alexa.Speaker.

View File

@ -443,74 +443,6 @@ async def async_api_deactivate(
)
@HANDLERS.register(("Alexa.PercentageController", "SetPercentage"))
async def async_api_set_percentage(
hass: ha.HomeAssistant,
config: AbstractConfig,
directive: AlexaDirective,
context: ha.Context,
) -> AlexaResponse:
"""Process a set percentage request."""
entity = directive.entity
if entity.domain == fan.DOMAIN:
percentage = int(directive.payload["percentage"])
service = fan.SERVICE_SET_PERCENTAGE
data = {
ATTR_ENTITY_ID: entity.entity_id,
fan.ATTR_PERCENTAGE: percentage,
}
await hass.services.async_call(
entity.domain, service, data, blocking=False, context=context
)
elif entity.domain == humidifier.DOMAIN:
percentage = int(directive.payload["percentage"])
service = humidifier.SERVICE_SET_HUMIDITY
data = {
ATTR_ENTITY_ID: entity.entity_id,
humidifier.ATTR_HUMIDITY: percentage,
}
await hass.services.async_call(
entity.domain, service, data, blocking=False, context=context
)
else:
raise AlexaInvalidDirectiveError(DIRECTIVE_NOT_SUPPORTED)
return directive.response()
@HANDLERS.register(("Alexa.PercentageController", "AdjustPercentage"))
async def async_api_adjust_percentage(
hass: ha.HomeAssistant,
config: AbstractConfig,
directive: AlexaDirective,
context: ha.Context,
) -> AlexaResponse:
"""Process an adjust percentage request."""
entity = directive.entity
if entity.domain != fan.DOMAIN:
raise AlexaInvalidDirectiveError(DIRECTIVE_NOT_SUPPORTED)
percentage_delta = int(directive.payload["percentageDelta"])
current = entity.attributes.get(fan.ATTR_PERCENTAGE) or 0
# set percentage
percentage = min(100, max(0, percentage_delta + current))
service = fan.SERVICE_SET_PERCENTAGE
data = {
ATTR_ENTITY_ID: entity.entity_id,
fan.ATTR_PERCENTAGE: percentage,
}
await hass.services.async_call(
entity.domain, service, data, blocking=False, context=context
)
return directive.response()
@HANDLERS.register(("Alexa.LockController", "Lock"))
async def async_api_lock(
hass: ha.HomeAssistant,

View File

@ -4,6 +4,6 @@
"documentation": "https://www.home-assistant.io/integrations/alexa",
"dependencies": ["http"],
"after_dependencies": ["camera"],
"codeowners": ["@home-assistant/cloud", "@ochlocracy"],
"codeowners": ["@home-assistant/cloud", "@ochlocracy", "@jbouwh"],
"iot_class": "cloud_push"
}