Menturan / MMM-OpeningHours

Magic Mirror module that displays places opening hours.
GNU General Public License v3.0
12 stars 3 forks source link

Errors with more than one place #6

Open ferferga opened 5 years ago

ferferga commented 5 years ago

After verifying for weeks that there is no limitation going with the Google API, it seems that there are some issues while getting more than one place using this module. It gets stuck in a infinite "Loading..." state

I found some 403 errors in the logs while running this at the beginning, but I upgraded to a Premium account in Google and it seems that the errors are still going on. Here are the logs that appear when starting MagicMirror through npm start (hiding places names):

[19:53:38] - DEBUG - MMM-OpeningHours : Response -  { status: 200,
  headers:
   { 'content-type': 'application/json; charset=UTF-8',
     date: 'Sun, 19 May 2019 17:53:38 GMT',
     expires: 'Sun, 19 May 2019 17:58:38 GMT',
     'cache-control': 'public, max-age=300',
     server: 'scaffolding on HTTPServer2',
     'x-xss-protection': '0',
     'x-frame-options': 'SAMEORIGIN',
     'server-timing': 'gfet4t7; dur=118',
     'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  json:
   { html_attributions: [],
     result: { name: 'X', opening_hours: [Object] },
     status: 'OK' },
  requestUrl:
   'https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours&language=es&placeid=ChIJAWUYvG5sEg0RNC_oa2_gxxx&key=[HIDDEN]',
  query:
   { fields: 'name,opening_hours',
     language: 'es',
     placeid: 'ChIJAWUYvG5sEg0RNC_oa2_XXXX',
     key: '[HIDDEN]' } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response.json.result -  { name: SOMEPLACE',
  opening_hours:
   { open_now: true,
     periods:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ],
     weekday_text:
      [ 'lunes: 13:00–24:00',
        'martes: 13:00–24:00',
        'miércoles: 13:00–24:00',
        'jueves: 13:00–24:00',
        'viernes: 13:00–24:00',
        'sábado: 13:00–24:00',
        'domingo: 13:00–24:00' ] } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response -  { status: 200,
  headers:
   { 'content-type': 'application/json; charset=UTF-8',
     date: 'Sun, 19 May 2019 17:53:38 GMT',
     expires: 'Sun, 19 May 2019 17:58:38 GMT',
     'cache-control': 'public, max-age=300',
     server: 'scaffolding on HTTPServer2',
     'x-xss-protection': '0',
     'x-frame-options': 'SAMEORIGIN',
     'server-timing': 'gfet4t7; dur=120',
     'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  json:
   { html_attributions: [],
     result: { name: 'Lidl', opening_hours: [Object] },
     status: 'OK' },
  requestUrl:
   'https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours&language=es&placeid=ChIJXQ1XuWpsEg0RkbqBx1XXXX&key=[HIDDEN]',
  query:
   { fields: 'name,opening_hours',
     language: 'es',
     placeid: 'ChIJXQ1XuWpsEg0RkbqBx1OXXXX',
     key: '[HIDDEN]' } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response.json.result -  { name: 'Lidl',
  opening_hours:
   { open_now: false,
     periods:
      [ [Object], [Object], [Object], [Object], [Object], [Object] ],
     weekday_text:
      [ 'lunes: 9:00–21:30',
        'martes: 9:00–21:30',
        'miércoles: 9:00–21:30',
        'jueves: 9:00–21:30',
        'viernes: 9:00–21:30',
        'sábado: 9:00–21:30',
        'domingo: Cerrado' ] } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response -  { status: 200,
  headers:
   { 'content-type': 'application/json; charset=UTF-8',
     date: 'Sun, 19 May 2019 17:53:38 GMT',
     expires: 'Sun, 19 May 2019 17:58:38 GMT',
     'cache-control': 'public, max-age=300',
     server: 'scaffolding on HTTPServer2',
     'x-xss-protection': '0',
     'x-frame-options': 'SAMEORIGIN',
     'server-timing': 'gfet4t7; dur=208',
     'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  json:
   { html_attributions: [],
     result: { name: 'SOMEPLACE', opening_hours: [Object] },
     status: 'OK' },
  requestUrl:
   'https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours&language=es&placeid=ChIJQQDaGGxsEg0RNILE38XXXXX&key=[HIDDEN]',
  query:
   { fields: 'name,opening_hours',
     language: 'es',
     placeid: 'ChIJQQDaGGxsEg0RNILE38XXXXX',
     key: '[HIDDEN]' } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response.json.result -  { name: 'SOMEPLACE',
  opening_hours:
   { open_now: false,
     periods:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ],
     weekday_text:
      [ 'lunes: Cerrado',
        'martes: 13:00–16:00, 20:30–23:00',
        'miércoles: 13:00–16:00, 20:30–23:00',
        'jueves: 13:00–16:00, 20:30–23:00',
        'viernes: 13:00–16:00, 20:30–23:00',
        'sábado: 13:00–16:00, 20:30–23:00',
        'domingo: 13:00–16:00' ] } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response -  { status: 200,
  headers:
   { 'content-type': 'application/json; charset=UTF-8',
     date: 'Sun, 19 May 2019 17:53:38 GMT',
     expires: 'Sun, 19 May 2019 17:58:38 GMT',
     'cache-control': 'public, max-age=300',
     server: 'scaffolding on HTTPServer2',
     'x-xss-protection': '0',
     'x-frame-options': 'SAMEORIGIN',
     'server-timing': 'gfet4t7; dur=106',
     'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  json:
   { html_attributions: [],
     result: { name: 'SOMEPLACE', opening_hours: [Object] },
     status: 'OK' },
  requestUrl:
   'https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours&language=es&placeid=ChIJx5EBKW9sEg0RjZQlE_XXXXX&key=[HIDDEN]',
  query:
   { fields: 'name,opening_hours',
     language: 'es',
     placeid: 'ChIJx5EBKW9sEg0RjZQlE_XXXX',
     key: '[HIDDEN]' } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response.json.result -  { name: 'SOMEPLACE',
  opening_hours:
   { open_now: true,
     periods:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ],
     weekday_text:
      [ 'lunes: 13:00–24:00',
        'martes: 20:00–24:00',
        'miércoles: 13:00–24:00',
        'jueves: 13:00–24:00',
        'viernes: 13:00–0:30',
        'sábado: 13:00–0:30',
        'domingo: 13:00–24:00' ] } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response -  { status: 200,
  headers:
   { 'content-type': 'application/json; charset=UTF-8',
     date: 'Sun, 19 May 2019 17:53:38 GMT',
     expires: 'Sun, 19 May 2019 17:58:38 GMT',
     'cache-control': 'public, max-age=300',
     server: 'scaffolding on HTTPServer2',
     'x-xss-protection': '0',
     'x-frame-options': 'SAMEORIGIN',
     'server-timing': 'gfet4t7; dur=188',
     'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  json:
   { html_attributions: [],
     result: { name: 'SOMEPLACE', opening_hours: [Object] },
     status: 'OK' },
  requestUrl:
   'https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours&language=es&placeid=ChIJNYda7WtsEg0RCC83FLkXXXX&key=[HIDDEN]',
  query:
   { fields: 'name,opening_hours',
     language: 'es',
     placeid: 'ChIJNYda7WtsEg0RCC83FLkXXXX',
     key: '[HIDDEN]' } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response.json.result -  { name: 'SOMEPLACE',
  opening_hours:
   { open_now: false,
     periods:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ],
     weekday_text:
      [ 'lunes: 6:00–23:00',
        'martes: 6:00–23:00',
        'miércoles: 6:00–23:00',
        'jueves: 6:00–23:00',
        'viernes: 6:00–23:00',
        'sábado: 9:00–21:00',
        'domingo: 9:00–15:00' ] } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response -  { status: 200,
  headers:
   { 'content-type': 'application/json; charset=UTF-8',
     date: 'Sun, 19 May 2019 17:53:38 GMT',
     expires: 'Sun, 19 May 2019 17:58:38 GMT',
     'cache-control': 'public, max-age=300',
     server: 'scaffolding on HTTPServer2',
     'x-xss-protection': '0',
     'x-frame-options': 'SAMEORIGIN',
     'server-timing': 'gfet4t7; dur=96',
     'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  json:
   { html_attributions: [],
     result: { name: 'Burger King' },
     status: 'OK' },
  requestUrl:
   'https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours&language=es&placeid=ChIJ4Wft4C9tEg0Rlp6tR1XXXX&key=[HIDDEN]',
  query:
   { fields: 'name,opening_hours',
     language: 'es',
     placeid: 'ChIJ4Wft4C9tEg0Rlp6tR14XXXX',
     key: '[HIDDEN]' } }
[19:53:38] - DEBUG - MMM-OpeningHours : Response.json.result -  { name: 'Burger King' }
[19:53:38] - DEBUG - MMM-OpeningHours : Sending to frontend -  [ { name: 'Someplace',
    opening_hours: { open_now: true, periods: [Array], weekday_text: [Array] } },
  { name: 'Lidl',
    opening_hours: { open_now: false, periods: [Array], weekday_text: [Array] } },
  { name: 'Someplace',
    opening_hours: { open_now: false, periods: [Array], weekday_text: [Array] } },
  { name: 'someplace',
    opening_hours: { open_now: true, periods: [Array], weekday_text: [Array] } },
  { name: 'someplace',
    opening_hours: { open_now: false, periods: [Array], weekday_text: [Array] } },
  { name: 'Burger King' } ]

I use the same API key in other modules, it's that an issue? I hope not, as everything looks good in my side and the module works flawlessly with only one place configured.

ferferga commented 5 years ago

Error is thrown at line 108 here by Electron console (Cannot read property 'close' of undefined). Still trying to debug it...

Menturan commented 5 years ago

Hi @ferferga! My guess is that the faulty place is always open. In 2ec477c66c89f481be099fa8b41fc71b834d79bd and 17c3ae44e22d735dd319944e3e9f862af1998de0 I added checks for no opening hours and always open. Please pull the latest changes to see if theses checks fixes the problem.

ferferga commented 5 years ago

Hello @Menturan ! Thank you very much for pushing out some fixes. I thought the same at the beginning, but I sent the same request to Google's API using my browser and JSON data did include information related to the closing hours in all my places. So it seems that it's related to something else.

I tried today to put places one by one in the array, and I got many of them working together, but two. I inmediately noted those. However, one that worked yesterday, now it's not working, so I'm afraid to say that this seems completely random (although I know nothing in programming or technology is :D). The first place I always had working and now it isn't as I mentioned has ChIJAWUYvG5sEg0RNC_oa2_g7Oc as it's key. Can you replicate it with that place? Any other step I could take to help you to debug this?

Thank you very much for your work in this module and for bringing it to us. It was amazing when I got it to work =D

PS: If, for some chance, Google's API is not helping you with this, I don't mind sharing a key with you in private to help with this issue.

Bloham commented 5 years ago

Hi :) The Debug Log looks like a mess now ^^ By purpose (because you show more?) or did you wanted it to be formatted like the old one? I also have a problem with the updating store times (or better not updating). My store is closed on Mondays, and now it says "open in 2 days" since weeks... Unfortunately, I have no idea how to fix it. But I have great respect for your module, it's amazing when it works! Maybe I contribute a German translation, as I cannot help you more ^^

0|mm | ATTENTION: default value of option force_s3tc_enable overridden by environment. 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : Notification - SETUP 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : Started - false 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : Config - { googleApiKey: 'XXXXXXXXX', 0|mm | places: 0|mm | [ 'ChIJBe7-DVQDX0YRpNJ50BELOeU', 0|mm | 'ChIJhUQhi1MDX0YRDLOmy57Tq4Y', 0|mm | 'ChIJuULTJ8ocX0YRkzCmpaZC-7I', 0|mm | 'ChIJs7JrpFQDX0YRyz2JT-AkRyU' ], 0|mm | scheduleTime: 86400000, 0|mm | timeFormat: 24, 0|mm | language: 'en', 0|mm | styling: { showTimeUntil: true, textAlign: 'center', size: 'small' }, 0|mm | debug: true, 0|mm | mockData: false } 0|mm | [00:33:00] - MMM-OpeningHours : Fetching opening hours 0|mm | [00:33:00] - MMM-OpeningHours : Using Google Places API. 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : googlePromise - Promise { <pending> } 0|mm | [00:33:00] - MMM-OpeningHours : Using Google Places API. 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : googlePromise - Promise { <pending> } 0|mm | [00:33:00] - MMM-OpeningHours : Using Google Places API. 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : googlePromise - Promise { <pending> } 0|mm | [00:33:00] - MMM-OpeningHours : Using Google Places API. 0|mm | [00:33:00] - DEBUG - MMM-OpeningHours : googlePromise - Promise { <pending> } 0|mm | WatchDog started. Maximum timeout: 100s. 0|mm | [00:33:01] - DEBUG - MMM-OpeningHours : Response - {"status":200,"headers":{"content-type":"application/json; charset=UTF-8","date":"Mon, 20 May 2019 22:33:01 GMT","expires":"Mon, 20 May 2019 22:38:01 GMT","cache-control":"public, max-age=300","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","server-timing":"gfet4t7; dur=125","alt-svc":"quic=\":443\"; ma=2592000; v=\"46,44,43,39\"","accept-ranges":"none","vary":"Accept-Encoding","connection":"close"},"json":{"html_attributions":[],"result":{"name":"Två Goda Ting","opening_hours":{"open_now":false,"periods":[{"close":{"day":1,"time":"1800"},"open":{"day":1,"time":"1000"}},{"close":{"day":2,"time":"1800"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1800"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1800"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1800"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1800"},"open":{"day":6,"time":"1000"}}],"weekday_text":["Monday: 10:00 AM – 6:00 PM","Tuesday: 10:00 AM – 6:00 PM","Wednesday: 10:00 AM – 6:00 PM","Thursday: 10:00 AM – 6:00 PM","Friday: 10:00 AM – 6:00 PM","Saturday: 10:00 AM – 6:00 PM","Sunday: Closed"]},"place_id":"ChIJBe7-DVQDX0YRpNJ50BELOeU"},"status":"OK"},"requestUrl":"https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours%2Cplace_id&language=en&placeid=ChIJBe7-DVQDX0YRpNJ50BELOeU&key=XXXXXXXXX","query":{"fields":"name,opening_hours,place_id","language":"en","placeid":"ChIJBe7-DVQDX0YRpNJ50BELOeU","key":"XXXXXXXX"}} 0|mm | [00:33:02] - DEBUG - MMM-OpeningHours : Response - {"status":200,"headers":{"content-type":"application/json; charset=UTF-8","date":"Mon, 20 May 2019 22:33:01 GMT","expires":"Mon, 20 May 2019 22:38:01 GMT","cache-control":"public, max-age=300","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","server-timing":"gfet4t7; dur=214","alt-svc":"quic=\":443\"; ma=2592000; v=\"46,44,43,39\"","accept-ranges":"none","vary":"Accept-Encoding","connection":"close"},"json":{"html_attributions":[],"result":{"name":"Liquor Store","opening_hours":{"open_now":false,"periods":[{"close":{"day":1,"time":"1800"},"open":{"day":1,"time":"1000"}},{"close":{"day":2,"time":"1800"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1800"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1900"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1900"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1500"},"open":{"day":6,"time":"1000"}}],"weekday_text":["Monday: 10:00 AM – 6:00 PM","Tuesday: 10:00 AM – 6:00 PM","Wednesday: 10:00 AM – 6:00 PM","Thursday: 10:00 AM – 7:00 PM","Friday: 10:00 AM – 7:00 PM","Saturday: 10:00 AM – 3:00 PM","Sunday: Closed"]},"place_id":"ChIJhUQhi1MDX0YRDLOmy57Tq4Y"},"status":"OK"},"requestUrl":"https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours%2Cplace_id&language=en&placeid=ChIJhUQhi1MDX0YRDLOmy57Tq4Y&key=XXXXXXXXX","query":{"fields":"name,opening_hours,place_id","language":"en","placeid":"ChIJhUQhi1MDX0YRDLOmy57Tq4Y","key":"XXXXXXXXX"}} 0|mm | [00:33:02] - DEBUG - MMM-OpeningHours : Response - {"status":200,"headers":{"content-type":"application/json; charset=UTF-8","date":"Mon, 20 May 2019 22:33:01 GMT","expires":"Mon, 20 May 2019 22:38:01 GMT","cache-control":"public, max-age=300","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","server-timing":"gfet4t7; dur=254","alt-svc":"quic=\":443\"; ma=2592000; v=\"46,44,43,39\"","accept-ranges":"none","vary":"Accept-Encoding","connection":"close"},"json":{"html_attributions":[],"result":{"name":"Annas Hembageri","opening_hours":{"open_now":false,"periods":[{"close":{"day":2,"time":"1800"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1800"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1800"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1800"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1600"},"open":{"day":6,"time":"0900"}}],"weekday_text":["Monday: Closed","Tuesday: 10:00 AM – 6:00 PM","Wednesday: 10:00 AM – 6:00 PM","Thursday: 10:00 AM – 6:00 PM","Friday: 10:00 AM – 6:00 PM","Saturday: 9:00 AM – 4:00 PM","Sunday: Closed"]},"place_id":"ChIJuULTJ8ocX0YRkzCmpaZC-7I"},"status":"OK"},"requestUrl":"https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours%2Cplace_id&language=en&placeid=ChIJuULTJ8ocX0YRkzCmpaZC-7I&key=XXXXXXX","query":{"fields":"name,opening_hours,place_id","language":"en","placeid":"ChIJuULTJ8ocX0YRkzCmpaZC-7I","key":"XXXXXXX"}} 0|mm | [00:33:02] - DEBUG - MMM-OpeningHours : Response - {"status":200,"headers":{"content-type":"application/json; charset=UTF-8","date":"Mon, 20 May 2019 22:33:01 GMT","expires":"Mon, 20 May 2019 22:38:01 GMT","cache-control":"public, max-age=300","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","server-timing":"gfet4t7; dur=236","alt-svc":"quic=\":443\"; ma=2592000; v=\"46,44,43,39\"","accept-ranges":"none","vary":"Accept-Encoding","connection":"close"},"json":{"html_attributions":[],"result":{"name":"Gripsholm Castle","opening_hours":{"open_now":false,"periods":[{"close":{"day":0,"time":"1600"},"open":{"day":0,"time":"1000"}},{"close":{"day":1,"time":"1600"},"open":{"day":1,"time":"1000"}},{"close":{"day":2,"time":"1600"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1600"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1600"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1600"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1600"},"open":{"day":6,"time":"1000"}}],"weekday_text":["Monday: 10:00 AM – 4:00 PM","Tuesday: 10:00 AM – 4:00 PM","Wednesday: 10:00 AM – 4:00 PM","Thursday: 10:00 AM – 4:00 PM","Friday: 10:00 AM – 4:00 PM","Saturday: 10:00 AM – 4:00 PM","Sunday: 10:00 AM – 4:00 PM"]},"place_id":"ChIJs7JrpFQDX0YRyz2JT-AkRyU"},"status":"OK"},"requestUrl":"https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Copening_hours%2Cplace_id&language=en&placeid=ChIJs7JrpFQDX0YRyz2JT-AkRyU&key=XXXXXXX,"query":{"fields":"name,opening_hours,place_id","language":"en","placeid":"ChIJs7JrpFQDX0YRyz2JT-AkRyU","key":"XXXXXXX"}} 0|mm | [00:33:02] - DEBUG - MMM-OpeningHours : Sending to frontend - [{"name":"Två Goda Ting","opening_hours":{"open_now":false,"periods":[{"close":{"day":1,"time":"1800"},"open":{"day":1,"time":"1000"}},{"close":{"day":2,"time":"1800"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1800"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1800"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1800"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1800"},"open":{"day":6,"time":"1000"}}],"weekday_text":["Monday: 10:00 AM – 6:00 PM","Tuesday: 10:00 AM – 6:00 PM","Wednesday: 10:00 AM – 6:00 PM","Thursday: 10:00 AM – 6:00 PM","Friday: 10:00 AM – 6:00 PM","Saturday: 10:00 AM – 6:00 PM","Sunday: Closed"]},"place_id":"ChIJBe7-DVQDX0YRpNJ50BELOeU"},{"name":"Liquor Store","opening_hours":{"open_now":false,"periods":[{"close":{"day":1,"time":"1800"},"open":{"day":1,"time":"1000"}},{"close":{"day":2,"time":"1800"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1800"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1900"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1900"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1500"},"open":{"day":6,"time":"1000"}}],"weekday_text":["Monday: 10:00 AM – 6:00 PM","Tuesday: 10:00 AM – 6:00 PM","Wednesday: 10:00 AM – 6:00 PM","Thursday: 10:00 AM – 7:00 PM","Friday: 10:00 AM – 7:00 PM","Saturday: 10:00 AM – 3:00 PM","Sunday: Closed"]},"place_id":"ChIJhUQhi1MDX0YRDLOmy57Tq4Y"},{"name":"Annas Hembageri","opening_hours":{"open_now":false,"periods":[{"close":{"day":2,"time":"1800"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1800"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1800"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1800"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1600"},"open":{"day":6,"time":"0900"}}],"weekday_text":["Monday: Closed","Tuesday: 10:00 AM – 6:00 PM","Wednesday: 10:00 AM – 6:00 PM","Thursday: 10:00 AM – 6:00 PM","Friday: 10:00 AM – 6:00 PM","Saturday: 9:00 AM – 4:00 PM","Sunday: Closed"]},"place_id":"ChIJuULTJ8ocX0YRkzCmpaZC-7I"},{"name":"Gripsholm Castle","opening_hours":{"open_now":false,"periods":[{"close":{"day":0,"time":"1600"},"open":{"day":0,"time":"1000"}},{"close":{"day":1,"time":"1600"},"open":{"day":1,"time":"1000"}},{"close":{"day":2,"time":"1600"},"open":{"day":2,"time":"1000"}},{"close":{"day":3,"time":"1600"},"open":{"day":3,"time":"1000"}},{"close":{"day":4,"time":"1600"},"open":{"day":4,"time":"1000"}},{"close":{"day":5,"time":"1600"},"open":{"day":5,"time":"1000"}},{"close":{"day":6,"time":"1600"},"open":{"day":6,"time":"1000"}}],"weekday_text":["Monday: 10:00 AM – 4:00 PM","Tuesday: 10:00 AM – 4:00 PM","Wednesday: 10:00 AM – 4:00 PM","Thursday: 10:00 AM – 4:00 PM","Friday: 10:00 AM – 4:00 PM","Saturday: 10:00 AM – 4:00 PM","Sunday: 10:00 AM – 4:00 PM"]},"place_id":"ChIJs7JrpFQDX0YRyz2JT-AkRyU"}]

ferferga commented 5 years ago

Hi @Bloham . Yeah, I noticed the same with the debug log as you say. You're likely hitting the same issue I'm experiencing: Something undefined is getting inside the getDom function and the module can't reload it's appearance. I think that for @Menturan would be useful if you attach the exact message/line where the DOMs fail to reload. You can do it by opening the Chromium developer tools (CTRL + SHIFT + I in MagicMirror), and going to "Console" tab. You can filter events produced by typing "MMM-OpeningHours" in the search bar.

Menturan commented 5 years ago

@ferferga The first place I always had working and now it isn't as I mentioned has ChIJAWUYvG5sEg0RNC_oa2_g7Oc as it's key. Can you replicate it with that place? Any other step I could take to help you to debug this? @Bloham I also have a problem with the updating store times (or better not updating). My store is closed on Mondays, and now it says "open in 2 days" since weeks...

Thank you @ferferga and @Bloham for your input! :+1: It is clearly something wrong with the logic of how the opening hours is parsed. Also when a place is closed for a whole day, that day doesn’t have a time period which is not taken into account. I’m about to rewrite the logic covering the time periods. I will test it with the places you provided.

@Bloham The Debug Log looks like a mess now ^^ By purpose (because you show more?) or did you wanted it to be formatted like the old one?

Yes @Bloham the debug logs is supposed to look like a mess. :wink: The debug logs now shows the whole object tree. To not bloat the logs, and to make them easier to copy, I kept them compact. Use other software like Notepad++ if like a pretty print. :slightly_smiling_face:

Menturan commented 5 years ago

@ferferga @Bloham Please checkout the branch opening_hours_logic_rewrite by running the following command in MMM-OpeningHours module folder and then restart MagicMirror:

$ git pull
$ git checkout opening_hours_logic_rewrite

I have changed a lot of how the results from Google Places API is parsed and interpreted.

ferferga commented 5 years ago

The command is incorrect, the correct one is git checkout -b opening_hours_logic_rewrite. Pointing out here in case @Bloham faces the same issue.

Testing out the new branch, I'll keep you informed 👍 =). Thank you very much for the fixes @Menturan !

Menturan commented 5 years ago

The command is incorrect, the correct one is git checkout -b opening_hours_logic_rewrite. Pointing out here in case @Bloham faces the same issue.

No, git checkout -b creates a new branch. It's the same as doing git branch <branch-name> and git checkout <branch-name>.

I forgot that you have to do a git pull first to get the branch locally and then git checkout opening_hours_logic_rewrite. I corrected my last post.

@ferferga You may have to delete the branch you created first by doing git branch -d opening_hours_logic_rewrite before doing a pull. The easiest is to just delete the module folder and clone it again.

ferferga commented 5 years ago

No luck with your changes :(. Still going on

In fact, I'm having more luck now with the master branch that with the rewrite branch. All places appear in master branch, except Burger King (ID: "ChIJ4Wft4C9tEg0Rlp6tR14vSgk")

Menturan commented 5 years ago

@ferferga In fact, I'm having more luck now with the master branch that with the rewrite branch. All places appear in master branch, except Burger King (ID: "ChIJ4Wft4C9tEg0Rlp6tR14vSgk")

That Burger King place dont have any opening hours. If a place dosen't have any opening hours the module should print Place-name N/A. Does it show that?

ferferga commented 5 years ago

@Menturan Yeah, it shows up as NOT_AVAILABLE. The module handles this gracefully without issues, it doesn't hang up or crash (master branch, not rewrite). I think, in that case, that a translation for that should be added to show something like "No information available" for a more useful feedback to users.