aioamazondevices 1.5.0__py3-none-any.whl → 1.7.0__py3-none-any.whl
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.
- aioamazondevices/__init__.py +1 -1
- aioamazondevices/api.py +69 -13
- {aioamazondevices-1.5.0.dist-info → aioamazondevices-1.7.0.dist-info}/METADATA +3 -3
- aioamazondevices-1.7.0.dist-info/RECORD +9 -0
- aioamazondevices-1.5.0.dist-info/RECORD +0 -9
- {aioamazondevices-1.5.0.dist-info → aioamazondevices-1.7.0.dist-info}/LICENSE +0 -0
- {aioamazondevices-1.5.0.dist-info → aioamazondevices-1.7.0.dist-info}/WHEEL +0 -0
aioamazondevices/__init__.py
CHANGED
aioamazondevices/api.py
CHANGED
@@ -7,6 +7,7 @@ import secrets
|
|
7
7
|
import uuid
|
8
8
|
from dataclasses import dataclass
|
9
9
|
from datetime import UTC, datetime, timedelta
|
10
|
+
from enum import StrEnum
|
10
11
|
from http import HTTPStatus
|
11
12
|
from http.cookies import Morsel
|
12
13
|
from pathlib import Path
|
@@ -63,6 +64,22 @@ class AmazonDevice:
|
|
63
64
|
bluetooth_state: bool
|
64
65
|
|
65
66
|
|
67
|
+
class AmazonSequenceType(StrEnum):
|
68
|
+
"""Amazon sequence types."""
|
69
|
+
|
70
|
+
Announcement = "AlexaAnnouncement"
|
71
|
+
Speak = "Alexa.Speak"
|
72
|
+
Sound = "Alexa.Sound"
|
73
|
+
Music = "Alexa.Music.PlaySearchPhrase"
|
74
|
+
|
75
|
+
|
76
|
+
class AmazonMusicSource(StrEnum):
|
77
|
+
"""Amazon music sources."""
|
78
|
+
|
79
|
+
Radio = "TUNEIN"
|
80
|
+
AmazonMusic = "AMAZON_MUSIC"
|
81
|
+
|
82
|
+
|
66
83
|
class AmazonEchoApi:
|
67
84
|
"""Queries Amazon for Echo devices."""
|
68
85
|
|
@@ -601,7 +618,11 @@ class AmazonEchoApi:
|
|
601
618
|
return bool(authenticated)
|
602
619
|
|
603
620
|
async def _send_message(
|
604
|
-
self,
|
621
|
+
self,
|
622
|
+
device: AmazonDevice,
|
623
|
+
message_type: str,
|
624
|
+
message_body: str,
|
625
|
+
message_source: AmazonMusicSource | None = None,
|
605
626
|
) -> None:
|
606
627
|
"""Send message to specific device."""
|
607
628
|
locale_data = Locale.parse(f"und_{self._login_country_code}")
|
@@ -611,13 +632,17 @@ class AmazonEchoApi:
|
|
611
632
|
_LOGGER.warning("Trying to send message before login")
|
612
633
|
return
|
613
634
|
|
635
|
+
base_payload = {
|
636
|
+
"deviceType": device.device_type,
|
637
|
+
"deviceSerialNumber": device.serial_number,
|
638
|
+
"locale": locale,
|
639
|
+
"customerId": device.device_owner_customer_id,
|
640
|
+
}
|
641
|
+
|
614
642
|
payload: dict[str, Any]
|
615
|
-
if message_type ==
|
643
|
+
if message_type == AmazonSequenceType.Speak:
|
616
644
|
payload = {
|
617
|
-
|
618
|
-
"deviceSerialNumber": device.serial_number,
|
619
|
-
"locale": locale,
|
620
|
-
"customerId": device.device_owner_customer_id,
|
645
|
+
**base_payload,
|
621
646
|
"textToSpeak": message_body,
|
622
647
|
"target": {
|
623
648
|
"customerId": device.device_owner_customer_id,
|
@@ -630,7 +655,7 @@ class AmazonEchoApi:
|
|
630
655
|
},
|
631
656
|
"skillId": "amzn1.ask.1p.saysomething",
|
632
657
|
}
|
633
|
-
|
658
|
+
elif message_type == AmazonSequenceType.Announcement:
|
634
659
|
playback_devices: list[dict[str, str]] = [
|
635
660
|
{
|
636
661
|
"deviceSerialNumber": serial,
|
@@ -641,10 +666,7 @@ class AmazonEchoApi:
|
|
641
666
|
]
|
642
667
|
|
643
668
|
payload = {
|
644
|
-
|
645
|
-
"deviceSerialNumber": device.serial_number,
|
646
|
-
"locale": locale,
|
647
|
-
"customerId": device.device_owner_customer_id,
|
669
|
+
**base_payload,
|
648
670
|
"expireAfter": "PT5S",
|
649
671
|
"content": [
|
650
672
|
{
|
@@ -665,6 +687,19 @@ class AmazonEchoApi:
|
|
665
687
|
},
|
666
688
|
"skillId": "amzn1.ask.1p.routines.messaging",
|
667
689
|
}
|
690
|
+
elif message_type == AmazonSequenceType.Sound:
|
691
|
+
payload = {
|
692
|
+
**base_payload,
|
693
|
+
"soundStringId": message_body,
|
694
|
+
"skillId": "amzn1.ask.1p.sound",
|
695
|
+
}
|
696
|
+
elif message_type == AmazonSequenceType.Music:
|
697
|
+
payload = {
|
698
|
+
**base_payload,
|
699
|
+
"searchPhrase": message_body,
|
700
|
+
"sanitizedSearchPhrase": message_body,
|
701
|
+
"musicProviderId": message_source,
|
702
|
+
}
|
668
703
|
|
669
704
|
sequence = {
|
670
705
|
"@type": "com.amazon.alexa.behaviors.model.Sequence",
|
@@ -702,7 +737,7 @@ class AmazonEchoApi:
|
|
702
737
|
message_body: str,
|
703
738
|
) -> None:
|
704
739
|
"""Call Alexa.Speak to send a message."""
|
705
|
-
return await self._send_message(device,
|
740
|
+
return await self._send_message(device, AmazonSequenceType.Speak, message_body)
|
706
741
|
|
707
742
|
async def call_alexa_announcement(
|
708
743
|
self,
|
@@ -710,4 +745,25 @@ class AmazonEchoApi:
|
|
710
745
|
message_body: str,
|
711
746
|
) -> None:
|
712
747
|
"""Call AlexaAnnouncement to send a message."""
|
713
|
-
return await self._send_message(
|
748
|
+
return await self._send_message(
|
749
|
+
device, AmazonSequenceType.Announcement, message_body
|
750
|
+
)
|
751
|
+
|
752
|
+
async def call_alexa_sound(
|
753
|
+
self,
|
754
|
+
device: AmazonDevice,
|
755
|
+
message_body: str,
|
756
|
+
) -> None:
|
757
|
+
"""Call Alexa.Sound to play sound."""
|
758
|
+
return await self._send_message(device, AmazonSequenceType.Sound, message_body)
|
759
|
+
|
760
|
+
async def call_alexa_music(
|
761
|
+
self,
|
762
|
+
device: AmazonDevice,
|
763
|
+
message_body: str,
|
764
|
+
message_source: AmazonMusicSource,
|
765
|
+
) -> None:
|
766
|
+
"""Call Alexa.Music.PlaySearchPhrase to play music."""
|
767
|
+
return await self._send_message(
|
768
|
+
device, AmazonSequenceType.Music, message_body, message_source
|
769
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: aioamazondevices
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.7.0
|
4
4
|
Summary: Python library to control Amazon devices
|
5
5
|
License: Apache-2.0
|
6
6
|
Author: Simone Chemelli
|
@@ -82,8 +82,8 @@ The script accept command line arguments or a library_test.json config file:
|
|
82
82
|
"country": "IT",
|
83
83
|
"email": "<my_address@gmail.com>",
|
84
84
|
"password": "<my_password>",
|
85
|
-
"
|
86
|
-
"
|
85
|
+
"single_device_name": "Echo Dot Livingroom",
|
86
|
+
"cluster_device_name": "Everywhere",
|
87
87
|
"login_data_file": "out/login_data.json",
|
88
88
|
"save_raw_data": "True"
|
89
89
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
aioamazondevices/__init__.py,sha256=L4W0ORfkNA0DX8VpSFxeXgqh0SCV-FEGz1MGVY5suBc,276
|
2
|
+
aioamazondevices/api.py,sha256=MqUfScgFXiD26AOSZfpKPN78xysmOkq7g-p2KutN9vs,27392
|
3
|
+
aioamazondevices/const.py,sha256=6BBEg_q2BkYVYJcz3hMrLNyEwOJBWziPSStMzftWQLg,2106
|
4
|
+
aioamazondevices/exceptions.py,sha256=qK_Hak9pc-lC2FPW-0i4rYIwNpEOHMmA9Rii8F2lkQo,1260
|
5
|
+
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
aioamazondevices-1.7.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
7
|
+
aioamazondevices-1.7.0.dist-info/METADATA,sha256=dxCWOsgRGz6qydT8btCfigvN9DZeYHkOvgmB5mRdbO8,5010
|
8
|
+
aioamazondevices-1.7.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
9
|
+
aioamazondevices-1.7.0.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
aioamazondevices/__init__.py,sha256=c7Bi99W-tVQoCNwjK33ROJQCAZG1GcwSjaCvz9kMOwM,276
|
2
|
-
aioamazondevices/api.py,sha256=_4kojHD_86milDMLrbVscHgNg9nerq8mE6k7xOXOAeE,25874
|
3
|
-
aioamazondevices/const.py,sha256=6BBEg_q2BkYVYJcz3hMrLNyEwOJBWziPSStMzftWQLg,2106
|
4
|
-
aioamazondevices/exceptions.py,sha256=qK_Hak9pc-lC2FPW-0i4rYIwNpEOHMmA9Rii8F2lkQo,1260
|
5
|
-
aioamazondevices/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
aioamazondevices-1.5.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
7
|
-
aioamazondevices-1.5.0.dist-info/METADATA,sha256=m03j63zvtCHK_AWQbVBSaUsB5yRhlZTSWVPtZ389xdo,5014
|
8
|
-
aioamazondevices-1.5.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
9
|
-
aioamazondevices-1.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|