aioamazondevices 1.6.0__tar.gz → 1.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aioamazondevices
3
- Version: 1.6.0
3
+ Version: 1.8.0
4
4
  Summary: Python library to control Amazon devices
5
5
  License: Apache-2.0
6
6
  Author: Simone Chemelli
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "aioamazondevices"
3
- version = "1.6.0"
3
+ version = "1.8.0"
4
4
  description = "Python library to control Amazon devices"
5
5
  authors = ["Simone Chemelli <simone.chemelli@gmail.com>"]
6
6
  license = "Apache-2.0"
@@ -1,6 +1,6 @@
1
1
  """aioamazondevices library."""
2
2
 
3
- __version__ = "1.6.0"
3
+ __version__ = "1.8.0"
4
4
 
5
5
 
6
6
  from .api import AmazonDevice, AmazonEchoApi
@@ -70,6 +70,15 @@ class AmazonSequenceType(StrEnum):
70
70
  Announcement = "AlexaAnnouncement"
71
71
  Speak = "Alexa.Speak"
72
72
  Sound = "Alexa.Sound"
73
+ Music = "Alexa.Music.PlaySearchPhrase"
74
+ TextCommand = "Alexa.TextCommand"
75
+
76
+
77
+ class AmazonMusicSource(StrEnum):
78
+ """Amazon music sources."""
79
+
80
+ Radio = "TUNEIN"
81
+ AmazonMusic = "AMAZON_MUSIC"
73
82
 
74
83
 
75
84
  class AmazonEchoApi:
@@ -610,7 +619,11 @@ class AmazonEchoApi:
610
619
  return bool(authenticated)
611
620
 
612
621
  async def _send_message(
613
- self, device: AmazonDevice, message_type: str, message_body: str
622
+ self,
623
+ device: AmazonDevice,
624
+ message_type: str,
625
+ message_body: str,
626
+ message_source: AmazonMusicSource | None = None,
614
627
  ) -> None:
615
628
  """Send message to specific device."""
616
629
  locale_data = Locale.parse(f"und_{self._login_country_code}")
@@ -681,6 +694,19 @@ class AmazonEchoApi:
681
694
  "soundStringId": message_body,
682
695
  "skillId": "amzn1.ask.1p.sound",
683
696
  }
697
+ elif message_type == AmazonSequenceType.Music:
698
+ payload = {
699
+ **base_payload,
700
+ "searchPhrase": message_body,
701
+ "sanitizedSearchPhrase": message_body,
702
+ "musicProviderId": message_source,
703
+ }
704
+ elif message_type == AmazonSequenceType.TextCommand:
705
+ payload = {
706
+ **base_payload,
707
+ "skillId": "amzn1.ask.1p.tellalexa",
708
+ "text": message_body,
709
+ }
684
710
 
685
711
  sequence = {
686
712
  "@type": "com.amazon.alexa.behaviors.model.Sequence",
@@ -735,5 +761,26 @@ class AmazonEchoApi:
735
761
  device: AmazonDevice,
736
762
  message_body: str,
737
763
  ) -> None:
738
- """Call Alexa.Sound to send a message."""
764
+ """Call Alexa.Sound to play sound."""
739
765
  return await self._send_message(device, AmazonSequenceType.Sound, message_body)
766
+
767
+ async def call_alexa_music(
768
+ self,
769
+ device: AmazonDevice,
770
+ message_body: str,
771
+ message_source: AmazonMusicSource,
772
+ ) -> None:
773
+ """Call Alexa.Music.PlaySearchPhrase to play music."""
774
+ return await self._send_message(
775
+ device, AmazonSequenceType.Music, message_body, message_source
776
+ )
777
+
778
+ async def call_alexa_text_command(
779
+ self,
780
+ device: AmazonDevice,
781
+ message_body: str,
782
+ ) -> None:
783
+ """Call Alexa.Sound to play sound."""
784
+ return await self._send_message(
785
+ device, AmazonSequenceType.TextCommand, message_body
786
+ )