2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 16:05:19 +00:00

37_echodevice.pm: bugfixing voice_reading

git-svn-id: https://svn.fhem.de/fhem/trunk@28425 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
michael.winkler 2024-01-26 16:31:37 +00:00
parent 5ad75b7487
commit 27e93bab08

View File

@ -2,6 +2,9 @@
# #
############################################## ##############################################
# #
# 2024.01.26 v0.2.30
# - CHANGE: voice_reading auf neue API umgestellt
#
# 2023.11.15 v0.2.29 # 2023.11.15 v0.2.29
# - FEATURE: Unterstützung A1D6RDUOWH31HF JLR Incontrol # - FEATURE: Unterstützung A1D6RDUOWH31HF JLR Incontrol
# #
@ -530,7 +533,7 @@ use lib ('./FHEM/lib', './lib');
use MP3::Info; use MP3::Info;
use MIME::Base64; use MIME::Base64;
my $ModulVersion = "0.2.29"; my $ModulVersion = "0.2.30";
my $AWSPythonVersion = "0.0.3"; my $AWSPythonVersion = "0.0.3";
my $NPMLoginTyp = "unbekannt"; my $NPMLoginTyp = "unbekannt";
my $QueueNumber = 0; my $QueueNumber = 0;
@ -1776,11 +1779,18 @@ sub echodevice_SendCommand($$$) {
} }
elsif ($type eq "activities") { elsif ($type eq "activities") {
$SendUrl = "https://www.amazon.de/alexa-privacy/apd/rvh/customer-history-records/?startTime=0&endTime=2005090388459&recordType=VOICE_HISTORY&maxRecordSize=100"; #$SendUrl = "https://www.amazon.de/alexa-privacy/apd/rvh/customer-history-records/?startTime=0&endTime=2005090388459&recordType=VOICE_HISTORY&maxRecordSize=100";
$SendUrl = "https://www.amazon.de/alexa-privacy/apd/rvh/customer-history-records-v2/?startTime=0&endTime=2005090388459&pageType=VOICE_HISTORY";
$SendMetode = "POST";
$SendDataL = '{"previousRequestToken": null}';
$SendData = '{"previousRequestToken": null}';
}
elsif ($type eq "csrfPageUrl") {
$SendUrl = "https://www.amazon.de/alexa-privacy/apd/activity?ref=activityHistory";
$SendMetode = "GET"; $SendMetode = "GET";
$SendDataL = "" ; $SendDataL = "" ;
$SendData = ""; $SendData = "";
} }
elsif ($type eq "activities1") { elsif ($type eq "activities1") {
@ -2219,6 +2229,16 @@ sub echodevice_SendCommand($$$) {
$SendDataL = $SendData; $SendDataL = $SendData;
} }
elsif ($type eq "getsmarthome" ) {
$SendUrl .= "/api/phoenix/state";
$SendMetode = "POST";
$SendData = '{"stateRequests":[{"entityId":"AlexaBridge_'.$hash->{helper}{".SERIAL"}.'@'.$hash->{helper}{DEVICETYPE}.'_'.$hash->{helper}{".SERIAL"}.'","entityType": "APPLIANCE"}]}';
$SendDataL = $SendData;
}
else { else {
return; return;
} }
@ -2292,7 +2312,7 @@ sub echodevice_HandleCmdQueue($) {
# if($hash->{model} eq "ACCOUNT") {$AmazonHeader = "Cookie: ".$hash->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";} # if($hash->{model} eq "ACCOUNT") {$AmazonHeader = "Cookie: ".$hash->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";}
# else {$AmazonHeader = "Cookie: ".$hash->{IODev}->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{IODev}->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";} # else {$AmazonHeader = "Cookie: ".$hash->{IODev}->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{IODev}->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";}
if($hash->{model} eq "ACCOUNT") {$AmazonHeader = "User-Agent: ". $UserAgent ."\r\nAccept-Language: " . $HeaderLanguage . "\r\nDNT: 1\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nCookie:".$hash->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";} if($hash->{model} eq "ACCOUNT") {$AmazonHeader = "User-Agent: ". $UserAgent ."\r\nAccept-Language: " . $HeaderLanguage ."\r\nanti-csrftoken-a2z: " . ReadingsVal($name ,'csrf-token',"") . "\r\nDNT: 1\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nCookie:".$hash->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";}
else {$AmazonHeader = "User-Agent: ". $UserAgent ."\r\nAccept-Language: " . $HeaderLanguage . "\r\nDNT: 1\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nCookie:".$hash->{IODev}->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{IODev}->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";} else {$AmazonHeader = "User-Agent: ". $UserAgent ."\r\nAccept-Language: " . $HeaderLanguage . "\r\nDNT: 1\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nCookie:".$hash->{IODev}->{helper}{".COOKIE"}."\r\ncsrf: ".$hash->{IODev}->{helper}{".CSRF"}."\r\nContent-Type: application/json; charset=UTF-8";}
if(not($hash->{helper}{RUNNING_REQUEST}) and @{$hash->{helper}{CMD_QUEUE}}) if(not($hash->{helper}{RUNNING_REQUEST}) and @{$hash->{helper}{CMD_QUEUE}})
@ -2582,6 +2602,22 @@ sub echodevice_Parse($$$) {
close(FH); close(FH);
} }
if ($msgtype eq "csrfPageUrl") {
Log3 $name, 3, "[$name] [echodevice_Parse] [$msgtype] search csrf-token";
readingsBeginUpdate($hash);
my $regex = qr/meta name="csrf-token" content="([^"]+)"/;
while ($data =~ /$regex/g) {
my $csrf_token = $1;
readingsBulkUpdate($hash, ".csrf-token", $1, 1);
}
readingsEndUpdate($hash,1);
}
# COOKIE LOGIN Part # COOKIE LOGIN Part
if($msgtype eq "cookielogin1") { if($msgtype eq "cookielogin1") {
@ -4177,6 +4213,7 @@ sub echodevice_GetSettings($) {
if ($ConnectState eq "connected") { if ($ConnectState eq "connected") {
if($hash->{model} eq "ACCOUNT") { if($hash->{model} eq "ACCOUNT") {
echodevice_SendCommand($hash,"csrfPageUrl","");
echodevice_SendCommand($hash,"endpoints",""); echodevice_SendCommand($hash,"endpoints","");
echodevice_SendCommand($hash,"getnotifications",""); echodevice_SendCommand($hash,"getnotifications","");
echodevice_SendCommand($hash,"alarmvolume",""); echodevice_SendCommand($hash,"alarmvolume","");
@ -4244,6 +4281,7 @@ sub echodevice_GetSettings($) {
if ($hash->{IODev}{STATE} eq "connected") { if ($hash->{IODev}{STATE} eq "connected") {
echodevice_SendCommand($hash,"player",""); echodevice_SendCommand($hash,"player","");
echodevice_SendCommand($hash,"media",""); echodevice_SendCommand($hash,"media","");
echodevice_SendCommand($hash,"getsmarthome","");
} }
else { else {
$nextupdate = 10; $nextupdate = 10;