-
Notifications
You must be signed in to change notification settings - Fork 126
/
37_echodevice.pm
6006 lines (5000 loc) · 258 KB
/
37_echodevice.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# $Id$
#
##############################################
#
# 2024.01.26 v0.2.30
# - CHANGE: voice_reading auf neue API umgestellt
# - FEATURE: Unterstützung A2UONLFQW0PADH Echo Show 8 Gen3
#
# 2023.11.15 v0.2.29
# - FEATURE: Unterstützung A1D6RDUOWH31HF JLR Incontrol
#
# 2023.11.12 v0.2.28
# - FEATURE: Unterstützung A347N36W21919O Yamaha ATS-2090 Soundbar
#
# 2023.11.10 v0.2.27
# - FEATURE: Unterstützung A1WZKXFLI43K86 Fire TV Stick 4K Max
# Unterstützung A11QM4H9HGV71H Echo Show 5
# - CHANGE: Verbose Settings für HttpUtils
#
# 2023.11.08 v0.2.26
# - BUG: User-Agent https://forum.fhem.de/index.php?topic=82631.msg1292057#msg1292057
#
# 2023.10.31 v0.2.25
# - FEATURE: Unterstützung ASQZWP4GPYUT7 Echo Plus 2 Gen2
#
# 2023.10.31 v0.2.24
# - CHANGE: voice_reading TTS Antworten rausfiltern
#
# 2023.10.27 v0.2.23
# - BUG: Logeinträge bei set "speak" entfernt
#
# 2023.10.27 v0.2.22
# - CHANGE: voice_reading auf neue API umgestellt
# - FEATURE voice_person (Zeigt wer das letzte Voice Command gesagt hat, wenn eingerichtet)
#
# 2023.01.19 v0.2.21
# - BUG: Refresh Token
# Attribut "fhem_home"
# - FEATURE Neues Reading "parse_error"
#
# 2022.11.22 v0.2.20
# - FEATURE: Unterstützung A4ZXE0RM7LQ7A Echo Dot Gen5
#
# 2022.11.21 v0.2.19
# - BUG: Auswertung FHEM Verzeichnis Attribut "fhem_home" eingeführt Standardwert = "/opt/fhem"
#
# 2022.11.21 v0.2.18
# - FEATURE: Unterstützung A2DS1Q2TPDJ48U Echo Dot Gen5 with Clock
# Unterstützung AQCGW9PSYWRF Polk React Soundbar
# Unterstützung A1VGB7MHSIEYFK Fire TV Cube Gen3
#
# 2022.11.14 v0.2.17
# - FEATURE: Unterstützung A1EIANJ7PNB0Q7 Echo Show 15
#
# 2022.09.12 v0.2.16
# - BUG: Activities Result "DISCARDED_NON_DEVICE_DIRECTED_INTENT" entfernt
#
# 2022.01.12 v0.2.15
# - FEATURE: Unterstützung A2Z8O30CD35N8F Sonos Arc
# Unterstützung A3EVMLQTU6WL1W Fire TV Stick 4K Max
# Unterstützung A39Y3UG1XLEJLZ Fitbit Sense
# Unterstützung A1XWJRHALS1REP Echo Show 5 2. Generation
#
# 2021.10.19 v0.2.14
# - BUG: https://forum.fhem.de/index.php/topic,82631.msg1175268.html#msg1175268 (Danke Benutzer JudgeDredd)
# - FEATURE: Unterstützung A31DTMEEVDDOIV FireTV Stick
#
# 2021.09.15 v0.2.13
# - CHANGE: Probleme set tunein (Danke Benutzer adn77)
#
# 2021.06.24 v0.2.12
# - FEATURE: Unterstützung A15996VY63BQ2D Echo Show 8 Gen2
# Unterstützung A2WFDCBDEXOXR8 Bose Soundbar 700
#
# 2021.05.18 v0.2.11
# - FEATURE: Unterstützung A1DL2DVDQVK3Q Fire Tab HD 10
#
# 2021.04.26 v0.2.10
# - CHANGE: Logeintrag "[Echodevice] [echodevice_SendCommand] [12] IGNORIERE Command=activities Abfrage in CMD_Queue schon vorhanden!" auf Loglevel 4 geändert
# - FEATURE: Unterstützung AIPK7MM90V7TB Echo Show Gen3
#
# 2021.02.10 v0.2.9
# - BUG: Probleme wenn getbehavior keine Antwort liefert.
# - CHANGE: CMD_Queue check
# ($hash->{model} eq "Reverb" || $hash->{model} eq "Sonos One" || $hash->{model} eq "Sonos Beam" Unterscheidung entfernt
# - FEATURE: Geräte Kennung THIRD_PARTY_AVS_SONOS_BOOTLEG hinzugefügt
#
# 2021.02.07 v0.2.8
# - BUG: Sonso aktualisiert keine voice Readings
#
# 2021.01.28 v0.2.7
# - BUG: Routinen werden nicht mehr angezeigt
#
# 2021.01.18 v0.2.6
# - BUG: item_shopping_delete,item_shopping_add,item_task_delete,item_task.add
# - FEATURE: Unterstützung A23FPV4BT7FH68 Yamaha YAS-209 Soundbar
# Untersützung A265XOI9586NML Fire TV Stick 4K
#
# 2020.12.11 v0.2.5
# - FEATURE: Text Kommando an Amazon schicken "set textcommand"
# Unterstützung A2WN1FJ2HG09UN Ultimate Alexa
#
# 2020.11.19 v0.2.4
# - CHANGE: get custom-history-records Dialog angepasst
# - FEATURE: Unterstützung A2U21SRK4QGSE1 Echo Dot Gen4
#
# 2020.11.18 v0.2.3
# - FEATURE: get custom-history-records
# Unterstützung A2H4LV5GIZ1JFT Echo Dot Gen4 with Clock
# Unterstützung AVE5HX13UR5NO Zero Touch (Logitech)
# Unterstützung A3GZUE7F9MEB4U Sony WH-100XM3
# Unterstützung A2J0R2SD7G9LPA Lenovo P10
# Unterstützung A1J16TEDOYCZTN Amazon Tablet
# Unterstützung A38EHHIB10L47V Fire HD 8 Tablet
# Unterstützung A112LJ20W14H95 Media Display
# Unterstützung A1H0CMF1XM0ZP4 Bose Soundtouch
# Unterstützung AAMFMBBEW2960 Garmin DriveSmart 65 with Amazon Alexa
# Unterstützung A2IVLV5VM2W81 Mobile Voice iOS";}
# Unterstützung A2TF17PFR55MTB Mobile Voice Android
# Unterstützung A3V3VA38K169FO Fire Tablet
# Unterstützung AVD3HM0HOJAAL Sonos One
# Unterstützung A1C66CX2XD756O Fire HD 8 Tablet
# Unterstützung A17LGWINFBUTZZ Anker Roav Car Charger
# Unterstützung A2XPGY5LRKB9BE FitBit watch
# Unterstützung A2Y04QPFCANLPQ Bose QC35 II
# Unterstützung A3BW5ZVFHRCQPO Alexa Car
# Unterstützung A303PJF6ISQ7IC Echo Auto
# Unterstützung A1ZB65LA390I4K Fire HD 10 Tablet
# Unterstützung AVU7CPPF2ZRAS Fire HD 8 Plus (2020)
# Unterstützung A24Z7PEXY4MDTK Sony WF-1000X
# Unterstützung ABN8JEI7OQF61 Sony WF-1000XM3
# Unterstützung A7S41FQ5TWBC9 Sony WH-1000XM4
#
# 2020.11.06 v0.2.2
# - FEATURE: Unterstützung A3RMGO6LYLH7YN Echo Dot Gen4
#
# 2020.10.07 v0.2.1
# - BUG: Not a HASH reference at ./FHEM/37_echodevice.pm line 2975
#
# 2020.10.05 v0.2.0
# - BUG: Not a HASH reference at ./FHEM/37_echodevice.pm line 3532
#
# 2020.09.25 v0.1.9
# - BUG: Not a HASH reference at ./FHEM/37_echodevice.pm line 2687
#
# 2020.05.06 v0.1.8
# - BUG: Zu viele Loginfos bei set "NPM_login refresh"
#
# 2020.04.27 v0.1.7
# - FEATURE: Unterstützung A1WAR447VT003J Yamaha MusicCast 20
# - BUG: set "NPM_login refresh"
# - CHANGE: get status erweitert
#
# 2020.04.22 v0.1.5
# - CHANGE: Mehr Loginfos bei set "NPM_login refresh"
#
# 2020.04.20 v0.1.4
# - CHANGE: Keepalive aktiviert (cookielogin6)
#
# 2020.04.14 v0.1.3
# - CHANGE: Mehr Loginfos bei set "NPM_login new"
#
# 2020.04.12 v0.1.2
# - CHANGE: Mehr Loginfos bei set "NPM_login new"
#
# 2020.04.08 v0.1.1
# - CHANGE: Keepalive aktiviert
# - BUG: set "NPM_login new"
# - FEATURE: Unterstützung A3RBAYBE7VM004 ECHO Studio
# Unterstützung A3SSG6GR8UU7SN ECHO SUB
# Unterstützung A1HNT9YTOBE735 Telekom Smart Speaker
# set sounds: (Sounds gemäß Routine-Übersicht)
#
# 2019.12.24 v0.1.0
# - FEATURE: Unterstützung A1Z88NGR2BK6A2 ECHO Show 8
# Unterstützung A2JKHJ0PX4J3L3 ECHO FireTv Cube 4K
#
# 2019.12.22 v0.0.60
# - FEATURE: Unterstützung A3VRME03NAXFUB ECHO Flex
# Unterstützung AKOAGQTKAS9YB ECHO Connect
# Unterstützung A3NTO4JLV9QWRB Gigaset L800HX
#
# 2019.11.05 v0.0.59
# - FEATURE: Nachricht an Handy App schicken "set mobilmessage"
# - CHANGE: Hilfetexte erweitert
#
# 2019.10.27 v0.0.58
# - FEATURE: Unterstützung A30YDR2MK8HMRV ECHO Gen 3
#
# 2019.10.17 v0.0.57
# - FEATURE: Unterstützung A3FX4UWTP28V1P ECHO Gen 3
#
# 2019.10.09 v0.0.56
# - FEATURE: Hintergrundbild ECHO SHOW ändern "set homescreen"
#
# 2019.09.20 v0.0.55
# - CHANGE: speak_volume Auswertung Account-Device/Echo-Device
# DEF xxx@xxx.de xxx = NPM Login Modus
# - BUGFIX: presence
#
# 2019.07.22 v0.0.54
# - FEATURE: Unterstützung A1RABVCI4QCIKC ECHO dot 3
#
# 2019.02.19 v0.0.53
# - FEATURE: Unterstützung A4ZP7ZC4PI6TO ECHO 5
# Unterstützung A1RTAM01W29CUP Alexa App for PC
# Unterstützung A21Z3CGI8UIP0F HEOS
#
# 2019.02.19 v0.0.52
# - FEATURE: Alarme "_originalDate" als Reading
# - BUGFIX: Readings *_count Wert
#
# 2019.02.18 v0.0.51z
# - BUGFIX: NPM Proxy IP Adresse / Port usw.
# set routine_play - Unterstützung Smart Home Geräte
# set speak - Sonderzeichen " entfernen
# get conversations https://forum.fhem.de/index.php/topic,82631.msg903955.html#msg903955
# Bluetooth Geräte bereinigen
# - FEATURE: Unterstützung AppRegisterLogin per NPM
# Unterstützung A10L5JEZTKKCZ8 VOBOT
# Unterstützung A1JJ0KFC4ZPNJ3 ECHO Input
# Unterstützung AKPGW064GI9HE Fire TV Stick 4K
# Unterstützung A37SHHQ3NUL7B5 Bose Home Speaker 500
# Unterstützung AVN2TMX8MU2YM Bose Home Speaker 500
# set speak_ssml https://docs.aws.amazon.com/polly/latest/dg/supported-ssml.html
# https://developer.amazon.com/de/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html
# get status - Statusinformationen zum Modul
# Attribut "ignorevoicecommand" https://forum.fhem.de/index.php/topic,82631.msg906424.html#msg906424
# Alarme "_recurringPattern" als Reading
# - CHANGE: https://forum.fhem.de/index.php/topic,82631.msg869460.html#msg869460
#
# 2018.12.02 v0.0.50
# - FEATURE: Unterstützung A32DDESGESSHZA Echo Dot Gen3
#
# 2018.11.13 v0.0.49
# - BUGFIX: reading voice
# Sonos Beam A3NPD82ABCPIDP
# - FEATURE: reading voice_timestamp
#
# 2018.10.30 v0.0.48i
# - CHANGE: Attribut browser_useragent_random (Standard=0)
# Neuer Status "connected but loginerror"
# - BUGFIX: https://forum.fhem.de/index.php/topic,82631.msg850171.html#msg850171
# CMD_QUEUE leeren wenn loginerror
# set loginwithcaptcha
# - FEATURE: Unterstützung A3R9S4ZZECZ6YL Fire Tab HD 10
# Unterstützung A3L0T0VL9A921N Fire Tab HD 8
# Unterstützung A2M4YX06LWP8WI Fire Tab 7
# Unterstützung A2E0SNTXJVT7WK Fire TV V1
# Unterstützung A2GFL5ZMWNE0PX Fire TV
# Unterstützung A12GXV8XMS007S Fire TV
# Unterstützung A3HF4YRA2L7XGC Fire TV Cube
# Unterstützung ADVBD696BHNV5 Fire TV Stick V1
# Unterstützung A2LWARUGJLBYEW Fire TV Stick V2
# Unterstützung AP1F6KUH00XPV ECHO Stereopaar
#
# 2018.10.25 v0.0.47
# - FEATURE: Unterstützung neuer Sonos Beam A15ERDAKK5HQQG
# - BUGFIX: browser_language default = de,en-US;q=0.7,en;q=0.3
# browser_useragent default = Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
#
# 2018.10.17 v0.0.46b
# - BUGFIX: Attribut intervalvoice 0=realtime bis 100 Sekunden
# - FEATURE: Reading "bluetooth_MAC-Adresse" zeigt Connected Status an (ECHO Device)
# Readings "config_address_from","config_address_to" und "config_address_between" (Account Device)
# Unterstützung neuer ECHO Show Gen2 AWZZ5CVHX2CD
# Unterstützung neuer ECHO Dot Gen3 A32DOYMUN6DTXA
#
# 2018.10.15 v0.0.45
# - FEATURE: Attribut intervalvoice 0=realtime bis 100 Sekunden
#
# 2018.10.10 v0.0.44
# - FEATURE: set alarm_off und alarm_on (Wecker und Musikwecker)
# set alarm_normal und alarm_repeat
# set routine_play (Abspielen und ausführen von Routinen)
# set info (Beliebig_Auf_Wiedersehen,Beliebig_Bestaetigung,Beliebig_Geburtstag,Beliebig_Guten_Morgen,Beliebig_Gute_Nacht,Beliebig_Ich_Bin_Zuhause,Beliebig_Kompliment,Erzaehle_Geschichte,Erzaehle_Was_Neues,Erzaehle_Witz,Kalender_Heute,Kalender_Morgen,Kalender_Naechstes_Ereignis,Nachrichten,Singe_Song,Verkehr,Wetter)
# set config_address_from config_address_to config_address_between (Einstellungen Verkehr)
# get address (Hier kann die Adresse gesucht werden für die set Befehle config_address_from config_address_to config_address_between)
# Unterstützung neuer ECHO Plus 2 A18O6U1UQFJ0XK
# Lautstärke sollte jetzt immer regelbar sein!
# - BUGFIX: Reading "currentTuneInID"
#
# 2018.10.08 v0.0.43a
# - CHANGE: set speak von Multiroom Geräten entfernt
# - BUGFIX: set Account Device
# get conversations
#
# 2018.09.03 v0.0.42
# - BUGFIX: Login
# - CHANGE: readingsBulkUpdateIfChanged to readingsBulkUpdate
#
# 2018.08.23 v0.0.41
# - BUGFIX: Login
#
# 2018.08.22 v0.0.40
# - FEATURE: set speak Natives TTS
# "set loginwithcaptcha"
# - CHANGE: browser_language default = de-DE
# browser_useragent default = Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
# Attribut "browser_save_data" wird jetzt auch am ECHO angezeigt
# - BUGFIX: 2FACode Authentifizierung
# "get actions" mit leeren Gerätennamen. Fehler im LOG
# Attribut disable
# Login
#
# 2018.06.08 v0.0.39
# - BUGFIX: get html_results
#
# 2018.06.07 v0.0.38
# - FEATURE: Anzeigen der Amazon Login Ergebnisse (get html_results)
# Attribut "browser_save_data"
#
# 2018.05.30 v0.0.37
# - BUGFIX: ReLogin bei "COOKIE ERROR"
# - FEATURE: Neues Attribut "browser_language"
#
# 2018.05.17 v0.0.36
# - CHANGE: Accept-Language: de,en-US
#
# 2018.05.17 v0.0.35
# - BUGFIX: Attribut "cookie"
#
# 2018.05.07 v0.0.34
# - BUGFIX: Attribut "intervalsettings"
# ReLogin bei "COOKIE ERROR"
#
# 2018.04.09 v0.0.33
# - CHANGE: get "help" zusätzliche Anleitung MP3 Streamserver & IceCast2
# TTS_Nachrichten werden mindestens mit der Laustärke von Reading "volume_alarm" abgespielt.
# Zwei Faktor Authentifizierung (set login2FACode) Danke Benutzer JoWiedmann https://forum.fhem.de/index.php/topic,82631.msg787815.html#msg787815
# Verstecken von Helper "CUSTOMER","COMMSID","COOKIE","DIRECTID","PASSWORD","USER","HTTP_CONNECTION" und "SERIAL"
# Verstecken von Readings "COOKIE","AWS_Access_Key" und "aws_secret_key"
# - FEATURE: Neues Reading "currentTuneInID"
# set "tts_translate" Übersetzung von der Webseite http://www.online-translator.com/ Reading="tts_translate_result"
# Neues Attribut "TTS_Translate_From"
# TTS Translate unterstützt folgende Sprachen:dutch,english,french,german,italian,japanese,korean,portuguese,russian,spanish und turkish
# TTS MP3 Länge ermitteln. Reading = "tts_lenght"
# TTS Nachrichte abspielen wenn schon ein TuneIn Sender läuft.
# - BUGFIX: Log Eintrag bei TTS & Attribut: "TTS_normalize" entfernt
# Name Attribut "TTS_Voice" WelshEnglish_Female_Gwyneth
# get settings
# Verzeichnis "echodevice" wurde nicht automatisch angelegt
#
# 2018.03.20 v0.0.32
# - FEATURE: Neues Attribut: "TTS_normalize" (only mp3 Outputformat!)
# - BUGFIX: remove sleep 0.5
#
# 2018-03-19 v0.0.31
# - BUGFIX: Amazone TTS Nachrichten < 3 Zeichen
# File "cache/pollyspeech.py", line 4, in <module>
# get "devices" https://forum.fhem.de/index.php/topic,82631.msg783487.html#msg783487
#
# 2018-03-18 v0.0.30
# - FEATURE: Text2Speech (TTS) inkl. Google und Amazon Stimmen
# Musik aus dem eigenen LAN abspielen
# Neue Attribute: ALLE "TTS_Voice" und "TTS_IgnorPlay"
# Neue Set Befehle: ACCOUNT "AWS_Access_Key","AWS_OutputFormat","AWS_Secret_Key","POM_Filename","POM_IPAddress","POM_TuneIn","TTS_Filename","TTS_IPAddress" und "TTS_TuneIn"
# Neue Set Befehle: Nur ECHO "tts", "playownmusic", "playownplaylist", "deleteownplaylist", und "saveownplaylist"
# - CHANGE: get "help"
# Reihenfolge get settings https://forum.fhem.de/index.php/topic,82631.msg781731.html#msg781731
#
# v0.0.29
# - FEATURE: Zwei Faktor Authentifizierung (set login2FACode) Danke Benutzer JoWiedmann https://forum.fhem.de/index.php/topic,82631.msg780848.html#msg780848
#
# v0.0.28
# - CHANGE: get "Conversations" auf nonBlocking
# get "tunein" auf nonBlocking & move to Echo Device & play link
# get "tracks" auf nonBlocking
# get "devices" auf nonBlocking
# set "autocreat_devices" auf nonBlocking
# httpversion = "1.1"
# - FEATURE: get "actions"
# get "primeplayeigene_albums"
# get "primeplayeigene_tracks"
# get "primeplayeigene_artists"
# get "primeplayeigeneplaylist"
# get "help"
# Multiroom add get settings & tunein
# - BUGFIX: primeplayeigene
#
# v0.0.27
# - BUGFIX: Not an ARRAY reference at ./FHEM/37_echodevice.pm line 1610
#
# v0.0.26
# - BUGFIX: read readings if amazon device is connected
#
# v0.0.25
# - BUGFIX: set reminder_normal
# Attribut disable
# no Internet connect
# - FEATURE: Attribut browser_useragent_random (Standard=1)
# Attribut intervallogin (Standard=60)
#
# v0.0.24
# - BUGFIX: Timer Readings
#
# v0.0.23
# - BUGFIX: Nested quantifiers in regex
# - CHANGE: Reading version
#
# v0.0.22
# - FEATURE: Attribut browser_useragent https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Attribute
#
# v0.0.21
# - CHANGE: Header
#
# v0.0.20
# - CHANGE: Cookie erstellen auf nonBlocking
# Cookie erstellen Timeout 10 sekunden
# - BUGFIX: div.
#
# v0.0.19
# - BUGFIX: Fehlt bei "get" der Punkt "conversations"
# Fehlt bei "set" der Punkt "textmessage"
#
# v0.0.18
# - FEATURE: autocreate Standard Raum "Amazon"
# - CHANGE: COOKIE wird nicht mehr erneuert!
#
# v0.0.17
# - FEATURE: refresh ECHO devices (Attribut autocreate_refresh)
# define icon to echo
# - CHANGE: Header
#
# v0.0.16
# - FEATURE: autocreate ECHO Spot
#
# v0.0.15
# - CHANGE: deletereading auf FHEM Command umgestellt
# - BUGFIX: MausicAlarm
#
# v0.0.14
# - FEATURE: autocreate ECHO Multiroom
# autocreate Sonos One
# autocreate Reverb
# - CHANGE: model im Klartext z.B. Echo Dot
#
# v0.0.13
# - BUGFIX: Cookie
#
# v0.0.12
# - FEATURE: Support Musicalarm
#
# v0.0.11.2
# - FEATURE: neue Readings timer_XX, reminder_X und alarm_xx
# neue Readings deviceAddress, timeZoneId
# Zeigt den Status für Mikrofon Reading = microphone
# Zeigt den Status ob der ECHO online ist. Reading = online
# - BUGFIX: Reading voice leer
# Div. Logeinträge wenn Variablen leer sind
# - CHANGE : Reading active entfernt
#
# v0.0.10
# - BUGFIX: Einkaufsliste und ToDo Liste (Fehler beim hinzufügen und entfernen von Einträgen)
#
# v0.0.9
# - BUGFIX: ECHO Devices Readings wurden nicht aktualisiert
#
# v0.0.8
# - FEATURE: Attribut tuneid_default (Hier kann ein Standard TuneIn Sender angegeben werden)
# set notifications_delete (löschen von Erinnerungen, Timer und Wecker)
# autocreate ECHO Show Geräte
# löschen und hinzufügen von Einkauflisten- und Task Einträgen
#
# v0.0.7
# - FEATURE: Interval Anpassung beim abspielen eines Songs
# - CHANGE: set reminder_normal ohne Datumsangabe (Reminder sofort ausgeführt))
#
# v0.0.6
# - CHANGE : Log Einträge reduziert
# Reading "voice" zum Echo Device verschoben
# - BUGFIX: set reminder_normal Text (Reminder sofort ausgeführt))
# ACCOUNT DEVICE macht jetzt die abfragen für wakeword, volume_alarm, dnd, active, bluetooth
# Standard Interval 60 Sekunden
#
# v0.0.5
# - CHANGE : set reminder_normal (durch weglassen der Uhrzeit wird der Reminder sofort ausgeführt)
# - FEATURE: Attribut reminder_delay (wird für reminder_normal benötigt. Standardwert = 10 sekunden)
#
# v0.0.4
# - CHANGE: set reminder vom ACCOUNT DEVICE entfernt
# set reminder zum Echo DEVICE hinzugefügt
# - FEATURE: set reminder_normal
# set reminder_repeat
#
# v0.0.3
# - BUGFIX: Anzeige set befehle primeplayeigene,primeplayeigeneplaylist,primeplaylist und primeplaysender
#
# v0.0.2
# - FEATURE: set primeplayeigene
# set primeplayeigeneplaylist
# set primeplaylist
# set primeplaysender
#
# v.0.0.1
# - BUGFIX: blocking restart fhem
# readings
#
# Copyright by Michael Winkler
# e-mail: michael.winkler at online.de
#
# This file is part of fhem.
#
# Fhem is free software: you can redistribute it andor modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Fhem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
#
# https://forum.fhem.de/index.php/topic,82631.0.html
#
##############################################################################
package main;
#use strict;
use Time::Local;
use Encode;
use Encode qw/from_to/;
use URI::Escape;
use Data::Dumper;
use JSON;
use utf8;
use Date::Parse;
use Time::Piece;
use lib ('./FHEM/lib', './lib');
use MP3::Info;
use MIME::Base64;
my $ModulVersion = "0.2.30";
my $AWSPythonVersion = "0.0.3";
my $NPMLoginTyp = "unbekannt";
my $QueueNumber = 0;
##############################################################################
sub echodevice_Initialize($) {
my ($hash) = @_;
my $name = $hash->{NAME};
$hash->{DefFn} = "echodevice_Define";
$hash->{UndefFn} = "echodevice_Undefine";
$hash->{NOTIFYDEV} = "global";
$hash->{NotifyFn} = "echodevice_Notify";
$hash->{GetFn} = "echodevice_Get";
$hash->{SetFn} = "echodevice_Set";
$hash->{AttrFn} = "echodevice_Attr";
$hash->{AttrList} = "disable:0,1 ".
"IODev ".
"TTS_Voice:AustralianEnglish_Female_Nicole,AustralianEnglish_Male_Russell,BrazilianPortuguese_Female_Vitoria,BrazilianPortuguese_Male_Ricardo,BritishEnglish_Female_Amy,BritishEnglish_Female_Emma,BritishEnglish_Male_Brian,CanadianFrench_Female_Chantal,CastilianSpanish_Female_Conchita,CastilianSpanish_Male_Enrique,Danish_Female_Naja,Danish_Male_Mads,Dutch_Female_Lotte,Dutch_Male_Ruben,French_Female_Celine,French_Male_Mathieu,German_Female_Google,German_Female_Marlene,German_Female_Vicki,German_Male_Hans,Icelandic_Female_Dora,Icelandic_Male_Karl,IndianEnglish_Female_Aditi,IndianEnglish_Female_Raveena,Italian_Female_Carla,Italian_Male_Giorgio,Japanese_Female_Mizuki,Japanese_Male_Takumi,Korean_Female_Seoyeon,Norwegian_Female_Liv,Polish_Female_Ewa,Polish_Female_Maja,Polish_Male_Jacek,Polish_Male_Jan,Portuguese_Female_Ines,Portuguese_Male_Cristiano,Romanian_Female_Carmen,Russian_Female_Tatyana,Russian_Male_Maxim,Swedish_Female_Astrid,Turkish_Female_Filiz,USEnglish_Female_Ivy,USEnglish_Female_Joanna,USEnglish_Female_Kendra,USEnglish_Female_Kimberly,USEnglish_Female_Salli,USEnglish_Male_Joey,USEnglish_Male_Justin,USEnglish_Male_Matthew,USSpanish_Female_Penelope,USSpanish_Male_Miguel,WelshEnglish_Female_Gwyneth,WelshEnglish_Male_Geraint ".
"TTS_IgnorPlay:0,1 ".
"TTS_normalize:slider,5,1,40 ".
"TTS_Translate_From:dutch,english,french,german,italian,japanese,korean,portuguese,russian,spanish,turkish ".
"intervalsettings ".
"intervallogin ".
"intervalvoice:slider,0,1,100 ".
"ignorevoicecommand ".
"speak_volume:slider,0,1,100 ".
"server ".
"cookie ".
"reminder_delay ".
"tunein_default ".
"autocreate_refresh:0,1 ".
"browser_useragent ".
"browser_language ".
"browser_save_data:0,1 ".
"browser_useragent_random:0,1 ".
"npm_proxy_port ".
"npm_proxy_ip ".
"npm_proxy_listen_ip ".
"npm_refresh_intervall ".
"npm_bin ".
"npm_bin_node ".
"fhem_home ".
$readingFnAttributes;
}
sub echodevice_Define($$$) {
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
my ($found, $dummy);
return "syntax: define <name> echodevice <account> <password>" if(int(@a) != 4 );
my $name = $hash->{NAME};
$attr{$name}{server} = "layla.amazon.de" if( defined($attr{$name}) && !defined($attr{$name}{server}) );
RemoveInternalTimer($hash);
if($a[2] =~ /crypt/ || $a[2] =~ /@/ || $a[2] =~ /^\+/) {
$hash->{model} = "ACCOUNT";
my $user = $a[2];
my $pass = $a[3];
if ($user eq 'xxx@xxx.xx' and $pass eq "xxx") {
# Amazon NPM Login Modus
$hash->{LOGINMODE} = "NPM";
}
else {
# Amazon normal Login Modus
my $username = echodevice_encrypt($user);
my $password = echodevice_encrypt($pass);
$hash->{DEF} = "$username $password";
$hash->{helper}{".USER"} = $username;
$hash->{helper}{".PASSWORD"} = $password;
$hash->{LOGINMODE} = "NORMAL";
}
$hash->{helper}{TWOFA} = "";
$hash->{helper}{SERVER} = $attr{$name}{server};
$hash->{helper}{SERVER} = "layla.amazon.de" if(!defined($hash->{helper}{SERVER}));
$hash->{helper}{RUNLOGIN} = 0;
$hash->{helper}{".LOGINERROR"} = 0;
$modules{$hash->{TYPE}}{defptr}{"account"} = $hash;
$hash->{STATE} = "INITIALIZED";
# set default settings on first define
if ($init_done and $attr{$name}{icon} eq "" and $attr{$name}{room} eq "") {
$attr{$name}{icon} = 'echo';
$attr{$name}{room} = 'Amazon';
}
InternalTimer(gettimeofday() + 5 , "echodevice_FirstStart" , $hash, 0);
InternalTimer(gettimeofday() + 10 , "echodevice_GetSettings", $hash, 0);
}
else {
# Attribute
my $DeviceTyp = $a[2];
my $DeviceSerial = $a[3];
# Amazon ECHO Device
$hash->{STATE} = "INITIALIZED";
$hash->{model} = echodevice_getModel($DeviceTyp);#$a[2];
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "model", $hash->{model}, 1);
readingsBulkUpdate($hash, "state", "INITIALIZED", 1);
readingsEndUpdate($hash,1);
$hash->{helper}{DEVICETYPE} = $DeviceTyp;
$hash->{helper}{".SERIAL"} = $DeviceSerial;
$hash->{LOGINMODE} = "IODEV";
$modules{$hash->{TYPE}}{defptr}{$DeviceSerial} = $hash;
my $account = $modules{$hash->{TYPE}}{defptr}{"account"};
Log3 $name, 0, "[echodevice_Define] load ECHO Devicename=$name Devicetype=" . $DeviceTyp . " Devicemodel=" . $hash->{model};
$hash->{IODev} = $account;
$attr{$name}{IODev} = $account->{NAME} if( !defined($attr{$name}{IODev}) && $account);
if ($hash->{model} ne "THIRD_PARTY_AVS_MEDIA_DISPLAY") {
InternalTimer(gettimeofday() + 1, "echodevice_GetSettings", $hash, 0);
}
}
readingsSingleUpdate ($hash, "COOKIE_MODE", $hash->{LOGINMODE} ,0);
Log3 $name, 4, "[$name] [echodevice_Define] Getting auth URL return";
return undef;
}
sub echodevice_Undefine($$) {
my ($hash, $arg) = @_;
my $name = $hash->{NAME};
RemoveInternalTimer($hash);
delete( $modules{$hash->{TYPE}}{defptr}{"ACCOUNT"} ) if($hash->{model} eq "ACCOUNT");
delete( $modules{$hash->{TYPE}}{defptr}{$hash->{helper}{".SERIAL"}} ) if($hash->{model} ne "ACCOUNT");
return undef;
}
sub echodevice_Notify($$) {
my ($hash,$dev) = @_;
my $name = $hash->{NAME};
return if($dev->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
Log3 "echodevice", 4, "[$name] [echodevice_Notify] echodevice: notify reload";
return undef;
}
sub echodevice_Get($@) {
my ($hash, @a) = @_;
shift @a;
my $command = shift @a;
my $parameter = join(' ',@a);
my $name = $hash->{NAME};
my $usage = "Unknown argument $command, choose one of ";
return $usage if ($hash->{model} eq 'unbekannt');
return $usage if ($hash->{model} eq 'Sonos One');
return $usage if ($hash->{model} eq 'Sonos Beam');
if ($hash->{model} eq "Reverb") {
$usage .= "help:noArg " ;
}
elsif ($hash->{model} eq "ACCOUNT") {
$usage .= "settings:noArg devices:noArg actions:noArg tracks:noArg help:noArg conversations:noArg html_results:noArg address status:noArg customer-history-records:noArg NPM_check:noArg";
}
else {
$usage .= "tunein settings:noArg primeplayeigene_albums primeplayeigene_tracks primeplayeigene_artists primeplayeigeneplaylist:noArg help:noArg html_results:noArg ";
}
#return "no get" if ($hash->{model} eq "Echo Multiroom");
return $usage if $command eq '?';
if ($command ne "help" || $command ne "help_results" || $command ne "status") {
}
elsif (IsDisabled($name)) {
$hash->{STATE} = "disabled";
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "state", "disabled", 1);
readingsEndUpdate($hash,1);
return "$name is disabled. Aborting...";
}
else {
}
my $ConnectState = "";
if($hash->{model} eq "ACCOUNT") {$ConnectState = $hash->{STATE}} else {$ConnectState = $hash->{IODev}->{STATE}}
if ($command eq "help") {
my $return = '<html><table align="" border="0" cellspacing="0" cellpadding="3" width="100%" height="100%" class="mceEditable"><tbody>';
$return .= "<p><strong>Hilfe:</strong></p>";
$return .= "<tr><td><strong>Dokumentation Modul  </strong></td><td><strong></strong></td></tr>";
$return .= "<tr><td>"."Beschreibung"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice</td></tr>";
$return .= "<tr><td>"."Readings"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Readings' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Readings</td></tr>";
$return .= "<tr><td>"."Attribute"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Attribute' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Attribute</td></tr>";
$return .= "<tr><td>"."Set"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Set' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Set</td></tr>";
$return .= "<tr><td>"."Get"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Get' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Get</td></tr>";
$return .= "<tr><td>"."Medieninformationen ermitteln"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Medieninformationen_ermitteln' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Medieninformationen_ermitteln</td></tr>";
$return .= "<tr><td>"."Cookie_ermitteln"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Cookie_ermitteln' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Cookie_ermitteln</td></tr>";
$return .= "<tr><td>"."Loginmit Captcha"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Login_captcha' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#Login_captcha</td></tr>";
$return .= "<tr><td>"."MP3 Playlisten"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#MP3_Playlisten' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#MP3_Playlisten</td></tr>";
$return .= "<tr><td>"."Amazon Stimmen"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#AWS_Konfiguration' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/eigene-module/echodevice/#AWS_Konfiguration</td></tr>";
$return .= "<tr><td> </td><td> </td></tr>";
$return .= "<tr><td><strong>Diverse Anleitungen</strong></td><td></td></tr>";
$return .= "<tr><td></td><td></td></tr>";
$return .= "<tr><td>"."Amazon ECHO TTS/POM"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/sonstiges/amazon-echo-tts-mp3s' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/sonstiges/amazon-echo-tts-mp3s</td></tr>";
$return .= "<tr><td>"."MPD Streamserver"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/sonstiges/mpd-streamserver' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/sonstiges/mpd-streamserver</td></tr>";
$return .= "<tr><td>"."MPD Web Frontend"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/sonstiges/mpd-webfrontend' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/sonstiges/mpd-webfrontend</td></tr>";
$return .= "<tr><td>"."IceCast2"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/smarthome/sonstiges/icecast2' .'"'. "</a>https://mwinkler.jimdo.com/smarthome/sonstiges/icecast2</td></tr>";
$return .= "<tr><td>"."NPM Login"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://mwinkler.jimdo.com/modul-echodevice-npm' .'"'. "</a>https://mwinkler.jimdo.com/modul-echodevice-npm</td></tr>";
$return .= "<tr><td> </td><td> </td></tr>";
$return .= "<tr><td><strong>Forum</strong></td><td></td></tr>";
$return .= "<tr><td></td><td></td></tr>";
$return .= "<tr><td>"."Forums Thread"." </td><td><a target=" . "_blank" . " href=" .'"' . 'https://forum.fhem.de/index.php/topic,82631.0.html' .'"'. "</a>https://forum.fhem.de/index.php/topic,82631.0.html</td></tr>";
$return .= "<tr><td> </td><td> </td></tr>";
$return .= "</tbody></table></html>";
return $return;
}
if ($command eq "html_results") {
my $timestamp ;
my $epoch_timestamp ;
my $return = '<html><table align="" border="0" cellspacing="0" cellpadding="3" width="100%" height="100%" class="mceEditable"><tbody>';
$return .= "<p><strong>Amazon HTML Results:</strong></p>";
$return .= "<tr><td><strong>Datum  </strong></td><td><strong>HTML Result Dateiname</strong></td></tr>";
opendir(DH, $FW_dir . "/echodevice/results");
my @files = readdir(DH);
closedir(DH);
my @filessorted = sort @files;
foreach my $file (@filessorted){
# skip . and ..
next if($file =~ /^\.$/);
next if($file =~ /^\.\.$/);
# Datum
$epoch_timestamp = 0 ;
$timestamp = 0 ;
if ((-e $FW_dir . "/echodevice/results/" . $file)) {
$epoch_timestamp = (stat($FW_dir . "/echodevice/results/" . $file))[9];
$timestamp = localtime($epoch_timestamp);
}
if ($hash->{model} eq "ACCOUNT" || index($file, $name) == 0 ) {
# $file is the file used on this iteration of the loop
$return .= "<tr><td>".$timestamp." </td><td><a target=" . "_blank" . " href=" .'"' . $FW_ME . '/echodevice/results/' . $file .'"'. "</a>" . $file . "</td></tr>";
}
}
$return .= "<tr><td> </td><td> </td></tr>";
$return .= "</tbody></table></html>";
return $return;
}
if ($command eq "status") {
my $return = '<html>';
#Allgemeine Informationen
$return .= '<table align="" border="0" cellspacing="0" cellpadding="3" width="100%" height="100%" class="mceEditable"><tbody>';
$return .= "<p><strong>Modul Infos:</strong></p>";
$return .= "<tr><td><strong>Beschreibung  </strong></td><td><strong>Bereich  </strong></td><td><strong>Wert</strong></td></tr>";
$return .= "<tr><td>STATE </td><td>Reading</td><td>" . ReadingsVal( $name, "state", "unbekannt") . "</td></tr>";
$return .= "<tr><td>Version </td><td>Reading</td><td>" . ReadingsVal( $name, "version", "unbekannt") . "</td></tr>";
$return .= "<tr><td>NPM Cookie Version </td><td>Reading</td><td>" . echodevice_NPMCheckVersion($hash,"cache/alexa-cookie/node_modules/alexa-cookie2/package.json","get status") . "</td></tr>";
$return .= "<tr><td>COOKIE_STATE </td><td>Reading</td><td>" . ReadingsVal( $name, "COOKIE_STATE", "unbekannt") . "</td></tr>";
$return .= "<tr><td>COOKIE_TYPE </td><td>Reading</td><td>" . ReadingsVal( $name, "COOKIE_TYPE", "unbekannt") . "</td></tr>";
$return .= "<tr><td>COOKIE_MODE </td><td>Reading</td><td>" . $hash->{LOGINMODE} . "</td></tr>";
$return .= "<tr><td>amazon_refreshtoken </td><td>Reading</td><td>" . ReadingsVal( $name, "amazon_refreshtoken", "unbekannt") . "</td></tr>";
#$return .= "<tr><td>.COOKIE </td><td>Reading</td><td>123</td></tr>";
# Attribute auslesen
while ( my ($key, $value) = each %{$attr{$name}} ) {
$return .= "<tr><td>" . $key . " </td><td>Attribut</td><td>" . $value . "</td></tr>";
}
$return .= "<tr><td> </td><td> </td><td> </td></tr></tbody></table>";
#Allgemeine Cookie Infos
$return .= '<table align="" border="0" cellspacing="0" cellpadding="3" width="100%" height="100%" class="mceEditable"><tbody>';
$return .= "<p><strong>Amazon Cookie:</strong></p>";
$return .= "<tr><td><strong>Beschreibung  </strong></td><td><strong>Bereich  </strong></td><td><strong>Wert</strong></td></tr>";
$return .= "<tr><td>.COOKIE </td><td>Reading</td><td>" . substr(ReadingsVal( $name, ".COOKIE", "unbekannt" ), 0, 20) . "....</td></tr>";
$return .= "<tr><td>COOKIE_STATE </td><td>Reading</td><td>" . ReadingsVal( $name, "COOKIE_STATE", "unbekannt") . "</td></tr>";
$return .= "<tr><td>COOKIE_TYPE </td><td>Reading</td><td>" . ReadingsVal( $name, "COOKIE_TYPE", "unbekannt") . "</td></tr>";
$return .= "<tr><td>amazon_refreshtoken </td><td>Reading</td><td>" . ReadingsVal( $name, "amazon_refreshtoken", "unbekannt") . "</td></tr>";
$return .= "<tr><td>.COOKIE </td><td>Helper</td><td>" . substr($hash->{helper}{".COOKIE"}, 0, 20) . "....</td></tr>";
$return .= "<tr><td>.COMMSID </td><td>Helper</td><td>" . substr($hash->{helper}{".COMMSID"}, 0, 20) . "....</td></tr>";
$return .= "<tr><td>.CSRF </td><td>Helper</td><td>" . substr($hash->{helper}{".CSRF"}, 0, 3) . "....</td></tr>";
$return .= "<tr><td>.DIRECTID </td><td>Helper</td><td>" . substr($hash->{helper}{".DIRECTID"}, 0, 20) . "....</td></tr>";
$return .= "<tr><td>RUNLOGIN </td><td>Helper</td><td>" . $hash->{helper}{RUNLOGIN} . "</td></tr>";
$return .= "<tr><td>RUNNING_REQUEST </td><td>Helper</td><td>" . $hash->{helper}{RUNNING_REQUEST} . "</td></tr>";
$return .= "<tr><td>LOGINERROR </td><td>Helper</td><td>" . $hash->{helper}{".LOGINERROR"} . "</td></tr>";
$return .= "<tr><td>FHEM_HOME </td><td>Attribut</td><td>" . AttrVal($name,"fhem_home","/opt/fhem") . "</td></tr>";
$return .= "<tr><td> </td><td> </td><td> </td></tr></tbody></table>";
$return .= "</html>";
return $return;
}
if ($command eq "NPM_check") {
$return = echodevice_NPMCheck($hash);
return $return;
}
if ($ConnectState ne "connected") {
return "$name is not connected. Aborting...";
}
if ($command eq "settings") {
echodevice_GetSettings($hash);
return "OK" if($hash->{model} ne "ACCOUNT");
}
elsif($command eq "actions") {
echodevice_SendCommand($hash,"getcards","");
}
elsif($command eq "devices") {
echodevice_SendCommand($hash,"devices","");
}
elsif($command eq "conversations") {
echodevice_SendCommand($hash,"conversations","");
}
elsif($command eq "tunein") {
echodevice_SendCommand($hash,"searchtunein",$parameter);
}
elsif($command eq "tracks") {
echodevice_SendCommand($hash,"searchtracks",$parameter);
}
elsif($command eq "primeplayeigene_albums") {
echodevice_SendCommand($hash,"primeplayeigene_Albums",$parameter);
}
elsif($command eq "primeplayeigene_tracks") {
echodevice_SendCommand($hash,"primeplayeigene_Tracks",$parameter);
}
elsif($command eq "primeplayeigene_artists") {
echodevice_SendCommand($hash,"primeplayeigene_Artists",$parameter);
}
elsif($command eq "primeplayeigeneplaylist") {
echodevice_SendCommand($hash,"getprimeplayeigeneplaylist","");
}
elsif($command eq "address") {
echodevice_SendCommand($hash,"address",$parameter);
}
elsif($command eq "customer-history-records") {
echodevice_SendCommand($hash,"customer-history-records",$parameter);
}
return undef;
}
sub echodevice_Set($@) {
my ($hash, @a) = @_;
shift @a;
my $command = shift @a;
my $parameter = join(' ',@a);
my $name = $hash->{NAME};
my $ShoppingListe = ReadingsVal($name, "list_SHOPPING_ITEM", "");
my $TaskListe = ReadingsVal($name, "list_TASK", "");
my $tracks = AttrVal($name, 'tracks', AttrVal(AttrVal($name, 'IODev', $name), 'tracks', undef));
my $usage = 'Unknown argument $command, choose one of ';
return $usage if ($hash->{model} eq 'unbekannt');
if($hash->{model} eq "ACCOUNT") {
$usage .= 'autocreate_devices:noArg item_shopping_add item_task_add ';
$usage .= 'AWS_Access_Key AWS_Secret_Key TTS_IPAddress TTS_Filename TTS_TuneIn POM_TuneIn POM_IPAddress POM_Filename AWS_OutputFormat:mp3,ogg_vorbis,pcm textmessage ';# if(defined($hash->{helper}{".COMMSID"}));
$usage .= 'config_address_from config_address_to config_address_between mobilmessage ';
$usage .= 'login:noArg loginwithcaptcha login2FACode ' if($hash->{LOGINMODE} eq "NORMAL");
$usage .= 'NPM_install:noArg NPM_login:new,refresh NPM_check:noArg' if($hash->{LOGINMODE} eq "NPM");
# Einkaufsliste
my $ShoppingListe = ReadingsVal($name, "list_SHOPPING_ITEM", "");
my $TaskListe = ReadingsVal($name, "list_TASK", "");
$ShoppingListe =~ s/ / /g;
$TaskListe =~ s/ / /g;
$usage .= ' item_shopping_delete:'.$ShoppingListe;
$usage .= ' item_task_delete:'.$TaskListe;
}
elsif ($hash->{model} eq "Echo Multiroom" || $hash->{model} eq "Sonos Display" || $hash->{model} eq "Echo Stereopaar") {
$usage .= 'volume:slider,0,1,100 play:noArg pause:noArg next:noArg previous:noArg forward:noArg rewind:noArg shuffle:on,off repeat:on,off ';
$usage .= 'tunein primeplaylist primeplaysender primeplayeigene primeplayeigeneplaylist tts tts_translate:textField-long playownmusic:textField-long saveownplaylist:textField-long speak speak_ssml ';
if(defined($tracks)) {
$tracks =~ s/ /_/g;
$tracks =~ s/:/,/g;
$usage .= 'track:'.$tracks.' ';
}
else {
$usage .= 'track ';
}
# startownplaylist
$usage .= echodevice_GetOwnPlaylist($hash);
}
else {
$usage .= 'volume:slider,0,1,100 play:noArg pause:noArg next:noArg previous:noArg forward:noArg rewind:noArg shuffle:on,off repeat:on,off dnd:on,off volume_alarm:slider,0,1,100 ';
$usage .= 'info:Beliebig_Auf_Wiedersehen,Beliebig_Bestaetigung,Beliebig_Geburtstag,Beliebig_Guten_Morgen,Beliebig_Gute_Nacht,Beliebig_Ich_Bin_Zuhause,Beliebig_Kompliment,Erzaehle_Geschichte,Erzaehle_Was_Neues,Erzaehle_Witz,Kalender_Heute,Kalender_Morgen,Kalender_Naechstes_Ereignis,Nachrichten,Singe_Song,Verkehr,Wetter sounds:glocken,kirchenglocke,summer,tuerklingel_1,tuerklingel_2,tuerklingel_3,jubelnde_menschenmenge,publikumsapplaus,flugzeug,katastrophenalarm,motoren_an,schilde_hoch,sirenen,zappen,boing_1,boing_2,kamera,lufthupe,quitschende_tuer,tickende_uhr,trompete,hahn,hundegebell,katzenmauzen,loewengebruell,wolfsgeheul,gruselig_quitschende_tuer,weihnachtsglocken tunein primeplaylist primeplaysender primeplayeigene primeplayeigeneplaylist alarm_normal alarm_repeat reminder_normal reminder_repeat speak speak_ssml tts tts_translate:textField-long playownmusic:textField-long saveownplaylist:textField-long ';
$usage .= 'textcommand ';
$usage .= 'homescreen ' if ($hash->{model} eq "Echo Show 5" || $hash->{model} eq "Echo Show 8" || $hash->{model} eq "Echo Show" || $hash->{model} eq "Echo Show Gen2" || $hash->{model} eq "Echo Show Gen3");
# startownplaylist
$usage .= echodevice_GetOwnPlaylist($hash);
if(defined($tracks)) {
$tracks =~ s/ /_/g;
$tracks =~ s/:/,/g;
$usage .= 'track:'.$tracks.' ';
}
else {
$usage .= 'track ';
}
$usage .= 'bluetooth_connect:'.$hash->{helper}{bluetooth}.' bluetooth_disconnect:'.$hash->{helper}{bluetooth}.' ' if(defined($hash->{helper}{bluetooth}));
# Routinen auslesen
my $BehaviorName ;
my @Behaviors = ();
foreach my $BehaviorID (sort keys %{$hash->{IODev}->{helper}{"getbehavior"}}) {
#Log3 $name, 3, "[DEBUG] BehaviorID = " . $BehaviorID;
$BehaviorName = $hash->{IODev}->{helper}{"getbehavior"}{$BehaviorID}{triggers}[0]{payload}{utterance};
$BehaviorName =~ s/ /_/g;
#Log3 $name, 3, "[DEBUG] Name = " . $BehaviorName;
push @Behaviors, $BehaviorName . "@" . $BehaviorID;
}
# Reminder/Alarm auslesen
my @ncstrings = ();
my @Alarms = ();