aioamazondevices 1.5.0__py3-none-any.whl → 1.6.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 +38 -12
- {aioamazondevices-1.5.0.dist-info → aioamazondevices-1.6.0.dist-info}/METADATA +3 -3
- aioamazondevices-1.6.0.dist-info/RECORD +9 -0
- aioamazondevices-1.5.0.dist-info/RECORD +0 -9
- {aioamazondevices-1.5.0.dist-info → aioamazondevices-1.6.0.dist-info}/LICENSE +0 -0
- {aioamazondevices-1.5.0.dist-info → aioamazondevices-1.6.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,14 @@ 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
|
+
|
74
|
+
|
66
75
|
class AmazonEchoApi:
|
67
76
|
"""Queries Amazon for Echo devices."""
|
68
77
|
|
@@ -611,13 +620,17 @@ class AmazonEchoApi:
|
|
611
620
|
_LOGGER.warning("Trying to send message before login")
|
612
621
|
return
|
613
622
|
|
623
|
+
base_payload = {
|
624
|
+
"deviceType": device.device_type,
|
625
|
+
"deviceSerialNumber": device.serial_number,
|
626
|
+
"locale": locale,
|
627
|
+
"customerId": device.device_owner_customer_id,
|
628
|
+
}
|
629
|
+
|
614
630
|
payload: dict[str, Any]
|
615
|
-
if message_type ==
|
631
|
+
if message_type == AmazonSequenceType.Speak:
|
616
632
|
payload = {
|
617
|
-
|
618
|
-
"deviceSerialNumber": device.serial_number,
|
619
|
-
"locale": locale,
|
620
|
-
"customerId": device.device_owner_customer_id,
|
633
|
+
**base_payload,
|
621
634
|
"textToSpeak": message_body,
|
622
635
|
"target": {
|
623
636
|
"customerId": device.device_owner_customer_id,
|
@@ -630,7 +643,7 @@ class AmazonEchoApi:
|
|
630
643
|
},
|
631
644
|
"skillId": "amzn1.ask.1p.saysomething",
|
632
645
|
}
|
633
|
-
|
646
|
+
elif message_type == AmazonSequenceType.Announcement:
|
634
647
|
playback_devices: list[dict[str, str]] = [
|
635
648
|
{
|
636
649
|
"deviceSerialNumber": serial,
|
@@ -641,10 +654,7 @@ class AmazonEchoApi:
|
|
641
654
|
]
|
642
655
|
|
643
656
|
payload = {
|
644
|
-
|
645
|
-
"deviceSerialNumber": device.serial_number,
|
646
|
-
"locale": locale,
|
647
|
-
"customerId": device.device_owner_customer_id,
|
657
|
+
**base_payload,
|
648
658
|
"expireAfter": "PT5S",
|
649
659
|
"content": [
|
650
660
|
{
|
@@ -665,6 +675,12 @@ class AmazonEchoApi:
|
|
665
675
|
},
|
666
676
|
"skillId": "amzn1.ask.1p.routines.messaging",
|
667
677
|
}
|
678
|
+
elif message_type == AmazonSequenceType.Sound:
|
679
|
+
payload = {
|
680
|
+
**base_payload,
|
681
|
+
"soundStringId": message_body,
|
682
|
+
"skillId": "amzn1.ask.1p.sound",
|
683
|
+
}
|
668
684
|
|
669
685
|
sequence = {
|
670
686
|
"@type": "com.amazon.alexa.behaviors.model.Sequence",
|
@@ -702,7 +718,7 @@ class AmazonEchoApi:
|
|
702
718
|
message_body: str,
|
703
719
|
) -> None:
|
704
720
|
"""Call Alexa.Speak to send a message."""
|
705
|
-
return await self._send_message(device,
|
721
|
+
return await self._send_message(device, AmazonSequenceType.Speak, message_body)
|
706
722
|
|
707
723
|
async def call_alexa_announcement(
|
708
724
|
self,
|
@@ -710,4 +726,14 @@ class AmazonEchoApi:
|
|
710
726
|
message_body: str,
|
711
727
|
) -> None:
|
712
728
|
"""Call AlexaAnnouncement to send a message."""
|
713
|
-
return await self._send_message(
|
729
|
+
return await self._send_message(
|
730
|
+
device, AmazonSequenceType.Announcement, message_body
|
731
|
+
)
|
732
|
+
|
733
|
+
async def call_alexa_sound(
|
734
|
+
self,
|
735
|
+
device: AmazonDevice,
|
736
|
+
message_body: str,
|
737
|
+
) -> None:
|
738
|
+
"""Call Alexa.Sound to send a message."""
|
739
|
+
return await self._send_message(device, AmazonSequenceType.Sound, message_body)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: aioamazondevices
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.6.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=in_tNmEx7nOOujxGDPDDWw7DqPiabEzcb_EXOV0YM_M,276
|
2
|
+
aioamazondevices/api.py,sha256=9dwKJ31TIUIGDEXG7sdqIA3FFbhUWGHeocKmWci5PwM,26520
|
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.6.0.dist-info/LICENSE,sha256=sS48k5sp9bFV-NSHDfAJuTZZ_-AP9ZDqUzQ9sffGlsg,11346
|
7
|
+
aioamazondevices-1.6.0.dist-info/METADATA,sha256=DACE14_5WuvXM_qHui5Mk89TB4CSTwZdrmf5YDu7oW4,5010
|
8
|
+
aioamazondevices-1.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
9
|
+
aioamazondevices-1.6.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
|