Notdienst Apotheke via jsonmod

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

Vorheriges Thema - Nächstes Thema

JoWiemann

#75
Zitat von: grossmaggul am 09 März 2024, 17:35:44Tschuldigung jetzt schon, sollte ich mich damit als DAU outen...
Hallo,

hast Du somit getan ;-)

Eine entsprechende Lösung mit httpmod findest Du hier im Forum.

Grüße Jörg

Damit Du nicht suchen musst:
defmod NotApo HTTPMOD https://www.apotheken-umschau.de/apotheken-notdienst/ 0
attr NotApo alignTime 09:02
attr NotApo disable 0
attr NotApo reading01Name NotApo_Name
attr NotApo reading01Regex <p>[\s]*<strong>(.+)[(]ca
attr NotApo reading02Name NotApo_Street
attr NotApo reading02Regex <br>[\s]*(.+)<br>
attr NotApo reading03Name NotApo_City
attr NotApo reading03Regex <br>[\s]*(.*)<br>[\s]*<\/p>
attr NotApo reading04Name NotApo_TimeText
attr NotApo reading04Regex <p class="font-size-xs">(.*)<\/p>
attr NotApo reading05Name NotApo_Tel
attr NotApo reading05Regex dashed">[\s]+<p>Telefon:[\W]+(.*)<\/p>
attr NotApo replacement01Mode text
attr NotApo replacement01Regex %%ZIP%%
attr NotApo replacement01Value Deine Postletzahl
attr NotApo replacement02Mode text
attr NotApo replacement02Regex %%CITY%%
attr NotApo replacement02Value Deine Stadt
attr NotApo replacement03Mode text
attr NotApo replacement03Regex %%STREET%%
attr NotApo replacement03Value Deine Straße
attr NotApo replacement04Mode expression
attr NotApo replacement04Regex %%DATE%%
attr NotApo replacement04Value return DateTime->now(time_zone => 'local')\
          ->set_time_zone('floating')\
        ->add(days => 0)\
        ->strftime('%Y-%m-%d');;
attr NotApo requestData01 emergency_pharmacy_search%5Bplz%5D=%%ZIP%%&emergency_pharmacy_search%5Bort%5D=%%CITY%%&emergency_pharmacy_search%5Bstrasse%5D=%%STREET%%&emergency_pharmacy_search%5Bdatum%5D=%%DATE%%
attr NotApo requestHeader01 Accept: text/html,application/xhtml+xml,application/xml;;q=0.9,image/avif,image/webp,*/*;;q=0.8
attr NotApo requestHeader02 Accept-Language: de,en-US;;q=0.7,en;;q=0.3
attr NotApo requestHeader03 Content-Type: application/x-www-form-urlencoded
attr NotApo requestHeader04 Accept-Encoding: gzip, deflate, br
attr NotApo requestHeader05 Host: www.apotheken-umschau.de
attr NotApo requestHeader06 User-Agent: Mozilla/5.0 (X11;; Linux x86_64;; rv:109.0) Gecko/20100101 Firefox/113.0
attr NotApo room Apotheke
attr NotApo stateFormat { my $ret = "<div style=\"text-align: left;;\">";;\
    $ret .= "<font style=\"font-weight: bold;;\">".ReadingsVal($name,"NotApo_Name","?")."</font><br />";;\
        my $osmlink = "https://www.openstreetmap.org/search?query=";;\
            $osmlink .= ReadingsVal($name,"NotApo_Street","")."%2C ";;\
            $osmlink .= ReadingsVal($name,"NotApo_City","");;\
    $ret .= "<a href=\"".$osmlink."\" rel=\"noopener noreferrer\" target=\"_blank\">";;\
    $ret .= ReadingsVal($name,"NotApo_Street","?")."<br />";;\
    $ret .= ReadingsVal($name,"NotApo_City","?")."</a><br />";;\
    $ret .= "<br />";;\
        my $numberlink = ReadingsVal($name,"NotApo_Tel","");;\
            $numberlink =~ s/\s+//g;;\
            $numberlink =~ s/\///g;;\
    $ret .= "Tel.: <a href=\"tel:+49".substr($numberlink, 1)."\">".ReadingsVal($name,"NotApo_Tel","")."</a><br />";;\
    $ret .= "<br />";;\
    $ret .= ReadingsVal($name,"NotApo_TimeText","?")."<br />";;\
    $ret .= "</div>";;\
    return $ret;;\
}
attr NotApo webCmd reread
Jörg Wiemann

Slave: RPi B+ mit 512 MB, COC (868 MHz), CUL V3 (433.92MHz SlowRF); FHEMduino, Aktuelles FHEM

Master: CubieTruck; Debian; Aktuelles FHEM

grossmaggul

Zitathast Du somit getan ;)
:-[ Wusste ich's doch. :o  ;)

ZitatDamit Du nicht suchen musst:
Danke Dir!
FHEM auf Debian Buster Server, 2 x nanoCUL868, 1xnanoCUL465; Homematic, MAX, MiLight, HUE,  2 x Gosund SP1

KyleK

Ich hab mein HTTPMod entsprechend angepasst:
defmod apotheke_token HTTPMOD none 0
attr apotheke_token event-on-change-reading .*
attr apotheke_token get1FollowGet pharmacymap
attr apotheke_token get1Name start
attr apotheke_token get1Poll 1
attr apotheke_token get1RegOpt g
attr apotheke_token get1Regex src=\"(.+\/Main.entry-.*\?\d+)\"
attr apotheke_token get1URL https://www.aponet.de/apotheke/notdienstsuche
attr apotheke_token get2FollowGet token
attr apotheke_token get2Name pharmacymap
attr apotheke_token get2Poll 1
attr apotheke_token get2PollDelay 5
attr apotheke_token get2Regex \[\".(\/Pharmacymap.*?\.js)\".+\]
attr apotheke_token get2URL https://www.aponet.de%%me%%
attr apotheke_token get3Name token
attr apotheke_token get3OExpr $val=urlEncode($val)
attr apotheke_token get3Poll 1
attr apotheke_token get3Regex fs=\"(.+?)\"
attr apotheke_token get3URL https://www.aponet.de/_assets/vite/assets%%pm%%
attr apotheke_token replacement2Mode reading
attr apotheke_token replacement2Regex %%me%%
attr apotheke_token replacement2Value start-2
attr apotheke_token replacement3Mode reading
attr apotheke_token replacement3Regex %%pm%%
attr apotheke_token replacement3Value pharmacymap
FHEM on Raspberry Pi 3B+
CUL868
7x MAX! Thermostat, 8x MAX! Fensterkontakte
Conbee II + deConz, TradFri Lampen, Osram Smart+ Steckdosen