Code is posted above
Read the statement by Michael Teeuw here.
Latest posts made by dsmtweaker
-
RE: Geocode API
I am just using the MMM-GoogleAnalytics code, along with the MMM-Globe code as explained in the walk through. My analytics API is working, as it displays the information on the mirror. The issue comes with the geocode section. I believe this module was written before google started requiring a geocode API.
{ module: 'MMM-GoogleAnalytics', header: 'mywebsite.com - Today', position: 'top_right', config: { viewID : 'ga:XXXXXXX', // see README.md, how to get viewID and your keyfile.json start_date: '1daysAgo', //today,1daysAgo, end_date: 'today', metrics: 'ga:newusers, ga:users, ga:sessions, ga:pageviews, ga:sessionDuration', dimensions: 'ga:city, ga:country', //ga:country, ga:city,ga:source //sort: '-ga:timeOnPage', //filters: 'ga:timeOnPage>10', //ga:timeOnPage>10 Return results where the time on the page is strictly greater than ten seconds. segment: '', start_index: 1, max_results: 50, updateInterval: 10 * 30 * 1000, // every minute showtable: true, showtotalline: true, exportdatatoMMM_Globe: true, debug: false } }, ] }; { module: 'MMM-Globe', position: 'lower_third', // This can be any of the regions. Best results in lower_third config: { size:"small", // Globe size. See configuration options below for more options dayLength: 38, // (Optional) Rotation speed. See configuration options below viewAngle: 15, // (Optional) Globe tilt. See configuration options below. introLinesDuration: 2000, receiveExternalLocations: 1, locations: [ // Fill with location Objects if desired // e.g. // {lat:37.77493,lng:-122.41942, label: "San Francisco"}, // {lat:-23.5475,lng:-46.63611, label: "Sao Paulo"} // Individual values must be seperated by a comma. // You can look up the latitude and longitude for a specific location on Google Maps. ] } },
-
Geocode API
I am trying to do the mmm-googleanalytics connected to MMM-Globe, as done here. http://robstechlog.com/2017/07/22/google-analytics-coordinates-rotating-globe/
I have followed all the steps, and both analytics & globe are working, however the globe is not showing data from analytics(just using the default cities)
I did create a google geocode API(which the steps don’t mention) But I don’t see anywhere to enter the geocode API. When I npm start I get the following error.
{ Error: Status is OVER_QUERY_LIMIT. Keyless access to Google Maps Platform is deprecated. Please use an API key with all your API calls to avoid service interruption. For further details please refer to http://g.co/dev/maps-no-account at C:\Users\brandon\MagicMirror\modules\MMM-GoogleAnalytics\node_modules\node-geocoder\lib\geocoder\googlegeocoder.js:89:25 at IncomingMessage.<anonymous> (C:\Users\brandon\MagicMirror\modules\MMM-GoogleAnalytics\node_modules\node-geocoder\lib\httpadapter\httpadapter.js:65:9) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1056:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) cause: Error: Status is OVER_QUERY_LIMIT. Keyless access to Google Maps Platform is deprecated. Please use an API key with all your API calls to avoid service interruption. For further details please refer to http://g.co/dev/maps-no-account
Am I just missing where to put my geocode API key?
-
RE: Timer on Module
@sean said in Timer on Module:
Anyway, your video is already repeating by loop: true, why you need to repeat it with timer?
Because I don’t want it to loop. I want it to play in intervals. Like maybe every 15 minutes it runs the video(once)
-
RE: Timer on Module
@sean You are a genius, thank you so much.
Extra bonus, do you know of anyway to use a local source, instead of a web source?
IE- videoSRC: “/home/pi/content/videos/video1.mp4”
It’s not necessary, I just figured running something locally instead of from the web
would help reduce lag/buffer/tearing etc. -
RE: Timer on Module
@sean Thank you, and everyone else for all the help. It’s refreshing to find a forum that doesn’t automatically start bashing beginners.
I think my knowledge is just not ready for something this advanced yet. I used your code, and tried changes here and there to make it work, but still no luck. I am no longer getting any errors in the console. But nothing happens(ie- no video ever loads/plays) this is where I got the code so far…
Module.register(“MMM-htmlvideo”,{
// Default module config. defaults: { videoSRC: 'https://www.mid-americantitle.com/wp-content/uploads/output_HD7205.mp4', loop: true, }, // get stylesheet getStyles: function() { return ["htmlvideo.css"]; }, start: function() { this.timer = null this.videoDom = null }, getDom: function() { var container = document.createElement("div") var video = document.createElement("video") video.src = this.config.videoSRC; video.id = "VIDEO" video.style.display = "none" video.autoplay = true video.loop = this.config.loop container.appendChild(video) this.videoDom = video return container // Just create DOMs in getDom(). It's better to control DOMs outside of getDom(). }, notificationReceived: function(noti, payload, sender) { if (noti == "DOM_OBJECT_CREATED") this.work() //DOM_OBJECT_CREATED would be the best time to start your job. Your DOM would be created and be ready to work on that message. }, work: function(src = null, interval = null) { clearTimer(this.timer) interval = (interval) ? interval : 30000 src = (src) ? src : this.config.videoSRC this.playVideo(src) this.timer = setTimeout(()=>{ this.work() }, interval) //setTimeout is better than setInterval. // you can repeat this function by interval. you can change interval and src with parameters of this function. }, playVideo: function(src) { this.videoDom.src = src if (this.videoDom.style.display == "none") this.videoDom.style.display = "block" this.videoDom.play() // assign src to your videoDom and play it. }, });
I tried changing “interval” with actual numbers, as well as changing the source in multiple locations. Still just get a black screen.
-
RE: Timer on Module
@sdetweil I made all the corrections noted.
but on if (noti == “DOM_OBJECT_CREATED”) this.job() I am still getting the error SyntaxError: Invalid or unexpected token
-
RE: Timer on Module
@sdetweil It is there in the get:function
get: function() {setInterval(()=>{this.updateDom()}, 60000) notificationRecieved: function (noti, payload, sender) { if (noti = "DOM_OBJECT_CREATED") this.job() }, getDom: fuction () var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop;
},});
-
RE: Timer on Module
@sean Sorry for being so new at this. And thank you for all of the help. I tried using your code.
get: function() {
setInterval(()=>{this.updateDom()}, 60000)
notificationRecieved: function (noti, payload, sender) {
if (noti = “DOM_OBJECT_CREATED”) this.job()}, getDom: function () var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop; },
});
But I get “Uncaught SyntaxError: Unexpected token (” from notificationRecieved: function (noti, payload, sender) {
-
RE: Timer on Module
@sean So, should I be putting the updateDom in a function? Such as…
// Override dom generator. getDom: function() { var intervalID = window.setInterval(this.GetVid, 60000); var video = document.createElement("video"); video.src = this.config.videoSRC; video.autoplay = true; video.loop = this.config.loop; function GetVid() { updateDom } }