Open ferferga opened 5 years ago
Error is thrown at line 108 here by Electron console (Cannot read property 'close' of undefined
). Still trying to debug it...
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.
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.
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"}]
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.
@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:
@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.
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 !
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.
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")
@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?
@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.
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):
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.