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" fieldpull/29341/head
parent
9811d63d78
commit
83b21651ce
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue