FHEM > Codeschnipsel

Notdienst Apotheke

<< < (21/21)

Wolle02:

--- Zitat von: yersinia am 23 September 2021, 16:47:22 ---Für alle, die den Standort der Apotheke auf einer Karte angezeigt haben wollen, können sich mit OSM einen Kartenlink generieren (raw):

--- Code: ---attr DEVICE userReadings OSMLink { my $ret = "https:\/\/www.openstreetmap.org\/?";;\
$ret .= "mlat=".ReadingsVal($name,"Breitengrad","0");;\
$ret .= "&mlon=".ReadingsVal($name,"Laengengrad","0");;\
$ret .= "#map=18";;\
$ret .= "\/".ReadingsVal($name,"Breitengrad","0");;\
$ret .= "\/".ReadingsVal($name,"Laengengrad","0");;\
return $ret;; }
--- Ende Code ---
erzeugt ein userReading OSMLink wie diesen:

--- Code: ---   2021-09-23 16:45:17   OSMLink         https://www.openstreetmap.org/?mlat=51.1873547&mlon=10.0575891#map=18/51.1873547/10.0575891
--- Ende Code ---
Entspricht diesem link: https://www.openstreetmap.org/?mlat=51.1873547&mlon=10.0575891#map=18/51.1873547/10.0575891

--- Ende Zitat ---

.... und wer lieber GoogleMaps verwendet für den wäre hier der passende Code:


--- Code: ---attr DEVICE userReadings GoogleLink {my $ret = "https:\/\/www.google.com\/maps\/search\/?api=1";;\
    $ret .= "&query=".ReadingsVal($name,"Breitengrad","0");;\
    $ret .= ",".ReadingsVal($name,"Laengengrad","0");;\
    return $ret;; }
--- Ende Code ---

yersinia:
Alternativ:

--- Code: ---attr DEVICE userReadings GoogleLink {my $ret = "https:\/\/www.google.com\/maps\/search\/";;\
    $ret .= ReadingsVal($name,"Breitengrad","0");;\
    $ret .= ",".ReadingsVal($name,"Laengengrad","0");;\
    $ret .= "\/\@".ReadingsVal($name,"Breitengrad","0");;\
    $ret .= ",".ReadingsVal($name,"Laengengrad","0");;\
    $ret .= ",18z";;\
    return $ret;; }
--- Ende Code ---
Erzeugt diesen Link mit Zentrierung und Zoom: https://maps.google.com/maps/search/51.1873547,10.0575891/@51.1873547,10.0575891,18z

caldir65:
Hallo,

ich habe den OSM-Link versucht, umzusetzen, jedoch kommt bei mir nur der folgende Fehler:

--- Code: ---Error evaluating NotdienstApotheke userReading OSMLink: Can't modify single ref constructor in concatenation (.) or string at (eval 4505466) line 2, at EOF
--- Ende Code ---

Was übersehe ich da jetzt bloß?

Das Device:

--- Code: ---Internals:
   BUSY       0
   DEF        https://apothekenfinder.mobi/interface/json.php?device=web&source=not&search=49324 0
   FUUID      5db338f9-f33f-378b-3622-385c1dfe29ce8674
   FVERSION   98_HTTPMOD.pm:0.247080/2021-07-06
   Interval   0
   MainURL    https://apothekenfinder.mobi/interface/json.php?device=web&source=not&search=49324
   ModuleVersion 4.1.10 - 6.7.2021
   NAME       NotdienstApotheke
   NOTIFYDEV  global
   NR         1228
   NTFY_ORDER 50-NotdienstApotheke
   STATE      Neue Apotheke Bruchmühlen, 05226 982222, Kilverstraße 169 -173 in 32289 Rödinghausen
   TYPE       HTTPMOD
   value     
   HttpUtils:
     NAME       
     addr       https://apothekenfinder.mobi:443
     auth       0
     buf       
     code       200
     compress   1
     conn       
     data       
     displayurl https://apothekenfinder.mobi/interface/json.php?device=web&source=not&search=49324
     header     Accept-Encoding: gzip, deflate
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6
User-Agent: Lynx/2.8.8dev.3 libwww-FM/2.14 SSL-MM/1.4.1
Referer: http://apothekenfinder.mobi/
X-Requested-With: XMLHttpRequest
Connection: keep-alive
     host       apothekenfinder.mobi
     httpheader HTTP/1.1 200 OK
Date: Mon, 07 Feb 2022 09:47:52 GMT
Server: Apache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 922
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
     httpversion 1.0
     hu_blocking 0
     hu_filecount 1
     hu_port    443
     hu_portSfx
     ignoreredirects 1
     loglevel   4
     path       /interface/json.php?device=web&source=not&search=49324
     protocol   https
     redirects  0
     timeout    2
     url        https://apothekenfinder.mobi/interface/json.php?device=web&source=not&search=49324
     sslargs:
   QUEUE:
   READINGS:
     2022-02-07 10:47:39   Beginn          1644220800
     2022-02-07 10:47:39   Breitengrad     52.20131
     2022-02-07 10:47:39   Ende            1644307200
     2022-02-07 10:47:39   Entfernung      8.56
     2022-02-07 10:47:39   Laengengrad     8.45689
     2022-02-07 10:38:59   Längengrad     8.45689
     2022-02-07 10:47:39   Name            Neue Apotheke Bruchmühlen
     2022-02-07 10:47:39   OSMLink         Error evaluating NotdienstApotheke userReading OSMLink: Can't modify single ref constructor in concatenation (.) or string at (eval 4505466) line 2, at EOF

     2022-02-07 10:47:39   Ort             Rödinghausen
     2022-02-07 10:47:39   Plz             32289
     2022-02-07 10:47:39   Strasse         Kilverstraße 169 -173
     2022-02-07 10:47:39   Telefax         05226 984749
     2022-02-07 10:47:39   Telefon         05226 982222
   REQUEST:
     context    reading
     data       
     header     Accept-Encoding: gzip, deflate
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6
User-Agent: Lynx/2.8.8dev.3 libwww-FM/2.14 SSL-MM/1.4.1
Referer: http://apothekenfinder.mobi/
X-Requested-With: XMLHttpRequest
Connection: keep-alive
     ignoreredirects 0
     num        unknown
     retryCount 0
     type       update
     url        https://apothekenfinder.mobi/interface/json.php?device=web&source=not&search=49324
   defptr:
     readingBase:
       Beginn     reading
       Breitengrad reading
       Ende       reading
       Entfernung reading
       Laengengrad reading
       Längengrad reading
       Name       reading
       Ort        reading
       Plz        reading
       Strasse    reading
       Telefax    reading
       Telefon    reading
     readingNum:
       Beginn     07
       Breitengrad 10
       Ende       08
       Entfernung 11
       Laengengrad 09
       Längengrad 09
       Name       01
       Ort        04
       Plz        03
       Strasse    02
       Telefax    06
       Telefon    05
     readingOutdated:
     requestReadings:
       update:
         Beginn     reading 07
         Breitengrad reading 10
         Ende       reading 08
         Entfernung reading 11
         Laengengrad reading 09
         Längengrad reading 09
         Name       reading 01
         Ort        reading 04
         Plz        reading 03
         Strasse    reading 02
         Telefax    reading 06
         Telefon    reading 05
Attributes:
   DbLogExclude .*
   enableControlSet 1
   event-on-change-reading .*
   group      A_SOS
   icon       message_attention
   reading01Encode UTF-8
   reading01JSON result_01_name
   reading01Name Name
   reading02JSON result_01_street
   reading02Name Strasse
   reading03JSON result_01_plz
   reading03Name Plz
   reading04JSON result_01_place
   reading04Name Ort
   reading05JSON result_01_number
   reading05Name Telefon
   reading06JSON result_01_fax
   reading06Name Telefax
   reading07JSON result_01_start
   reading07Name Beginn
   reading08JSON result_01_end
   reading08Name Ende
   reading09JSON result_01_lng
   reading09Name Laengengrad
   reading10JSON result_01_lat
   reading10Name Breitengrad
   reading11JSON result_01_distance
   reading11Name Entfernung
   readingEncode UTF-8
   requestHeader2 Accept-Encoding: gzip, deflate
   requestHeader3 Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6
   requestHeader4 User-Agent: Lynx/2.8.8dev.3 libwww-FM/2.14 SSL-MM/1.4.1
   requestHeader5 Referer: http://apothekenfinder.mobi/
   requestHeader6 X-Requested-With: XMLHttpRequest
   requestHeader7 Connection: keep-alive
   room       Flur
   showBody   0
   stateFormat Name, Telefon, Strasse in Plz Ort
   userReadings OSMLink { my $ret = "https:\/\/www.openstreetmap.org\/?";;\
$ret .= "mlat=".ReadingsVal($name,"Breitengrad","0");;\
$ret .= "&mlon=".ReadingsVal($name,"Laengengrad","0");;\
$ret .= "#map=18";;\
$ret .= "\/".ReadingsVal($name,"Breitengrad","0");;\
$ret .= "\/".ReadingsVal($name,"Laengengrad","0");;\
return $ret;; }
   userattr   get01Encode get01JSON get01Name get02ExtractAllJSON:0,1 getURL reading07OExpr reading08OExpr requestHeader requestHeader1
--- Ende Code ---

Gruß, Christoph

yersinia:
Da stimmt was mit deinem userReading nicht.
Das list(-Auszug) deines Devices ist

--- Code: ---   userReadings OSMLink { my $ret = "https:\/\/www.openstreetmap.org\/?";;\
$ret .= "mlat=".ReadingsVal($name,"Breitengrad","0");;\
$ret .= "&mlon=".ReadingsVal($name,"Laengengrad","0");;\
$ret .= "#map=18";;\
$ret .= "\/".ReadingsVal($name,"Breitengrad","0");;\
$ret .= "\/".ReadingsVal($name,"Laengengrad","0");;\
return $ret;; }
--- Ende Code ---
versus welche ich nutze ohne Fehlermeldung (ebenfalls list-Auszug):

--- Code: ---   userReadings OSMLink { my $ret = "https:\/\/www.openstreetmap.org\/?";
$ret .= "mlat=".ReadingsVal($name,"Breitengrad","0");
$ret .= "&mlon=".ReadingsVal($name,"Laengengrad","0");
$ret .= "#map=18";
$ret .= "\/".ReadingsVal($name,"Breitengrad","0");
$ret .= "\/".ReadingsVal($name,"Laengengrad","0");
return $ret; }
--- Ende Code ---

Hast du ggf das raw-Format als userReading kopiert? Wenn ja, probier mal die Version fürs Frontend (über Attribut userReading und dann einfach reinkopieren):

--- Code: ---OSMLink { my $ret = "https:\/\/www.openstreetmap.org\/?";
$ret .= "mlat=".ReadingsVal($name,"Breitengrad","0");
$ret .= "&mlon=".ReadingsVal($name,"Laengengrad","0");
$ret .= "#map=18";
$ret .= "\/".ReadingsVal($name,"Breitengrad","0");
$ret .= "\/".ReadingsVal($name,"Laengengrad","0");
return $ret; }
--- Ende Code ---

caldir65:
Danke,

manchmal ist man ja auch schlicht blind  ::) Jetzt funktioniert es

Gruß, Christoph

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln