Add alexa check for "name" channelMetadata attribute (#29279)

* 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
pull/29341/head
Alain Turbide 2019-12-02 19:10:44 -05:00 committed by Paulus Schoutsen
parent 9811d63d78
commit 83b21651ce
2 changed files with 29 additions and 13 deletions

View File

@ -1144,21 +1144,25 @@ async def async_api_changechannel(hass, config, directive, context):
"""Process a change channel request."""
channel = "0"
entity = directive.entity
payload = directive.payload["channel"]
channel_payload = directive.payload["channel"]
metadata_payload = directive.payload["channelMetadata"]
payload_name = "number"
if "number" in payload:
channel = payload["number"]
if "number" in channel_payload:
channel = channel_payload["number"]
payload_name = "number"
elif "callSign" in payload:
channel = payload["callSign"]
elif "callSign" in channel_payload:
channel = channel_payload["callSign"]
payload_name = "callSign"
elif "affiliateCallSign" in payload:
channel = payload["affiliateCallSign"]
elif "affiliateCallSign" in channel_payload:
channel = channel_payload["affiliateCallSign"]
payload_name = "affiliateCallSign"
elif "uri" in payload:
channel = payload["uri"]
elif "uri" in channel_payload:
channel = channel_payload["uri"]
payload_name = "uri"
elif "name" in metadata_payload:
channel = metadata_payload["name"]
payload_name = "callSign"
data = {
ATTR_ENTITY_ID: entity.entity_id,

View File

@ -935,7 +935,7 @@ async def test_media_player(hass):
"media_player#test",
"media_player.play_media",
hass,
payload={"channel": {"number": 24}},
payload={"channel": {"number": "24"}, "channelMetadata": {"name": ""}},
)
call, _ = await assert_request_calls_service(
@ -944,7 +944,7 @@ async def test_media_player(hass):
"media_player#test",
"media_player.play_media",
hass,
payload={"channel": {"callSign": "ABC"}},
payload={"channel": {"callSign": "ABC"}, "channelMetadata": {"name": ""}},
)
call, _ = await assert_request_calls_service(
@ -953,7 +953,7 @@ async def test_media_player(hass):
"media_player#test",
"media_player.play_media",
hass,
payload={"channel": {"affiliateCallSign": "ABC"}},
payload={"channel": {"number": ""}, "channelMetadata": {"name": "ABC"}},
)
call, _ = await assert_request_calls_service(
@ -962,7 +962,19 @@ async def test_media_player(hass):
"media_player#test",
"media_player.play_media",
hass,
payload={"channel": {"uri": "ABC"}},
payload={
"channel": {"affiliateCallSign": "ABC"},
"channelMetadata": {"name": ""},
},
)
call, _ = await assert_request_calls_service(
"Alexa.ChannelController",
"ChangeChannel",
"media_player#test",
"media_player.play_media",
hass,
payload={"channel": {"uri": "ABC"}, "channelMetadata": {"name": ""}},
)
call, _ = await assert_request_calls_service(