Notdienst Apotheke via jsonmod

Begonnen von binford6000, 27 März 2023, 14:10:27

Vorheriges Thema - Nächstes Thema

Sailor

Moin tosammen

Anbei ein paar Verbesserungen zu dem obigen Beispiel - Noch mehr Readings und was fürs Auge:

define apotheke2 HTTPMOD none 0
attr apotheke2 DbLogExclude .*
attr apotheke2 enableCookies 1
attr apotheke2 event-on-change-reading .*
attr apotheke2 get1FollowGet data
attr apotheke2 get1Header01 User-Agent: Mozilla/5.0 (X11;; Linux x86_64;; rv:128.0) Gecko/20100101 Firefox/128.0
attr apotheke2 get1Header02 Referer: https://www.aponet.de/notdienstsuche
attr apotheke2 get1Header03 Host: www.aponet.de
attr apotheke2 get1Header04 DNT: 1
attr apotheke2 get1Name data-token
attr apotheke2 get1RegOpt g
attr apotheke2 get1Regex data-token=\"(.+?)\"
attr apotheke2 get1URL https://www.aponet.de/notdienstsuche
attr apotheke2 get2CheckAllReadings 1
attr apotheke2 get2Data tx_aponetpharmacy_search[action]=result&tx_aponetpharmacy_search[controller]=Search&tx_aponetpharmacy_search[search][plzort]=10115&tx_aponetpharmacy_search[search][date]=&tx_aponetpharmacy_search[search][street]=+&tx_aponetpharmacy_search[search][radius]=30&tx_aponetpharmacy_search[search][lat]=&tx_aponetpharmacy_search[search][lng]=
attr apotheke2 get2Header01 User-Agent: Mozilla/5.0 (X11;; Linux x86_64;; rv:128.0) Gecko/20100101 Firefox/128.0
attr apotheke2 get2Header02 Referer: https://www.aponet.de/notdienstsuche
attr apotheke2 get2Header03 Host: www.aponet.de
attr apotheke2 get2Header04 DNT: 1
attr apotheke2 get2Header05 x-pharmacy-token: %%token%%
attr apotheke2 get2Header06 Content-Type: application/x-www-form-urlencoded;;charset=UTF-8
attr apotheke2 get2Name data
attr apotheke2 get2URL https://www.aponet.de/notdienstsuche?type=1981
attr apotheke2 reading101JSON results_apotheken_apotheke_01_name
attr apotheke2 reading101Name 01_name
attr apotheke2 reading102JSON results_apotheken_apotheke_01_strasse
attr apotheke2 reading102Name 01_strasse
attr apotheke2 reading103JSON results_apotheken_apotheke_01_ort
attr apotheke2 reading103Name 01_ort
attr apotheke2 reading104JSON results_apotheken_apotheke_01_plz
attr apotheke2 reading104Name 01_plz
attr apotheke2 reading105JSON results_apotheken_apotheke_01_telefon
attr apotheke2 reading105Name 01_telefon
attr apotheke2 reading106JSON results_apotheken_apotheke_01_distanz
attr apotheke2 reading106Name 01_distanz
attr apotheke2 reading107JSON results_apotheken_apotheke_01_startdatum
attr apotheke2 reading107Name 01_startdatum
attr apotheke2 reading108JSON results_apotheken_apotheke_01_latitude
attr apotheke2 reading108Name 01_latitude
attr apotheke2 reading109JSON results_apotheken_apotheke_01_longitude
attr apotheke2 reading109Name 01_longitude
attr apotheke2 reading110JSON results_apotheken_apotheke_01_fax
attr apotheke2 reading110Name 01_fax
attr apotheke2 reading111JSON results_apotheken_apotheke_01_id
attr apotheke2 reading111Name 01_id
attr apotheke2 reading201JSON results_apotheken_apotheke_02_name
attr apotheke2 reading201Name 02_name
attr apotheke2 reading202JSON results_apotheken_apotheke_02_strasse
attr apotheke2 reading202Name 02_strasse
attr apotheke2 reading203JSON results_apotheken_apotheke_02_ort
attr apotheke2 reading203Name 02_ort
attr apotheke2 reading204JSON results_apotheken_apotheke_02_plz
attr apotheke2 reading204Name 02_plz
attr apotheke2 reading205JSON results_apotheken_apotheke_02_telefon
attr apotheke2 reading205Name 02_telefon
attr apotheke2 reading206JSON results_apotheken_apotheke_02_distanz
attr apotheke2 reading206Name 02_distanz
attr apotheke2 reading207JSON results_apotheken_apotheke_02_startdatum
attr apotheke2 reading207Name 02_startdatum
attr apotheke2 reading208JSON results_apotheken_apotheke_02_latitude
attr apotheke2 reading208Name 02_latitude
attr apotheke2 reading209JSON results_apotheken_apotheke_02_longitude
attr apotheke2 reading209Name 02_longitude
attr apotheke2 reading210JSON results_apotheken_apotheke_02_fax
attr apotheke2 reading210Name 02_fax
attr apotheke2 reading211JSON results_apotheken_apotheke_02_id
attr apotheke2 reading211Name 02_id
attr apotheke2 reading301JSON results_apotheken_apotheke_03_name
attr apotheke2 reading301Name 03_name
attr apotheke2 reading302JSON results_apotheken_apotheke_03_strasse
attr apotheke2 reading302Name 03_strasse
attr apotheke2 reading303JSON results_apotheken_apotheke_03_ort
attr apotheke2 reading303Name 03_ort
attr apotheke2 reading304JSON results_apotheken_apotheke_03_plz
attr apotheke2 reading304Name 03_plz
attr apotheke2 reading305JSON results_apotheken_apotheke_03_telefon
attr apotheke2 reading305Name 03_telefon
attr apotheke2 reading306JSON results_apotheken_apotheke_03_distanz
attr apotheke2 reading306Name 03_distanz
attr apotheke2 reading307JSON results_apotheken_apotheke_03_startdatum
attr apotheke2 reading307Name 03_startdatum
attr apotheke2 reading308JSON results_apotheken_apotheke_03_latitude
attr apotheke2 reading308Name 03_latitude
attr apotheke2 reading309JSON results_apotheken_apotheke_03_longitude
attr apotheke2 reading309Name 03_longitude
attr apotheke2 reading310JSON results_apotheken_apotheke_03_fax
attr apotheke2 reading310Name 03_fax
attr apotheke2 reading311JSON results_apotheken_apotheke_03_id
attr apotheke2 reading311Name 03_id
attr apotheke2 reading401JSON results_apotheken_apotheke_04_name
attr apotheke2 reading401Name 04_name
attr apotheke2 reading402JSON results_apotheken_apotheke_04_strasse
attr apotheke2 reading402Name 04_strasse
attr apotheke2 reading403JSON results_apotheken_apotheke_04_ort
attr apotheke2 reading403Name 04_ort
attr apotheke2 reading404JSON results_apotheken_apotheke_04_plz
attr apotheke2 reading404Name 04_plz
attr apotheke2 reading405JSON results_apotheken_apotheke_04_telefon
attr apotheke2 reading405Name 04_telefon
attr apotheke2 reading406JSON results_apotheken_apotheke_04_distanz
attr apotheke2 reading406Name 04_distanz
attr apotheke2 reading407JSON results_apotheken_apotheke_04_startdatum
attr apotheke2 reading407Name 04_startdatum
attr apotheke2 reading408JSON results_apotheken_apotheke_04_latitude
attr apotheke2 reading408Name 04_latitude
attr apotheke2 reading409JSON results_apotheken_apotheke_04_longitude
attr apotheke2 reading409Name 04_longitude
attr apotheke2 reading410JSON results_apotheken_apotheke_04_fax
attr apotheke2 reading410Name 04_fax
attr apotheke2 reading411JSON results_apotheken_apotheke_04_id
attr apotheke2 reading411Name 04_id
attr apotheke2 replacement2Mode reading
attr apotheke2 replacement2Regex %%token%%
attr apotheke2 replacement2Value data-token
attr apotheke2 stateFormat <table style="width:100%;; border-collapse:collapse;; font-family:Arial;;">\
<thead>\
<tr>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Datum</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">ID</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Name</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Telefon</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Fax</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Straße</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">PLZ</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Ort</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Distanz</th>\
<th style="border:1px solid #ddd;; padding:8px;; text-align:center;;">Koordinaten</th>\
</tr>\
</thead>\
<tbody>\
<tr>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_startdatum]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_id]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_name]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_telefon]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_fax]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_strasse]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_plz]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_ort]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_distanz:r1] km</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:01_latitude] / [$name:01_longitude]</td>\
</tr>\
<tr>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_startdatum]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_id]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_name]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_telefon]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_fax]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_strasse]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_plz]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_ort]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_distanz:r1] km</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:02_latitude] / [$name:02_longitude]</td>\
</tr>\
<tr>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_startdatum]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_id]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_name]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_telefon]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_fax]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_strasse]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_plz]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_ort]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_distanz:r1] km</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:03_latitude] / [$name:03_longitude]</td>\
</tr>\
<tr>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_startdatum]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_id]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_name]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_telefon]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_fax]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_strasse]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_plz]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_ort]</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_distanz:r1] km</td>\
<td style="border:1px solid #ddd;; padding:8px;;">[$name:04_latitude] / [$name:04_longitude]</td>\
</tr>\
</tbody>
attr apotheke2 webCmd :

Gruss
    Sailor
******************************
Man wird immer besser...

300P

#121
@Sailor

Anfängefrage:  :o

Hab den obigen Code kopiert und so in meinem FHEM definiert. (PLZ geändert)
Muss noch was anderes hinzu (wie im Faden auf den Seiten da was steht) oder reicht allein dies inzwischen ?

Mit get .... token kommt auch nach 10 Minuten nix bei mir  :-[

EDIT:
Lösung war 1 mal den Notdienst per Hand aufgerufen und "Akzeptieren" geklickt.... jetzt hab ich schon mal den Token. 🤓

Und nach 10 Minuten dann auch die ersten Readings....😝

Dankeschön dafür !!!🤩😊

Gruß
300P

FHEM 6.4|RPi|SMAEM|SMAInverter|SolarForecast| DbLog|DbRep|MariaDB|Buderus-MQTT_EMS|
Fritzbox|fhempy|JsonMod|HTTPMOD|Modbus ser+TCP| ESP32_AI_on_the_Edge|ESP32CAM usw.

caldir65

Moinsen,

ich habe es jetzt noch einmal gelöscht und mit den Ergänzungen von @Sailor neu angelegt, PLZORT angepasst und get data-token ausgeführt, und wenige Augenblicke später hatte ich Daten.
Super, vielen Dank.

Gruß
Christoph
Alte Techniker-Regel: "kaum macht man es richtig, funktioniert es auch"
------
Dell Wyse5070 ThinClient 16GBRam, 128GB SSD, Lubuntu 24.04.04LTS, fhem (aktuell), debmatic, Homematic-Devs, ConBee III und deConz, viele Shellys, Rademacher, NextCloud-Anbindung, FullyKioskBrowser+FUIP uvm.