Autor Thema: HTTPMod und RegEX  (Gelesen 226 mal)

Offline stera

  • Full Member
  • ***
  • Beiträge: 310
HTTPMod und RegEX
« am: 07 Januar 2021, 20:02:55 »
Hallo zusammen,

ich bin fast am Ziel mit meinem RegEx. Ich habe nur das Problem, dass er zwei Matches findet und mir immer den letzten Treffer als Reading ausgibt. Möchte gerne den Windrichtungstext von Wetteronline auslesen.
Hier ein kurzer Ausschnitt, wo ich gerne nur den ersten Match haben möchte:

Mein Regex:
(?s)daySynonym: "heute",.*?dayTime: "day".*?windSpeedText: "(.*?Wind)

Kann man diesen Absatz zwischen daySynonym und dayTime irgendwie anders erkennen außer mit .*?
bzw. ein Verbund hinbekommen

Beim OnlineRegTester geht es wohl, wenn man den Flag von /g auf /m umstellt, aber ein
attr WetterOnline reading01RegOpt s
funktioniert in Fhem leider nicht

Habt ihr einen Tipp?

Danke,
Stefan


« Letzte Änderung: 07 Januar 2021, 20:09:29 von stera »

Offline stera

  • Full Member
  • ***
  • Beiträge: 310
Antw:HTTPMod und RegEX
« Antwort #1 am: 07 Januar 2021, 20:07:10 »
Irgendwie kann ich den Anfangspost nur mit Fehler ändern. deswegen hier nochmal den code


    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -2,
        daySynonym: "heute",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 16,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "60",
        precipitationProbability: 95,
        smog: "",
        snowProbability: 30,
        symbol: "bdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nordost",
        windDirectionShortSector: "NE",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1010,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 17,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "60",
        precipitationProbability: 90,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nordost",
        windDirectionShortSector: "NE",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1010,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 18,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "60",
        precipitationProbability: 90,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nordost",
        windDirectionShortSector: "NE",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1010,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 19,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "60",
        precipitationProbability: 70,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nordost",
        windDirectionShortSector: "NE",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1010,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 20,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "60",
        precipitationProbability: 70,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nordost",
        windDirectionShortSector: "NE",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1010,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 21,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0-10",
        precipitationProbability: 60,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nordost",
        windDirectionShortSector: "NE",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 22,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "heute",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 23,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -2,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 0,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 20,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 1,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 20,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 2,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 20,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 100
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 3,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 20,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "schwacher Wind",
        windy: "",
        airPressure: 1011,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 4,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0-10",
        precipitationProbability: 60,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1011,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 5,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0-10",
        precipitationProbability: 60,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1011,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 6,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0-10",
        precipitationProbability: 50,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1012,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 7,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0-10",
        precipitationProbability: 50,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "3",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "20",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1012,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 8,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0-10",
        precipitationProbability: 50,
        smog: "",
        snowProbability: 30,
        symbol: "mdsn1_",
        symbolText: "leichter Schneefall",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "opened",
        weatherInfoIndex: "2",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1013,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 9,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "bd____",
        symbolText: "bedeckt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1013,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 10,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1014,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 11,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 20,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1014,
        humidity: 95
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 12,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 30,
        smog: "",
        snowProbability: 20,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1014,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 13,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 30,
        smog: "",
        snowProbability: 20,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "5",
        windGustsKmh: "30",
        windSpeedBft: "3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1014,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -3,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 14,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 30,
        smog: "",
        snowProbability: 20,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "5",
        windGustsKmh: "30",
        windSpeedBft: "3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1015,
        humidity: 85
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 15,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 20,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "5",
        windGustsKmh: "30",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1015,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "day",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 16,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "wb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "5",
        windGustsKmh: "30",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1015,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 17,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 40,
        symbol: "mb____",
        symbolText: "teils bew&ouml;lkt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "2",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "5",
        windGustsKmh: "30",
        windSpeedBft: "2-3",
        windSpeedKmh: "10",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1016,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 18,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "2",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1017,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 19,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "2",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1017,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -4,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 20,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: 0,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1017,
        humidity: 90
    });
</script>
<script>
    WO = WO || {};
    WO.metadata = WO.metadata || {};
    WO.metadata.p_city_weather = WO.metadata.p_city_weather || {};
    WO.metadata.p_city_weather.hourlyForecastElements = WO.metadata.p_city_weather.hourlyForecastElements || [];
    WO.metadata.p_city_weather.hourlyForecastElements.push({
        apparentTemperature: -5,
        daySynonym: "morgen",
        dayTime: "night",
        docrootVersion: "1.1.239",
        freshSnowDepth: 0,
        hour: 21,
        hourlyPrecipitationAmount: "0-0,5",
        hourlyPrecipitationDuration: "0",
        precipitationProbability: 40,
        smog: "",
        snowProbability: 30,
        symbol: "md____",
        symbolText: "bedeckt",
        temperature: -1,
        thunderstormProbability: 0,
        tierAppendix: "",
        umbrellaState: "closed",
        weatherInfoIndex: "0",
        windDirection: "Nord",
        windDirectionShortSector: "N",
        windGusts: "4",
        windGustsKmh: "25",
        windSpeedBft: "2-3",
        windSpeedKmh: "15",
        windSpeedText: "m&auml;&szlig;iger Wind",
        windy: "",
        airPressure: 1018,
« Letzte Änderung: 07 Januar 2021, 20:12:06 von stera »

Offline stera

  • Full Member
  • ***
  • Beiträge: 310
Antw:HTTPMod und RegEX
« Antwort #2 am: 09 Januar 2021, 13:23:00 »
Hallo,

ich habe den RegEx nochmal etwas umgestellt. Falls einer Interesse hat, kann er das für die aktuelle Stunde von WetterOnline nutzen. Eigentlich muss man nur den Stadtname bei der URL ändern. Bei uns passen die Wetterdaten immer am besten.

defmod HttpModWetterOnline HTTPMOD https://www.wetteronline.de/wetter/hamburg 300
attr HttpModWetterOnline userattr event-on-change-reading reading01Decode reading01Name reading01RegOpt reading01Regex reading02Name reading02RegOpt reading02Regex reading03Name reading03Regex reading04Name reading04Regex reading05Name reading05Regex reading06Name reading06Regex readingEncode readingOExpr stateFormat timeout verbose
attr HttpModWetterOnline reading01Name windSpeedText
attr HttpModWetterOnline reading01Regex (?s)<div id="hourly-container"><script>.*?windSpeedText: "(.*?)",
attr HttpModWetterOnline reading02Name windDirection
attr HttpModWetterOnline reading02Regex (?s)<div id="hourly-container"><script>.*?windDirection: "(.*?)",
attr HttpModWetterOnline reading03Name windDirectionShortSector
attr HttpModWetterOnline reading03Regex (?s)<div id="hourly-container"><script>.*?windDirectionShortSector: "(.*?)",
attr HttpModWetterOnline reading04Name hour
attr HttpModWetterOnline reading04Regex (?s)<div id="hourly-container"><script>.*?hour: (.*?),
attr HttpModWetterOnline reading05Name symbolText
attr HttpModWetterOnline reading05Regex (?s)<div id="hourly-container"><script>.*?symbolText: "(.*?)",
attr HttpModWetterOnline reading06Name temperature
attr HttpModWetterOnline reading06Regex (?s)<div id="hourly-container"><script>.*?temperature: (.*?),
attr HttpModWetterOnline readingOExpr $val =~ s/\<br\>/ | /g;; $val =~ s/(&auml;;)/ä/g;; $val =~ s/(&Auml;;)/Ä/g;; $val =~ s/(&ouml;;)/ö/g;; $val =~ s/(&Ouml;;)/Ö/g;;$val =~ s/(&uuml;;)/ü/g;;$val =~ s/(&Uuml;;)/Ü/g;;$val =~ s/(&szlig;;)/ß/g;;$val;;
attr HttpModWetterOnline room 03_Überwachung
attr HttpModWetterOnline timeout 5
attr HttpModWetterOnline userReadings tabletui_row1 { ReadingsVal("$name","windSpeedText","")." aus ".ReadingsVal("$name","windDirectionShortSector","") }
attr HttpModWetterOnline verbose 0

Es lassen sich noch paar mehr Parameter abfragen (siehe Thread) davor..

Schöne Grüße,
Stefan