* Implement Alexa.CameraStreamController.
* Add dependencies.
* Add camera helpers for image url, and mjpeg url.
* Remove unsupported AlexaPowerController from cameras.
* Refactor camera_stream_url to hass_url
* Declare HLS instead of RTSP.
* Add test for async_get_image_url() and async_get_mpeg_stream_url().
* Sort imports.
* Fix camera.options to camera.stream_options. (#32767)
(cherry picked from commit 9af95e8577)
* Remove URL configuration option for AlexaCameraStreamController.
* Update test_initialize_camera_stream.
* Optimize camera stream configuration.
* Update Tests for optimized camera stream configuration.
* Sort imports.
* Add check for Stream integration.
* Checks and Balances.
* Remove unnecessary camera helpers.
* Return None instead of empty list for camera_stream_configurations().
* alexa/capabilities.py: Fix TypeError Exception
- Remove division by zero try/catch -- there is no division
- Handle TypeError exception when current_volume = None
- Simplify math and return logic
* Add test for Alexa.Speaker's valid volume range
* Use f-strings in integrations starting with A
* Use f-strings in tests for integrations starting with A
* Fix pylint by renaming variable
* Fix nested for loop in f-string for aprs device_tracker
* Break long lines into multiple short lines
* Break long lines into multiple short lines v2
* Yield only one Speaker interface.
* Yield PowerController only is supported.
* Revert "Yield PowerController only is supported."
This reverts commit c0dbf7e4
* Add Alexa.Speaker interface properties.
* Refactor tests for Alexa.Speaker and Alexa.StepSpeaker.
* Code Smell Change.
* Fix R1705: Unnecessary "elif" after "return".
* Update tests with rangeValue and rangeValueDelta to use int.
* Add support for rangeValueDeltaDefault for covers.
* Update tests for range changes.
* Test for AdjustRangeValue with rangeValueDeltaDefault True.
* Update tilt error.
* Update attribute in Alexa service call for cover tilt
* Update Tests to fix Tilt Position call.
Co-authored-by: ochlocracy <5885236+ochlocracy@users.noreply.github.com>
* Add support for input_number entities
* Update homeassistant/components/alexa/capabilities.py
Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>
* Removed get methods to directly access required attributes dicts.
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Refactor capabilityResources object into class.
Implement semantics object to support open, close, raise, lower utterences.
Replace covers PercentageController with RangeController.
Add semantics for covers.
Remove PowerController for covers.
Add new display categories.
Add new items to Alexa Global Catalog.
Implement garage door voice PIN code support though Alexa app.
Fixed bug with getting property for ModeController.
Fixed bug were PercentageController AdjustPercentage would exceed 100.
* Comment fixes in Tests.
* Reorder imports.
* Added additional tests for more code coverage.
* Added and additional test for more code coverage.
* Explicitly return None for configuration() if not instance of AlexaCapabilityResource.
* Implement Alexa.EventDetectionSensor Interface
* Removed references to PR #28218 not yet merged into dev.
* Update tests to include Alexa Interface
* Guard for `unknown` and `unavailible` states.
* Fixed Unnecessary "elif" after "return"
* Added check for "name" channelMetada attribute
* Added/changed smart home media player tests for added value name in chanelMetadata payload section
* Since Alexa only expects a number/callSign/affiliate in the returned response, returning "name" is not technically valid. Modified to return the value in the callSign field instead since it's a text value. Since there is no returned channel number, cannot return a true numeric value in "channel" field
* Improve Alexa interface selection for binary sensors
This allows the sensor to work correctly as a contact or motion sensor
in alexa, if the user overrides its display category as such.
* add tests
* Explicitly include Alexa Interface to discovery response.
* Updated cloud component test to reflect additional Alexa interface.
* Updated test for recently added SeekController.
* Added Alexa.ModeController to cover entities.
* Added synonyms for directives.
* Updated tests for additional synonyms for directives.
* Added Alexa.ModeController to cover entities.
* Sacrifice unused variable in split() to please the Pylint gods.
* Removed duplicate instance check.
* Corrected variable name, clarified definition and consistency.
* Changed list to tuple.
* Update ThermostatController to map directives to supported modes and add support for CUSTOM mode.
* Removed erroneous config value from test.
* Removed unnecessary use of a comprehension by dumbing down comment so pylint could comprehend.
* Removed erroneous import variable caused by removing erroneous config value from test.
* Removed unnecessary use of a comprehension.
* Reverted Removal or erroneous import variable and erroneous config value from test.
Apparently need for additional tests outside this component. Whoops.
* Added missing Alexa.ChannelController functions. Specifically ChangeChannel
and SkipChannel commands. These functions will call the play_media function
in a media_player app if it has the capability published and pass on the
channel# or channel name. The selected media player can then use this to
select the channel on the device it is associated to.
Modified the existing Alexa.StepSpeaker Setvolume function to actually do
a stepped volume change using the steps sent by Alexa. The Alexa default
step of 10 for a simple volume up/down can be changed via an exposed
media_player attribute called volume_step_default.
The default is set to 1. Any other value then default will be sent
as sequential volume up /down to the media_player.
* The test code has some weird behaviour with passed boolean values. Had to surround them in quotes for the tests to pass properly.
* Reverted test_smart_home.py change. Issue was not the boolean value but the behavior in the handler. The test suite does not like multiple await calls in a loop. Will investigate further. The handler code works though.
* Added ChannelController/SkipChannels test in test_smart_home.py
Added test for callSign payload attribute.
* Modified smart home test to allow more than one call to services
* Added more tests for ChannelChange functions for various payload options.
Removed name options from metadata payload section. not needed.
* Reverted assert call change in alexa test __init__.py back to ==1. Not sure if it was the cause of the pytest's failing on github
* Corrected a comment. First commit after a rebase.
* Comment line change. Also wanted to force a code check on github.
* Added a loop delay in StepSpeaker and SkipChannel functions for safety
* Removed uneeded sleep from for loops. Let remote handle delays
Moved service type decision out of for loops in ChannelController and StepSpeaker
Used constants instead of numeric values for support options in test module
* Change media_player const import to be more specific in source
* Modifed test_smart_home to use media_play constants instead of hardcode valu
* Removed unecessary test volume_step_default attribute from test_smart_home
* Removed uneeded comment in StepSpeaker function.
Re-ordered constants in test_smart_home.py
* Modified call to media_player play_media service to use media_player constant instead of hard coded value.
* Changed constant use to be consistant with rest of function.
* Correct merge conflicts in handlers.py and capablities.py
* Implement AlexaToggleController, AlexaRangeController, and AlexaModeController interfaces.
* Implement AlexaToggleController, AlexaRangeController, and AlexaModeController interfaces.
* Unkerfuffled comments to please the pydocstyle gods.
* Unkerfuffled comments in Tests to please the pydocstyle gods.
* Added additional test for more coverage.
* Removed OSCILLATING property check from from ModeController.
* Added capability report tests for ModeController, ToggleController, RangeController, PowerLevelController.
* Update homeassistant/components/alexa/capabilities.py
Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>
* Update homeassistant/components/alexa/capabilities.py
Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>
* Corrected mis-spelling of AlexaCapability class.
* Changed instance from method to property in AlexaCapability class.
* Refactored to add {entity.domain}.{entity.attribute} to the instance name.
* Improved type handling for configuration object.
Added additional test for configuration object.
* Added Tests for unsupported domains for ModeController and RangeController
* Made changes to improve future scaling for other domains.
* Split fan range to speed maps into multiple constants.
* Update the Alexa.LockController Unlock directive to include the lockState property in the context of the response.
* Added Test for Alexa.LockController Unlock directive to include the lockState property in the context of the response.
* Fixes#26405 Return None if light state is off since attribute is unavailable, prevents property from being reported with invalid value of 0.
* Update Test to check property is not reported when light state is off.
* Added Fan to display categories.
* Added Doorbell to display categories.
* Added Microwave to display categories.
* Added Security Panel to display categories.
* Updated FanCapabilities to use FAN display category.
* Updated Tests for FanCapabilities to use FAN display category.
* Return None for AlexaThermostatController and AlexaTemperatureSensor properties if climate state is unavailable. Preserves raising an error for UnsupportedProperty, and allows Alexa.EndpointHealth to handle the unavailable state.
* Added additional tests for climate state reporting.
Fixed AlexaPowerController to report power state for thermostats, to look if state is OFF return OFF, otherwise report ON as thermostats have multiple values for ON
* Move more constants to const.py
* Import constants directly from const
* ATTR_ENTITY_ID is not defined in media_player
* MEDIA_PLAYER_PLAY_MEDIA_SCHEMA is still in __init__.py
* Correct imports in tts
* PLATFORM_SCHEMA, SCHEMA is still defined in __init__.py
* Pandora imports several services
* Some additional fixes for move of const in media_player
* Fix hound lengths
* Alexa: implement auth and proactive ChangeReport messages
* refactor after rebase from dev to use the new AlexaDirective and Response classes
* move to aiohttp; cleanup
* better function name
* move endpoint to config
* allow passing token function
* remove uneeded state get
* use iterable directly
Co-Authored-By: abmantis <abmantis@users.noreply.github.com>
* missing delete from previous commit
* checks for when user has no auth config
* update cloud component
* PR suggestions
* string lint
* Revert "string lint"
This reverts commit a05a1f134c9ebc7a6e67c093009744f142256365.
* linters are now happier
* more happy linters
* use internal date parser; improve json response handling
* remove unused import
* use await instead of async_add_job
* protect access token update method
* add test_report_state
* line too long
* add docstring
* Update test_smart_home.py
* test accept grant api
* init prefs if None
* add tests for auth and token requests
* replace global with hass.data
* doc lint
* Add support for locks in google assistant component
This is supported by the smarthome API, but there is no documentation
for it. This work is based on an article I found with screenshots of
documentation that was erroneously uploaded:
https://www.androidpolice.com/2018/01/17/google-assistant-home-can-now-natively-control-smart-locks-august-vivint-first-supported/
Google Assistant now supports unlocking certain locks - Nest and August
come to mind - via this API, and this commit allows Home Assistant to
do so as well.
Notably, I've added a config option `allow_unlock` that controls
whether we actually honor requests to unlock a lock via the google
assistant. It defaults to false.
Additionally, we add the functionNotSupported error, which makes a
little more sense when we're unable to execute the desired state
transition.
https://developers.google.com/actions/reference/smarthome/errors-exceptions#exception_list
* Fix linter warnings
* Ensure that certain groups are never exposed to cloud entities
For example, the group.all_locks entity - we should probably never
expose this to third party cloud integrations. It's risky.
This is not configurable, but can be extended by adding to the
cloud.const.NEVER_EXPOSED_ENTITIES array.
It's implemented in a modestly hacky fashion, because we determine
whether or not a entity should be excluded/included in several ways.
Notably, we define this array in the top level const.py, to avoid
circular import problems between the cloud/alexa components.
We were erroneously reporting the _previous_ mode. So if the thermostat was off
and the user asks, "Alexa, set the thermostat to heat", the thermostat would be
set to heat but Alexa would respond, "The thermostat is off."
Bug caught by @Thunderbird2086 at
https://github.com/home-assistant/home-assistant/pull/17969#issuecomment-434654345
* Refactor Alexa API to use objects for requests
This introduces _AlexaDirective to stand in for the previous model of passing
basic dict and list data structures to and from handlers. This gives a more
expressive platform for functionality common to most or all handlers.
I had two use cases in mind:
1) Most responses should include current properties. In the case of locks and
thermostats, the response must include the properties or Alexa will give the
user a vague error like "Hmm, $device is not responding." Locks currently work,
but thermostats do not. I wanted a way to automatically include properties in
all responses. This is implemented in a subsequent commit.
2) The previous model had a 1:1 mapping between Alexa endpoints and Home
Assistant entities. This works most of the time, but sometimes it's not so
great. For example, my Z-wave thermostat shows as three devices in Alexa: one
for the temperature sensor, one for the heat, and one for the AC. I'd like to
merge these into one device from Alexa's perspective. I believe this will be
facilitated with the `endpoint` attribute on `_AlexaDirective`.
* Include properties in all Alexa responses
The added _AlexaResponse class provides a richer vocabulary for handlers.
Among that vocabulary is .merge_context_properties(), which is invoked
automatically for any request directed at an endpoint. This adds all supported
properties to the response as recommended by the Alexa API docs, and in some
cases (locks, thermostats at least) the user will get an error "Hmm, $device is
not responding" if properties are not provided in the response.
* Fix setting temperature with Alexa thermostats
Fixes https://github.com/home-assistant/home-assistant/issues/16577
* Remove unit_of_measurement from climate base class.
* Updated google_assistant component and tests to use core temp units.
* Fixes
* Convert Alexa component to use core temp units for climate entities.
* Fix tests.
* Converted prometheus component.
* Remove unit_of_measurement from homekit thermostat tests.
* Small fix.
## Description:
More fixes flagged by pylint 2 that don't hurt to have before the actual pylint 2 upgrade (which I'll submit soon).
## Checklist:
- [ ] The code change is tested and works locally.
- [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
* Implement thermostat support for Alexa
* util.temperature: Support interval conversions
* Use climate.ATTR_OPERATION_MODE for Alexa thermostat mode
* Switch coroutines to async/await
* Log all Alexa error events
* Accept and report both xy and RGB color for lights
* Fix demo light supported_features
* Add new XY color util functions
* Always make color changes available as xy and RGB
* Always expose color as RGB and XY
* Consolidate color supported_features
* Test fixes
* Additional test fix
* Use hue/sat as the hass core color interface
* Tests updates
* Assume MQTT RGB devices need full RGB brightness
* Convert new platforms
* More migration
* Use float for HS API
* Fix backwards conversion for KNX lights
* Adjust limitless min saturation for new scale
It turns out I misunderstood which media_player services are available
when a media player supports StepVolume. This PR maps the Alexa
StepSpeaker messages to the volume_up and volume_down services.
Currently Alexa allows you to specify the number of steps but the media
player volume_up and volume_down services don't support this. For now I
just look to see if the steps are +/- and call up/down accordingly.
* Refactor Alexa Smart Home API
Having an object per interface will make it easier to support
properties.
Ideally, properties are reported in context in all responses. However
current implementation reports them only in response to a ReportState
request. This seems to work sufficiently. As long as the device is
opened in the Alexa app, Amazon will poll the device state every few
seconds with a ReportState request.
* Report properties for some Alexa interfaces
Fixes (mostly) #11874.
Other interfaces will need properties implemented as well.
Implementing properties for just PowerController seems sufficient to
eliminate the "There was a problem." error for any device that supports
it, even if other interfaces are supported. Of course the additional
properties will be reported incorrectly in the Alexa app.
Includes a minor bugfix: `reportable` was previously placed incorrectly
in the responses, so Amazon was ignoring it.
Having an object per interface will make it easier to support
properties.
Ideally, properties are reported in context in all responses. However
current implementation reports them only in response to a ReportState
request. This seems to work sufficiently. As long as the device is
opened in the Alexa app, Amazon will poll the device state every few
seconds with a ReportState request.
* Send Alexa Smart Home responses to debug log
* Report scripts and groups as scenes to Alexa
The Alexa API docs have a couple display categories that sound relevant
to scenes or scripts:
ACTIVITY_TRIGGER: Describes a combination of devices set to a
specific state, when the state change must occur in a specific
order. For example, a “watch Neflix” scene might require the: 1. TV
to be powered on & 2. Input set to HDMI1.
SCENE_TRIGGER: Describes a combination of devices set to a specific
state, when the order of the state change is not important. For
example a bedtime scene might include turning off lights and
lowering the thermostat, but the order is unimportant.
Additionally, Alexa has a notion of scenes that support deactivation.
This is a natural fit for groups, and scripts with delays which can be
cancelled.
https://developer.amazon.com/docs/device-apis/alexa-discovery.html#display-categories
The mechanism to map entities to the Alexa Discovery response is
refactored since extending the data structures in MAPPING_COMPONENT to
implement supportsDeactivation would have added complication to what I
already found to be a confusing construct.
* Expose Alexa Smart Home via HTTP POST
Haaska uses the deprecated v2 Alexa Smart Home payload. Exposing the v3
implementation this way allows an easy path to upgrading Haaska and
reducing code duplication with Home Assistant Cloud.
* Expose Alexa Smart Home via HTTP POST
Haaska uses the deprecated v2 Alexa Smart Home payload. Exposing the v3
implementation this way allows an easy path to upgrading Haaska and
reducing code duplication with Home Assistant Cloud.
* alexa: Add handling for covers
Covers don't support either cover.turn_on or homeassistant.turn_on so
use cover.[open|close]_cover.
* alexa: Add tests for covers
* Implement entity and domain exclude/include for Alexa
* Switch to using generate_filter
* Use proper domain for turn on/off calls except for groups where we must use the generic homeassistant.turn_on/off
* travis fixes
* Untangle
* Lint
* Initial scene support
* Initial fan support
* ordering
* Initial lock support
* Scenes cant be deactivated; Correct the scene display category
* Initial input_boolean support
* Support customization of Alexa discovered entities
* Initial media player support
* Add input_boolean to tests
* Add play/pause/stop/next/previous to media player
* Add missing functions and pylint
* Set manufacturerName to Home Assistant since the value is displayed in app
* Add scene test
* Add fan tests
* Add lock test
* Fix volume logic
* Add volume tests
* settup -> setup
* Remove unused variable
* Set required scene description as per docs
* Allow setting scene category (ACTIVITY_TRIGGER/SCENE_TRIGGER)
* Add alert, automation and group support/tests
* Change display categories to match docs
* simplify down the display category props into a single prop which can be used on any entity
* Fix tests to expect proper display categories
* Add cover support
* sort things
* Use generic homeassistant domain for turn on/off
* Added logic to the alexa component for handling slot synonyms
* Moved note with long url to the top of the file
* Just made a tiny url instead of messing with Flake8
* Refactored to be more Pythonic
* Put trailing comma back