[FUIP] Apotheken-Notdienst - PLZ und Ort in eine Zeile

Begonnen von caldir65, 03 November 2023, 22:29:42

Vorheriges Thema - Nächstes Thema

caldir65

Moin,

ich habe mir den Apotheken-Notdienst nachgebaut und in FUIP eingebunden.
In der letzten Fassung werden leider PLZ und Ort in zwei Readings verpackt - die würde ich jetzt gerne wieder zusammen darstellen, haber von HTML aber wenig bis keine Ahnung ...

Der HTML-View in FUIP:
<div class="sheet">
    <div class="row">
        <div class="cell">
            <img src="/fhem/ui/images/Apotheke.png" alt="Apotheke" width="60" heigth="70"/></div>
        </div>   
        <div class="row">   
              <div data-type="label"
                      <font style="font-weight: bold"
                      data-device="apotheke"
                      data-get="name" >
              </div>
              <div data-type="label"
                      data-device="apotheke"
                      data-get="strasse">
              </div>
              <div data-type="label"
                      data-device="apotheke"
                      data-get="ort">
              </div>
              <div data-type="label"
                      data-device="apotheke"
                      data-get="telefon">
              </div>
             
        </div>
    </div>
</div>

Das Quell-Device:
[code]define apotheke JsonMod https://www.aponet.de/apotheke/notdienstsuche?tx_aponetpharmacy_search[action]=result&tx_aponetpharmacy_search[controller]=Search&&tx_aponetpharmacy_search[search][lat]=52.2260592&tx_aponetpharmacy_search[search][lng]=8.31871219&tx_aponetpharmacy_search[search][radius]=8&tx_aponetpharmacy_search[token]=[my_token]&type=1981
attr apotheke DbLogExclude .*
attr apotheke alias Notdienstapotheke
attr apotheke event-on-change-reading .*
attr apotheke group A_SOS
attr apotheke icon message_medicine
attr apotheke interval 30 9 * * *
attr apotheke readingList single(jsonPath('$.results.apotheken.apotheke[0].name'), 'name', 'none');;\
single(jsonPath('$.results.apotheken.apotheke[0].strasse'), 'strasse', 'none');;\
single(jsonPath('$.results.apotheken.apotheke[0].ort'), 'ort', 'none');;\
single(jsonPath('$.results.apotheken.apotheke[0].plz'), 'plz', 'none');;\
single(jsonPath('$.results.apotheken.apotheke[0].distanz'), 'distanz', 'none');;\
single(jsonPath('$.results.apotheken.apotheke[0].telefon'), 'telefon', 'none');;\
multi(jsonPath('$.results.apotheken.apotheke.[0]'), "map_position", concat("https:\/\/www.openstreetmap.org\/?mlat=", property('.latitude'), "&mlon=", property('.longitude'), "#map=18\/", property('.latitude'), "\/", property('.longitude')));;\
multi(jsonPath('$.results.apotheken.apotheke.[0]'), 'map_route', concat("https:\/\/www.openstreetmap.org\/directions?engine=", AttrVal($name,"osm_engine","fossgis_osrm_car"), "&route=", AttrVal("global","latitude","0"), "%2C", AttrVal("global","longitude","0"), "%3B" , property('.latitude'), "%2C", property('.longitude')));;
attr apotheke room Arbeitszimmer
attr apotheke stateFormat [$name:name]<br>\
[$name:strasse]<br>\
[$name:plz] [$name:ort]<br>\
[$name:telefon]<br>\
([$name:distanz:r1] km)
#   API_LAST_MSG 200
#   API_LAST_RES 1699000200.51929
#   CFGFN     
#   DEF        https://www.aponet.de/apotheke/notdienstsuche?tx_aponetpharmacy_search[action]=result&tx_aponetpharmacy_search[controller]=Search&&tx_aponetpharmacy_search[search][lat]=52.2260592&tx_aponetpharmacy_search[search][lng]=8.31871219&tx_aponetpharmacy_search[search][radius]=8&tx_aponetpharmacy_search[token]=[my_token]&type=1981
#   FUUID      6542bac1-f33f-378b-3077-f359ff6ad1104a4c
#   NAME       apotheke
#   NEXT       2023-11-04 09:30:00
#   NR         2604
#   SECRETS    my_token
#   SOURCE     https://www.aponet.de/apotheke/notdienstsuche?tx_aponetpharmacy_search[action]=result&tx_aponetpharmacy_search[controller]=Search&&tx_aponetpharmacy_search[search][lat]=52.2260592&tx_aponetpharmacy_search[search][lng]=8.31871219&tx_aponetpharmacy_search[search][radius]=8&tx_aponetpharmacy_search[token]=XXXXXXXXXXX&type=1981 (200)
#   STATE      Sophien-Apotheke<br>
#Engelgarten 11<br>
#49xxx Ort<br>
#05xxx-xxxx<br>
#(3.4 km)
#   SVN        27933 2023-09-04 13:29:42 UTC
#   TYPE       JsonMod
#   eventCount 8
#   CONFIG:
#     IN_REQUEST 0
#     SOURCE     https://www.aponet.de/apotheke/notdienstsuche?tx_aponetpharmacy_search[action]=result&tx_aponetpharmacy_search[controller]=Search&&tx_aponetpharmacy_search[search][lat]=52.xxxxxxxx&tx_aponetpharmacy_search[search][lng]=8.xxxxxxxx&tx_aponetpharmacy_search[search][radius]=8&tx_aponetpharmacy_search[token]=[my_token]&type=1981
#     SECRET:
#   READINGS:
#     2023-11-03 09:30:00   distanz         3.4069113448399997
#     2023-11-03 09:30:00   map_position    https://www.openstreetmap.org/?mlat=52.xxxxxxxx&mlon=8.xxxxxxx#map=18/52.1976004/8.337098
#     2023-11-03 09:30:00   map_route       https://www.openstreetmap.org/directions?engine=fossgis_osrm_car&route=52.xxxxxxxx%2C8.xxxxxxxx%3B52.xxxxxxxx%2C8.xxxxxxx
#     2023-11-03 09:30:00   name            Sophien-Apotheke
#     2023-11-03 09:30:00   ort             Ort
#     2023-11-03 09:30:00   plz             49xxx
#     2023-11-03 09:30:00   strasse         Engelgarten 11
#     2023-11-03 09:30:00   telefon         05xxx-xxxx
#   hmccu:
#
setstate apotheke Sophien-Apotheke<br>\
Engelgarten 11<br>\
49xxx Ort<br>\
05xxx-xxxx<br>\
(3.4 km)
setstate apotheke 2023-11-03 09:30:00 .computedReadings map_position,name,strasse,ort,map_route,distanz,plz,telefon
setstate apotheke 2023-11-03 09:30:00 distanz 3.4069113448399997
setstate apotheke 2023-11-03 09:30:00 map_position https://www.openstreetmap.org/?mlat=52.xxxxx&mlon=8.xxxxx#map=18/52.xxxxx/8.xxxxx
setstate apotheke 2023-11-03 09:30:00 map_route https://www.openstreetmap.org/directions?engine=fossgis_osrm_car&route=52.xxxxxx%2C8.xxxxx%3B52.xxxxx%2C8.xxxxxx
setstate apotheke 2023-11-03 09:30:00 name Sophien-Apotheke
setstate apotheke 2023-11-03 09:30:00 ort Ort
setstate apotheke 2023-11-03 09:30:00 plz 49xxx
setstate apotheke 2023-11-03 09:30:00 strasse Engelgarten 11
setstate apotheke 2023-11-03 09:30:00 telefon 05xxx-xxxx


So sieht es jetzt aus:
Du darfst diesen Dateianhang nicht ansehen.

Unter der Straße steht jetzt nur der Ort - ich möchte aber Plz und Ort stehen haben - wie muß ich das jetzt anstellen?

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

betateilchen

Bau Dir doch im Quell-Device ein reading, das plz und ort schon gemeinsam enthält.

multi(jsonPath("\$.results.apotheken.apotheke[0]"),'plzort',concat(property('plz'),' ',property('ort')));

-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

caldir65

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