MagicMirror² v2.8.0 is available! For more information about this release, check out this topic.

Modifying existing module



  • I have installed this module: https://github.com/htilburgs/MMM-MyPrayerTimes
    And I have reallized that it gives me the wrong times. So what I wanted to do is, to use the same app but with an other API. I am a very beginner in javascript and json so I have to ask you for help.

    I want just the times of a specific city. I don’t want to change it with lon, lat or the timezone. The times should be static. The code should just take the data from the API: https://ezanvakti.herokuapp.com/vakitler?ilce=10565

    What I need from this API is the value of: Aksam, Ogle, Ikindi, Imsak, Yatsi

    So what I have done is, I changed this code: https://github.com/htilburgs/MMM-MyPrayerTimes/blob/master/MMM-MyPrayerTimes.js

    Here are the changes:

    • In line 64 I changed the url to the new one: this.url = https://ezanvakti.herokuapp.com/vakitler?ilce=10565

    • I have commented the lines 92 to 113 out

    • In line 127 I changed the time of fajr to get the time of the api (Value of: Imsak):
      from:
      FajrTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Fajr) : MPT.Fajr;
      To:
      FajrTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Imsak) : MPT.Imsak;

    • I have commented the lines from 138 to 159 out

    • line 173:
      From:
      DhuhrTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Dhuhr) : MPT.Dhuhr;
      To:
      DhuhrTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Ogle) : MPT.Ogle;

    • line 195:
      From:
      AsrTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Asr) : MPT.Asr;
      To:
      AsrTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Ikindi) : MPT.Ikindi;

    • commented from 206 to 227 out

    • line 241:
      From:
      MaghribTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Maghrib) : MPT.Maghrib;
      To:
      MaghribTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Aksam) : MPT.Aksam;

    • line 263:
      From:
      IshaTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Isha) : MPT.Isha;
      To:
      IshaTimeCell.innerHTML = this.config.show24Clock == false ? this.convert24Time(MPT.Yatsi) : MPT.Yatsi;

    • commented from 274 to 295 out

    So what I know is that I am not doing the access correctly. For example the MPT.Yatsi is not correct. I also tried MPT[0].Yatsi or MPT.0.Yatsi but these also did not work.

    I do not know if I also have to change the default:{…} Would it be enough to delete the lon lat and the other components I am not using? And do I also have to change other things (files) to get it to work? I hope you guys can help me.



  • @SirVer it may be that the different API returns data in a different format.

    I am not near my computer today, so I cannot look at it



  • @sdetweil Thanks you replyed. Could you look in the code when have time?


  • Project Sponsor

    @SirVer Data returned is definitely in a different format.

    From your link:
    {"Aksam":"21:27","AyinSekliURL":"http://namazvakti.diyanet.gov.tr/images/r1.gif","Gunes":"05:48","GunesBatis":"21:20","GunesDogus":"05:55","HicriTarihKisa":"1.12.1440","HicriTarihUzun":"1 ZİLHİCCE 1440","Ikindi":"17:51","Imsak":"04:18","KibleSaati":"11:18","MiladiTarihKisa":"02.08.2019","MiladiTarihKisaIso8601":"02.08.2019","MiladiTarihUzun":"02 Ağustos 2019 Cuma","MiladiTarihUzunIso8601":"2019-08-02T00:00:00.0000000+03:00","Ogle":"13:42","Yatsi":"22:47"}

    From the link used by the MMM-PrayerTimes:
    {"code":200,"status":"OK","data":{"timings":{"Fajr":"05:27","Sunrise":"06:47","Dhuhr":"12:14","Asr":"15:20","Sunset":"17:42","Maghrib":"17:42","Isha":"18:57","Imsak":"05:17","Midnight":"00:15"},"date":{"readable":"02 Aug 2019","timestamp":"1564760362","hijri":{"date":"30-11-1440","format":"DD-MM-YYYY","day":"30","weekday":{"en":"Al Juma'a","ar":"\u0627\u0644\u062c\u0645\u0639\u0629"},"month":{"number":11,"en":"Dh\u016b al-Qa\u02bfdah","ar":"\u0630\u0648\u0627\u0644\u0642\u0639\u062f\u0629"},"year":"1440","designation":{"abbreviated":"AH","expanded":"Anno Hegirae"},"holidays":[]},"gregorian":{"date":"02-08-2019","format":"DD-MM-YYYY","day":"02","weekday":{"en":"Friday"},"month":{"number":8,"en":"August"},"year":"2019","designation":{"abbreviated":"AD","expanded":"Anno Domini"}}},"meta":{"latitude":-26.250013,"longitude":27.985634,"timezone":"Africa\/Johannesburg","method":{"id":3,"name":"Muslim World League","params":{"Fajr":18,"Isha":17}},"latitudeAdjustmentMethod":"ANGLE_BASED","midnightMode":"STANDARD","school":"STANDARD","offset":{"Imsak":0,"Fajr":0,"Sunrise":0,"Dhuhr":0,"Asr":0,"Maghrib":0,"Sunset":0,"Isha":0,"Midnight":0}}}}