Group Details Private

Project Sponsors

These users contributed to the project by giving a donation: http://magicmirror.builders/donate

  • RE: Hello everyone, do you know if there is an MM module for rugby

    @Manu85 No problem. As mentioned before, if you would like to personalize the module further you are more than welcome to fork it and make whatever changes you would like.

    posted in Requests
  • RE: Hello everyone, do you know if there is an MM module for rugby

    @Manu85 I saw your request to him. The module is not built for you and only you. Others are using it right now. You don’t seem to appreciate and understand the complexities around the data and how it the API’s are defined.

    This module is being used by a number of people, and unless you raise a feature request and everybody agree to request will I entertain the idea. What you are asking for is not easily achievable with the way the API calls are structured.

    For my own personal use the module is fine as is.

    I hope you come right but this matter I consider closed now and module will remain as is.

    posted in Requests
  • RE: Hello everyone, do you know if there is an MM module for rugby

    @Manu85 The API they use is football only.

    posted in Requests
  • RE: Hello everyone, do you know if there is an MM module for rugby

    @Manu85 Hi. I do not know. If you want to ask him to create or include the rugby into his module then you are more than welcome to do so.

    posted in Requests
  • RE: Can anyone revive AviationWX, PilotWX, or TAF

    @FSAHD No donations required. We love this project and this forum. 😉

    posted in Requests
  • RE: Can anyone revive AviationWX, PilotWX, or TAF posted in Requests
  • RE: Hello everyone, do you know if there is an MM module for rugby

    @Manu85 PR = Pull Request which means you fork the module and make the relevant changes a push it back to the main repo. 😉

    posted in Requests
  • RE: Can anyone revive AviationWX, PilotWX, or TAF

    @sdetweil I have not seen another way. Sorry…🤦♂

    posted in Requests
  • RE: Can anyone revive AviationWX, PilotWX, or TAF

    @sdetweil If you want to use fetch you can do the first call as follows.

    try {
        const response = await fetch(metarUrl, {
          headers: {
            'Accept-Encoding': 'gzip', // Request gzip compression
          },
        });
    
        if (!response.ok) {
          throw new Error(`HTTP error! Status: ${response.status}`);
        }
    
        // Read response body as buffer
        const buffer = await response.buffer();
    
        // Manually decompress gzip data
        const zlib = require('zlib');
        const decompressedData = zlib.gunzipSync(buffer).toString();
    

    You could use pako.

    const decompressedData = pako.inflate(buffer, { to: 'string' });
    
    posted in Requests
  • RE: Can anyone revive AviationWX, PilotWX, or TAF

    @sdetweil Both calls working.

    try {
            const response = await axios.get(metarUrl, {
                responseType: 'arraybuffer', // ensure response is treated as binary
                headers: {
                    'Accept-Encoding': 'gzip', // request gzip compression
                },
            });
    
            // Unzip the gzip response
            const unzippedData = zlib.gunzipSync(response.data).toString();
    
            let json_string = convert.toJson(unzippedData);
            var json = JSON.parse(json_string);
            var metarData = json.response.data.METAR;
            var airportData = new Object();
    
            var airports = payload.airportList.split(",").map(function (airport) {
                airport = airport.trim();
                return (airport.length < 4) ? "K" + airport : airport;
            });
    
            airports.forEach(function (airport) {
                metarData.forEach(function (metar) {
                    if (airport === metar.station_id) {
                        if (this.debug)
                            console.log("METAR data found for " + airport);
                        airportData[airport] = metar;
                        return; // check next airport in list
                    }
                });
                // console.log(metarData)
            });
        } catch (error) {
            console.error('Error fetching data:', error);
        }
    
        const checktype = { "Airspace_Flow_List":"Airspace_Flow", "Ground_Delay_List": "Ground_Delay", "Arrival_Departure_Delay_List": "Delay","Airport_Closure_List":"Airport" }
    
        
        try {
            const response = await axios.get(FAAUrl);
    
            // Your further processing
            let json_string =
                //convert.toJson(test_data)     swap comments to use test FAA data
                convert.toJson(response.data.toString());
            if (this.debug)
                console.log("json faa=" + json_string);
            const faa_data = JSON.parse(json_string);
    
            if (!Array.isArray(faa_data['AIRPORT_STATUS_INFORMATION'].Delay_type)) {
                // save the current entry
                const x = faa_data['AIRPORT_STATUS_INFORMATION'].Delay_type
                //  init as an array
                faa_data['AIRPORT_STATUS_INFORMATION'].Delay_type = []
                // add the element into the array
                faa_data['AIRPORT_STATUS_INFORMATION'].Delay_type.push(x)
            }
            // loop thru the delay types
            faa_data['AIRPORT_STATUS_INFORMATION'].Delay_type.forEach(t => {
                //
                if (t.name !== "Airspace Flow Programs") {
                    // for each the  there are two major keys, name and the list for that type
                    // get the key of the list
                    const keyname = Object.keys(t)[1]
                    // remove the "_list"  part for passing to front end
                    const key = keyname.split('_').slice(0, -1).join('_')
                    if (this.debug)
                        console.log("key data=" + JSON.stringify(t[keyname][checktype[keyname]]) + "keyname=" + keyname + " key=" + checktype[keyname] + "\n")
                    if (!Array.isArray(t[keyname][checktype[keyname]])) {
                        const x = t[keyname][checktype[keyname]]
                        t[keyname][checktype[keyname]] = []
                        t[keyname][checktype[keyname]].push(x)
                    } else {
                        console.log("checkytype=" + checktype[keyname])
                    }
                    if (this.debug)
                        console.log("data=" + Object.keys(faa_data['AIRPORT_STATUS_INFORMATION'].Delay_type)[0] + " data=" + JSON.stringify(t) + " keyname=" + keyname + " key=" + key + " last part=" + JSON.stringify(t[keyname][key]) + "\n")
    
                    // look thru all the aaffected airports for this record type
                    t[keyname][checktype[keyname]].forEach(airport_record => {
                        // if the airport is one the user requested
                        if (airports.includes('K' + airport_record.ARPT)) {
                            if (airportData['K' + airport_record.ARPT]['FAA'] == undefined)
                                airportData['K' + airport_record.ARPT]['FAA'] = {}
                            // save this data record
                            airportData['K' + airport_record.ARPT]['FAA'][key] = airport_record
                        }
                    })
                }
    
            });
            // Emitting data to Socket
            //self.sendSocketNotification("WX_RESULT", airportData);
        } catch (error) {
            console.error('Error fetching FAA data:', error);
        }
    
    posted in Requests