denverquane / MMM-Teslamate

Magic Mirror Module for the Teslamate utility
MIT License
53 stars 14 forks source link

constant refresh of mmm-teslamate module, every 1 second #36

Closed hollandcloud closed 2 years ago

hollandcloud commented 2 years ago

Using latest MMM-Teslamate module with latest deployment of MagicMirror (just installed both on Monday 7/18). MMM-Teslamate module works great when the car is parked or charging, however when driving, it constantly refreshes the module on the mirror. I ran dev tools on a browser to see what's going on, and it appears to be calling materialdesignicons.min.css every second or so, getting errors. screenshot attached.

issue
hollandcloud commented 2 years ago

FYI, this is the full link it's polling: https://cdn.jsdelivr.net/npm/@mdi/font@4.8.95/css/materialdesignicons.min.css - I was able to load with no issues, so I don't believe the network is blocking any traffic to jsdelivr.net

2022-07-20 11_39_59-https___cdn jsdelivr net_npm_@mdi_font@4 8 95_css_materialdesignicons min css an
hollandcloud commented 2 years ago

Here's the config.js:

    {
        module: 'MMM-Teslamate',
        /*header: "DunDun Status",*/
        position: 'bottom_left',
        config: {
            mqttServer: {
                address: '10.10.0.10',  // Server address or IP address of the MQTT broker
                port: 1883,              // Port number if other than default (1883)
                //user: 'user',          // Leave out for no user
                //password: 'password',  // Leave out for no password
            },

            rangeDisplay: "%", // "%" or "range"
            imperial: true, //use imperial units (true = Miles & F) or metric (false = Km & C)

            carID: '1', // defaults to '1'; only override if you have multiple Teslas and want to display 
                        // a specific car per instance of the module

            // set to true to enable both the graphic, and the additional stats 
            // (charge remaining, scheduled charge start, etc)
            hybridView: false,
            // size of the visible area
            sizeOptions: {
                // size of the icons + battery (above text)
                width: 450, // px, default: 450
                height: 203, // px, default: 203
                // the battery images itself
                batWitdh: 250, // px, default: 250
                batHeight: 75, // px, default: 75
                // visual distance reduction to the module above
                topOffset: -40, // px, default: -40
            },
            carImageOptions: {
                model: "my", // mx, ms (S pre-refresh), ? (S post-refresh)

                view: "STUD_3QTR", // STUD_SIDE works better for S/X

                // full list of option codes: https://tesla-api.timdorr.com/vehicle/optioncodes.
                // you need at least the color and the wheels. not all combos work.
                // also consult: https://teslaownersonline.com/threads/teslas-image-compositor.7089/
                options: "PBSB,PFP31,WTSG,DV4W",

                // play with this until it looks about right.
                // tested values: 0 for m3/STUD_3QTR, 25 for ms/STUD_SIDE
                verticalOffset: 0,

                opacity: 0.5
            },

            // show inside and outside temperatures below the car image: when AC or preconditioning is running (default), always, or never
            showTemps: "hvac_on", // "always", "never"
        }
    },
]

};

olexs commented 2 years ago

I've noticed a higher CPU load on the mirror while driving before, I think it's the same issue. It's not getting any errors, 301 is a cache hit - just re-rendering the module every time the data changes, and that happens once per second while driving, which is way too often. Needs some sort of a debounce mechanic for re-rendering while driving. Will take a closer look soon and try and build a fix!

olexs commented 2 years ago

Implemented a configurable rendering debounce, this should solve the issue. Will test myself once I drive the car next time, should be easily visible in the mirror CPU load graph.

hollandcloud commented 2 years ago

Seems to have resolved the issue. Thanks!