Hauptmenü

HTTPMOD Hilfe

Begonnen von Skipper, 20 August 2017, 20:47:38

Vorheriges Thema - Nächstes Thema

Skipper

Hallo zusammen,

ich habe folgendes HTTPMOD angelegt und bekomme per XML die Daten. Diese werden mit XPath-Strict dann in Readings gelesen.
Leider habe ich dann den Tag, den Monat, das Jahr und die jeweilige Mülltonne in einem seperaten Reading.
Oder alternativ alles aber mit den XML Tags in einem Reading. Gerne würde ich aber alles in einem Reading ohne XML Tags haben um es dann weiter zu verarbeiten. Ich will schlussendlich eine Anzeige haben welche Tonne als nächstes abgeholt wird.
Hier mein Code
defmod Muell2 HTTPMOD http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml 60
attr Muell2 userattr reading01Name reading01RecombineExpr reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict reading05Name reading05Replacement reading05ReplacementMode reading05XPath-Strict
attr Muell2 reading01Name Tag
attr Muell2 reading01RecombineExpr join ",", @matchlist
attr Muell2 reading01XPath-Strict //trashdate/day/text()
attr Muell2 reading02Name Monat
attr Muell2 reading02XPath-Strict //trashdate/month/text()
attr Muell2 reading03Name Jahr
attr Muell2 reading03XPath-Strict //trashdate/year/text()
attr Muell2 reading04Name Tonne
attr Muell2 reading04XPath-Strict //trashdate/typ/text()
attr Muell2 reading05Name Termin
attr Muell2 reading05XPath-Strict //trashdate


Mein Problem ist, dass ich es mit Regex Ausdrücken bisher nicht hinbekommen habe. Abervielleicht gibt es ja auch eine Möglichkeit mit den einzel Readings für Tag, Monat und Jahr etwas anzufangen. Ich wieß lieder nicht wie.

Vielen Dank schonmal im Voraus. Ich bin um jeden Hinweis dankbar. Achso ähnliche Ausdrücke wie für die Weterverarbeitung aus der Wiki haben bei mir bisher nicht funktioniert.
Und hier noch ein Ausschnitt der Daten. Für die die keine Lust haben den Link mal aufzurufen.
<trashdates> <trashdate> <day>1</day> <month>6</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>1</day> <month>6</month> <year>2017</year> <typ>blue</typ> </trashdate> <trashdate> <day>2</day> <month>2</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>2</day> <month>5</month> <year>2017</year> <typ>wertstoff</typ> </trashdate> <trashdate> <day>2</day> <month>10</month> <year>2017</year> <typ>wertstoff</typ> </trashdate> <trashdate> <day>3</day> <month>3</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>3</day> <month>4</month> <year>2017</year> <typ>wertstoff</typ> </trashdate> <trashdate> <day>3</day> <month>8</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>3</day> <month>11</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>3</day> <month>11</month> <year>2017</year> <typ>blue</typ> </trashdate> <trashdate> <day>4</day> <month>9</month> <year>2017</year> <typ>wertstoff</typ> </trashdate> <trashdate> <day>5</day> <month>1</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>5</day> <month>5</month> <year>2017</year> <typ>grey</typ> </trashdate> <trashdate> <day>5</day> <month>5</month> <year>2017</year> <typ>blue</typ> </trashdate> <trashdate> <day>6</day> <month>2</month> <year>2017</year> <typ>wertstoff</typ> </trashdate>

andies

Also mit regex mache ich das immer so (bin da auch kein Profi): ich gehe auf regex101.com und teste so lange, bis es klappt. Habe mir mal deine graue Tonne angesehen und der folgende Regex liefert alle Einträge
<trashdate>
  <day>(\d+)<\/day>
  <month>(\d+)<\/month>
  <year>(\d+)<\/year>
  <typ>grey<\/typ>
<\/trashdate>

Achte auf die Leerzeichen, da kann man wahnsinnig werden. Die müssen exakt stimmen. Es werden dann alle Aufkommen angezeigt und in $1 steht der Tag, $2 der Monat und $3 das Jahr. Ich weiß jetzt nicht sofort, wie man das in FHEM umsetzt, aber damit müsste das irgendwie gehen.
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

viegener

Vielleicht kannst Du ja einfach die 3 readings in einem userreading zusammenzufügen?

So etwas wie (hmd sei der httpmoddevice)

attr hmd  userReadings datum { ReadingsVal("hmd ","tag",0)."."ReadingsVal("hmd ","monat",0)."."ReadingsVal("hmd ","jahr",0)..;; }
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

Skipper

Beides eine gute Idee.

Ich versuche gerade beides umzusetzen. Leider klappts irgendwie nicht so ganz.
Mein HTTPMOD sieht im Moment so aus:
defmod Muell2 HTTPMOD http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml 60
attr Muell2 userattr reading01Name reading01RecombineExpr reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict reading05Name reading05Regex
attr Muell2 enableControlSet 1
attr Muell2 reading01Name Tag
attr Muell2 reading01XPath-Strict //trashdate/day/text()
attr Muell2 reading02Name Monat
attr Muell2 reading02XPath-Strict //trashdate/month/text()
attr Muell2 reading03Name Jahr
attr Muell2 reading03XPath-Strict //trashdate/year/text()
attr Muell2 reading04Name Tonne
attr Muell2 reading04XPath-Strict //trashdate/typ/text()
attr Muell2 reading05Name Termin
attr Muell2 reading05Regex <trashdate>   <day>(\d+)<\/day>   <month>(\d+)<\/month>   <year>(\d+)<\/year>   <typ>grey<\/typ>  <\/trashdate>
attr Muell2 room Muell,Unsorted
attr Muell2 userReadings datum { ReadingsVal("Muell2","Tag",0).".".ReadingsVal("Muell2 ","Monat",0).".".ReadingsVal("Muell2","Jahr",0)..;; }

andies

FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

andies

Und mach mal ein List von deinem device, list Muell2
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

Skipper

#6
Ich habe jetzt folgendes eingefügt:
attr Muell2 reading05Regex (?s)<trashdate>.+<day>(\d+)<\/day>.+<month>(\d+)<\/month>.+<year>(\d+)<\/year>.+<typ>grey<\/typ>.+<\/trashdate>

Damit liest er mir das aller letzte Datum aus Mehr leider nicht aber auch in 3 Readings nicht in einem.

Und hier jetzt das sehr lange List:
Internals:
   BUSY       0
   DEF        http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml 60
   Interval   60
   LASTSEND   1503258822.20848
   MainURL    http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml
   ModuleVersion 3.3.11 - 8.5.2017
   NAME       Muell2
   NR         31
   STATE      ???
   TRIGGERTIME 1503258882.20821
   TRIGGERTIME_FMT 2017-08-20 21:54:42
   TYPE       HTTPMOD
   XPathStrictEnabled 1
   addr       http://www.awbkoeln.de:80
   buf        HTTP/1.1 200 OK

Date: Sun, 20 Aug 2017 19:53:42 GMT

Server: Apache

Access-Control-Allow-Origin: *

X-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

Cache-Control: max-age=0

Expires: Sun, 20 Aug 2017 19:53:42 GMT

X-UA-Compatible: IE=edge

X-Content-Type-Options: nosniff

Vary: Accept-Encoding

Connection: close

Content-Type: text/html; charset=utf-8



<?xml version="1.0" encoding="UTF-8"?>
<trashdates>
<trashdate>
  <day>1</day>
  <month>6</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>1</day>
  <month>6</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>2</day>
  <month>2</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>2</day>
  <month>5</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>2</day>
  <month>10</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>3</day>
  <month>3</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>3</day>
  <month>4</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>3</day>
  <month>8</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>3</day>
  <month>11</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>3</day>
  <month>11</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>4</day>
  <month>9</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>5</day>
  <month>1</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>5</day>
  <month>5</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>5</day>
  <month>5</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>2</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>3</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>4</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>4</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>7</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>10</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>6</day>
  <month>10</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>7</day>
  <month>8</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>7</day>
  <month>9</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>7</day>
  <month>9</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>7</day>
  <month>12</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>1</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>2</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>2</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>3</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>3</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>6</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>9</day>
  <month>11</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>10</day>
  <month>7</month>
  <year>2017</year>
  <typ>wertstoff</typ>
</trashdate>
<trashdate>
  <day>10</day>
  <month>8</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
<trashdate>
  <day>10</day>
  <month>8</month>
  <year>2017</year>
  <typ>blue</typ>
</trashdate>
<trashdate>
  <day>11</day>
  <month>5</month>
  <year>2017</year>
  <typ>grey</typ>
</trashdate>
......
</trashdates>
   code       200
   conn
   data
   displayurl http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml
   header
   host       www.awbkoeln.de
   httpheader HTTP/1.1 200 OK

Date: Sun, 20 Aug 2017 19:53:42 GMT

Server: Apache

Access-Control-Allow-Origin: *

X-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

Cache-Control: max-age=0

Expires: Sun, 20 Aug 2017 19:53:42 GMT

X-UA-Compatible: IE=edge

X-Content-Type-Options: nosniff

Vary: Accept-Encoding

Connection: close

Content-Type: text/html; charset=utf-8
   httpversion 1.0
   hu_blocking 0
   hu_filecount 35
   hu_portSfx
   ignoreredirects 0
   loglevel   4
   path       /sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml
   protocol   http
   redirects  0
   timeout    2
   url        http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml
   value      0
   QUEUE:
   READINGS:
     2017-08-20 21:53:42   Jahr-1          2017
     2017-08-20 21:53:42   Jahr-10         2017
     2017-08-20 21:53:42   Jahr-100        2017
     2017-08-20 21:53:42   Jahr-101        2017
     2017-08-20 21:53:42   Jahr-102        2017
     2017-08-20 21:53:42   Jahr-103        2017
     2017-08-20 21:53:42   Jahr-104        2017
     2017-08-20 21:53:42   Jahr-11         2017
     2017-08-20 21:53:42   Jahr-12         2017
     2017-08-20 21:53:42   Jahr-13         2017
     2017-08-20 21:53:42   Jahr-14         2017
     2017-08-20 21:53:42   Jahr-15         2017
     2017-08-20 21:53:42   Jahr-16         2017
     2017-08-20 21:53:42   Jahr-17         2017
     2017-08-20 21:53:42   Jahr-18         2017
     2017-08-20 21:53:42   Jahr-19         2017
     2017-08-20 21:53:42   Jahr-2          2017
     2017-08-20 21:53:42   Jahr-20         2017
     2017-08-20 21:53:42   Jahr-21         2017
     2017-08-20 21:53:42   Jahr-22         2017
     2017-08-20 21:53:42   Jahr-23         2017
     2017-08-20 21:53:42   Jahr-24         2017
     2017-08-20 21:53:42   Jahr-25         2017
     2017-08-20 21:53:42   Jahr-26         2017
     2017-08-20 21:53:42   Jahr-27         2017
     2017-08-20 21:53:42   Jahr-28         2017
     2017-08-20 21:53:42   Jahr-29         2017
....
     2017-08-20 21:53:42   Monat-77        2
     2017-08-20 21:53:42   Monat-78        3
     2017-08-20 21:53:42   Monat-79        3
     2017-08-20 21:53:42   Monat-8         8
     2017-08-20 21:53:42   Monat-80        11
     2017-08-20 21:53:42   Monat-81        12
     2017-08-20 21:53:42   Monat-82        7
     2017-08-20 21:53:42   Monat-83        8
     2017-08-20 21:53:42   Monat-84        8
     2017-08-20 21:53:42   Monat-85        1
     2017-08-20 21:53:42   Monat-86        1
     2017-08-20 21:53:42   Monat-87        5
     2017-08-20 21:53:42   Monat-88        6
     2017-08-20 21:53:42   Monat-89        10
     2017-08-20 21:53:42   Monat-9         11
     2017-08-20 21:53:42   Monat-90        4
     2017-08-20 21:53:42   Monat-91        7
     2017-08-20 21:53:42   Monat-92        7
     2017-08-20 21:53:42   Monat-93        11
     2017-08-20 21:53:42   Monat-94        9
     2017-08-20 21:53:42   Monat-95        10
     2017-08-20 21:53:42   Monat-96        5
     2017-08-20 21:53:42   Monat-97        6
     2017-08-20 21:53:42   Monat-98        6
     2017-08-20 21:53:42   Monat-99        12
     2017-08-20 21:53:42   Tag-1           1
     2017-08-20 21:53:42   Tag-10          3
     2017-08-20 21:53:42   Tag-100         29
   ....
     2017-08-20 21:53:42   Tag-96          29
     2017-08-20 21:53:42   Tag-97          29
     2017-08-20 21:53:42   Tag-98          29
     2017-08-20 21:53:42   Tag-99          29

     2017-08-20 21:53:42   Termin-1        31
     2017-08-20 21:53:42   Termin-2        8
     2017-08-20 21:53:42   Termin-3        2017

     2017-08-20 21:53:42   Tonne-1         grey
     2017-08-20 21:53:42   Tonne-10        blue
     2017-08-20 21:53:42   Tonne-100       blue
     2017-08-20 21:53:42   Tonne-101       grey
     2017-08-20 21:53:42   Tonne-102       grey
     2017-08-20 21:53:42   Tonne-103       blue
     2017-08-20 21:53:42   Tonne-104       grey
     2017-08-20 21:53:42   Tonne-11        wertstoff
     2017-08-20 21:53:42   Tonne-12        grey
     2017-08-20 21:53:42   Tonne-13        grey
     2017-08-20 21:53:42   Tonne-14        blue
     2017-08-20 21:53:42   Tonne-15        wertstoff
     2017-08-20 21:53:42   Tonne-16        wertstoff
     2017-08-20 21:53:42   Tonne-17        grey
     2017-08-20 21:53:42   Tonne-18        blue
     2017-08-20 21:53:42   Tonne-19        grey
     
     2017-08-20 21:53:42   Tonne-82        wertstoff
     2017-08-20 21:53:42   Tonne-83        grey
     2017-08-20 21:53:42   Tonne-84        blue
     2017-08-20 21:53:42   Tonne-85        grey
     2017-08-20 21:53:42   Tonne-86        blue
     2017-08-20 21:53:42   Tonne-87        grey
     2017-08-20 21:53:42   Tonne-88        wertstoff
     2017-08-20 21:53:42   Tonne-89        grey
     2017-08-20 21:53:42   Tonne-9         grey
     2017-08-20 21:53:42   Tonne-90        grey
     2017-08-20 21:53:42   Tonne-91        grey
     2017-08-20 21:53:42   Tonne-92        blue
     2017-08-20 21:53:42   Tonne-93        wertstoff
     2017-08-20 21:53:42   Tonne-94        grey
     2017-08-20 21:53:42   Tonne-95        wertstoff
     2017-08-20 21:53:42   Tonne-96        wertstoff
     2017-08-20 21:53:42   Tonne-97        grey
     2017-08-20 21:53:42   Tonne-98        blue
     2017-08-20 21:53:42   Tonne-99        grey
   REQUEST:
     data
     header
     ignoreredirects 0
     retryCount 0
     type       update
     url        http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=xml
     value      0
   defptr:
     readingBase:
       Jahr-1     reading
       Jahr-10    reading
       Jahr-100   reading
       Jahr-101   reading
       Jahr-102   reading
       Jahr-103   reading
       Jahr-104   reading
       Jahr-11    reading
       Jahr-12    reading
       Jahr-13    reading
       Jahr-14    reading
       Jahr-15    reading
       Jahr-16    reading
       Jahr-17    reading
       Jahr-18    reading
       Jahr-19    reading
       Jahr-2     reading
       Jahr-20    reading
       Jahr-21    reading
       Jahr-22    reading
       Jahr-23    reading
       Jahr-24    reading
       Jahr-25    reading
       Jahr-26    re

Skipper

sslargs:
Attributes:
   enableControlSet 1
   reading01Name Tag
   reading01XPath-Strict //trashdate/day/text()
   reading02Name Monat
   reading02XPath-Strict //trashdate/month/text()
   reading03Name Jahr
   reading03XPath-Strict //trashdate/year/text()
   reading04Name Tonne
   reading04XPath-Strict //trashdate/typ/text()
   reading05Name Termin
   reading05Regex (?s)<trashdate>.+<day>(\d+)<\/day>.+<month>(\d+)<\/month>.+<year>(\d+)<\/year>.+<typ>grey<\/typ>.+<\/trashdate>
   room       Muell,Unsorted
   userattr   reading01Name reading01RecombineExpr reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict reading05Name reading05Regex

Prof. Dr. Peter Henning

1 .Bitte den obigen Post editieren - da blättert man sich tot. Für so etwas gibt es code Tags

2. Textverarbeitung idealerweise mit einem Perl-Programm.

LG

pah

andies

#9
Ich denke mal laut. Die XPath-Sachen (die ich nicht kenne) werfen dir also alle Tage, dafür aber nacheinander, aus. Das ist natürlich wenig hilfreich.

Willst du alle Tage haben? Oder nur den nächsten? Dann könnte man versuchen, den Monat einzugrenzen. Beispielsweise, indem du in den Regex den aktuellen Monat (also die entsprechende Nummer) einträgst. Wie das allerdings ohne Perl geht, sehe ich nicht sofort.
FHEM 6.1 auf RaspPi3 (Raspbian:  6.1.21-v8+; Perl: v5.32.1)
SIGNALduino (433 MHz) und HM-UART (868 MHz), Sonoff, Blitzwolf, Somfy RTS, CAME-Gartentor, Volkszähler, Keyence-Sensor, Homematic-Sensoren und -thermostat, Ferraris-Zähler für Wasseruhr, Openlink-Nachbau Viessmann

amenomade

Du kannst auch mit JSON abrufen (&form=json in der URL):

defmod abfall HTTPMOD http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=json 60
attr abfall reading01JSON trashdates_trashdate_01
attr abfall reading01Name termin01
attr abfall reading01RecombineExpr { return sprintf("%04d%02d%02d-",@matchlist[3],@matchlist[1],@matchlist[0]).@matchlist[2]}


Ergebnis:
termin01     20170601-grey
Wenn Du alle in einem Reading möchtest, dann
defmod abfall HTTPMOD http://www.awbkoeln.de/sensis/trashdate.php?streetnumber=7&streetcode=2144&startyear=2017&endyear=2018&startmonth=1&endmonth=12&form=json 60
attr abfall reading01JSON trashdates_trashdate
attr abfall reading01Name termin
attr abfall reading01RecombineExpr join ",", @matchlist


Ergebnis:
termin       1,6,grey,2017,1,6,blue,2017,2,2,grey,2017,2,5,wertstoff,2017,2,10,wertstoff,2017,3,3,grey,2017,3,4,wertstoff,2017,3,8,grey,2017,3,11,grey,2017,29,12,blue,2017,30,3,grey,2017,30,11,grey,2017,30,11,blue,2017,31,8,grey,2017,3,11,blue,2017,4,9,wertstoff,2017,5,1,grey,2017,5,5,grey,2017,5,5,blue,2017,6,2,wertstoff,2017,6,3,wertstoff,2017,6,4,grey,2017,6,4,blue,2017,6,7,grey,2017,6,10,grey,2017,6,10,blue,2017,7,8,wertstoff,2017,7,9,grey,2017,7,9,blue,2017,7,12,grey,2017,9,1,wertstoff,2017,9,2,grey,2017,9,2,blue,2017,9,3,grey,2017,9,3,blue,2017,9,6,grey,2017,9,11,grey,2017,10,7,wertstoff,2017,10,8,grey,2017,10,8,blue,2017,11,5,grey,2017,11,12,wertstoff,2017,12,1,grey,2017,12,1,blue,2017,12,4,grey,2017,12,6,wertstoff,2017,12,10,grey,2017,13,7,grey,2017,13,7,blue,2017,13,11,wertstoff,2017,14,9,grey,2017,14,12,grey,2017,14,12,blue,2017,15,5,wertstoff,2017,16,2,grey,2017,16,3,grey,2017,16,6,grey,2017,16,6,blue,2017,16,10,wertstoff,2017,16,11,grey,2017,16,11,blue,2017,17,8,grey,2017,18,4,wertstoff,2017,18,5,grey,2017,18,5,blue,2017,18,9,wertstoff,2017,19,1,grey,2017,19,10,grey,2017,19,10,blue,2017,20,2,wertstoff,2017,20,3,wertstoff,2017,20,7,grey,2017,21,4,grey,2017,21,4,blue,2017,21,8,wertstoff,2017,21,9,grey,2017,21,9,blue,2017,21,12,grey,2017,22,6,grey,2017,23,1,wertstoff,2017,23,2,grey,2017,23,2,blue,2017,23,3,grey,2017,23,3,blue,2017,23,11,grey,2017,23,12,wertstoff,2017,24,7,wertstoff,2017,24,8,grey,2017,24,8,blue,2017,26,1,grey,2017,26,1,blue,2017,26,5,grey,2017,26,6,wertstoff,2017,26,10,grey,2017,27,4,grey,2017,27,7,grey,2017,27,7,blue,2017,27,11,wertstoff,2017,28,9,grey,2017,28,10,wertstoff,2017,29,5,wertstoff,2017,29,6,grey,2017,29,6,blue,2017,29,12,grey,2017
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

#11
Variante zu join:

attr abfall reading01RecombineExpr {my $result; for my $i (0 .. $#matchlist) { if ($i%4 == 0) { $result.= sprintf("%04d%02d%02d-",$matchlist[$i+3],$matchlist[$i+1],$matchlist[$i]).$matchlist[$i+2]." ";}}; return $result;}

Ergebnis:
termin       20170601-grey 20170601-blue 20170202-grey 20170502-wertstoff 20171002-wertstoff 20170303-grey 20170403-wertstoff 20170803-grey 20171103-grey 20171229-blue 20170330-grey 20171130-grey 20171130-blue 20170831-grey 20171103-blue 20170904-wertstoff 20170105-grey 20170505-grey 20170505-blue 20170206-wertstoff 20170306-wertstoff 20170406-grey 20170406-blue 20170706-grey 20171006-grey 20171006-blue 20170807-wertstoff 20170907-grey 20170907-blue 20171207-grey 20170109-wertstoff 20170209-grey 20170209-blue 20170309-grey 20170309-blue 20170609-grey 20171109-grey 20170710-wertstoff 20170810-grey 20170810-blue 20170511-grey 20171211-wertstoff 20170112-grey 20170112-blue 20170412-grey 20170612-wertstoff 20171012-grey 20170713-grey 20170713-blue 20171113-wertstoff 20170914-grey 20171214-grey 20171214-blue 20170515-wertstoff 20170216-grey 20170316-grey 20170616-grey 20170616-blue 20171016-wertstoff 20171116-grey 20171116-blue 20170817-grey 20170418-wertstoff 20170518-grey 20170518-blue 20170918-wertstoff 20170119-grey 20171019-grey 20171019-blue 20170220-wertstoff 20170320-wertstoff 20170720-grey 20170421-grey 20170421-blue 20170821-wertstoff 20170921-grey 20170921-blue 20171221-grey 20170622-grey 20170123-wertstoff 20170223-grey 20170223-blue 20170323-grey 20170323-blue 20171123-grey 20171223-wertstoff 20170724-wertstoff 20170824-grey 20170824-blue 20170126-grey 20170126-blue 20170526-grey 20170626-wertstoff 20171026-grey 20170427-grey 20170727-grey 20170727-blue 20171127-wertstoff 20170928-grey 20171028-wertstoff 20170529-wertstoff 20170629-grey 20170629-blue 20171229-grey

Und bitte /code Tag am Ende deiner List hieroben!
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

amenomade

Kann man sogar sortieren:
attr abfall reading01RecombineExpr {my $result;; for my $i (0 .. $#matchlist) { if ($i%4 == 0) { $result.= sprintf("%04d%02d%02d-",$matchlist[$i+3],$matchlist[$i+1],$matchlist[$i]).$matchlist[$i+2]." ";;}};;   return join("\n",sort(split(' ',$result)));;}

Ergebnis in termin:
20170105-grey
20170109-wertstoff
20170112-blue
20170112-grey
20170119-grey
20170123-wertstoff
20170126-blue
20170126-grey
20170202-grey
20170206-wertstoff
20170209-blue
20170209-grey
20170216-grey
20170220-wertstoff
20170223-blue
20170223-grey
20170303-grey
20170306-wertstoff
20170309-blue
20170309-grey
20170316-grey
20170320-wertstoff
20170323-blue
20170323-grey
20170330-grey
20170403-wertstoff
20170406-blue
20170406-grey
20170412-grey
20170418-wertstoff
20170421-blue
20170421-grey
20170427-grey
20170502-wertstoff
20170505-blue
20170505-grey
20170511-grey
20170515-wertstoff
20170518-blue
20170518-grey
20170526-grey
20170529-wertstoff
20170601-blue
20170601-grey
20170609-grey
20170612-wertstoff
20170616-blue
20170616-grey
20170622-grey
20170626-wertstoff
20170629-blue
20170629-grey
20170706-grey
20170710-wertstoff
20170713-blue
20170713-grey
20170720-grey
20170724-wertstoff
20170727-blue
20170727-grey
20170803-grey
20170807-wertstoff
20170810-blue
20170810-grey
20170817-grey
20170821-wertstoff
20170824-blue
20170824-grey
20170831-grey
20170904-wertstoff
20170907-blue
20170907-grey
20170914-grey
20170918-wertstoff
20170921-blue
20170921-grey
20170928-grey
20171002-wertstoff
20171006-blue
20171006-grey
20171012-grey
20171016-wertstoff
20171019-blue
20171019-grey
20171026-grey
20171028-wertstoff
20171103-blue
20171103-grey
20171109-grey
20171113-wertstoff
20171116-blue
20171116-grey
20171123-grey
20171127-wertstoff
20171130-blue
20171130-grey
20171207-grey
20171211-wertstoff
20171214-blue
20171214-grey
20171221-grey
20171223-wertstoff
20171229-blue
20171229-grey


Man könnte auch die vergangene Termine ausfiltern, usw usw...
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Skipper

#13
Sorry, war gestern dann nicht mehr online.

Hab oben den Code Tag hinzugebastelt.

Ich werde das hier erwähnte heute mal ausprobieren. Im Prinzip will ich mir die nächste Leerung anzeigen lassen. wobei bei uns meist die graue und die blaue auf einen Termin fallen.
Ich habe bisher nichts wirklich selber mit Perl gemacht. Wenn dann habe ich es nur hier irgendwoher kopiert und maximal ein bisschen angepasst. Deswegen ist mein erster Gedanke meist auch nicht gleich Perl.
Ich werde mich wohl daran gewöhnen. ;)
Aber danke auf jedenfall schonmal für die vielen Tips
Ja ich wusste, dass ich auch JSON nehmen kann, mir schien es nur auf den ersten Blick mit XML einfacher. Aber da hab ich mich dann wohl geirrt.

Könnt ihr mir vielleicht auch das hier erklären?
{ return sprintf("%04d%02d%02d-",@matchlist[3],@matchlist[1],@matchlist[0]).@matchlist[2]}
Ich verstehe nicht was es mit den matchlisten auf sich hat und wo die herkommen?

Skipper

#14
Hab mir jetzt folgendes in das Attribut gebaut. So bekomme ich jetzt immer den nächsten Termin für die jeweilige Tonne angezeigt.
Danke auf jedenfall für die Unterstützung. Hat mir sehr geholfen.


attr abfall reading02JSON trashdates_trashdate
attr abfall reading02Name Wertstofftonne
attr abfall reading02RecombineExpr
{
my $heute=strftime('%Y%m%d', localtime);;
my $result=99999999;;
my $termin;;
for my $i (0 .. $#matchlist)
{
if ($i%4 == 0)
{
if ($matchlist[$i+2]=="wertstoff"){
$termin= sprintf("%04d%02d%02d",$matchlist[$i+3],$matchlist[$i+1],$matchlist[$i]);;
if($termin>=$heute&&$termin<$result){
$result=$termin;;
}
}
}
};;   
return $result;;
}