WouterEekhout / MMM-Tado

A MagicMirror Module for your Tado Smart Thermostat.
MIT License
7 stars 6 forks source link

config from config.js not used #9

Closed sdetweil closed 4 years ago

sdetweil commented 4 years ago

bug in the start routine

    start: function () {
        if (this.config.updateInterval < this.defaults.updateInterval){
            this.config.updateInterval = this.defaults.updateInterval;
        }

        this.config.units = self.config.units;         // self is not set   <----  config.units overlayed with garbage
        this.sendSocketNotification('CONFIG', this.config);
    },

see https://forum.magicmirror.builders/topic/12914/mmm-tado-wrong-units/4?_=1590847553898

WouterEekhout commented 4 years ago

Hi, I cannot reproduce the problem. In my case the self.config.units reads out the units from the config.js correctly. If I set the recommendation like you posted in the forum (thank you btw for helping others): var self = this, then it will read out the defaults set in the MMM-Tado.js and not from the config.js.

My config.js looks like the following:

var config = {
...
    units: "metric",
...
    modules: [
...
        {
            module: 'MMM-Tado',
            position: 'top_right',
            header: 'My Home',
            config: {
                username: 'X',
                password: 'X',
                updateInterval: 300000,
            }
        },
...
    ]
};
lordvalium commented 3 years ago

Have the similar problem @WouterEekhout i cant switch to Celsius.

sdetweil commented 3 years ago

the problem is the code depends on an outside global variable self, at the time start: is called. and there is no assurance self is correctly set.

the global config variable IS set, and one doesn't need any prefixing pointer to use it

config.units would work

lordvalium commented 3 years ago

Thank you, so i have added config.units = metric in the config of tado. But that didn work /

sdetweil commented 3 years ago

@lordvalium I was talking about the one at the top of config.js, before the modules loop.

if the code removed the self. then it would work as he expected

lordvalium commented 3 years ago

image

no its not working

sdetweil commented 3 years ago

ok, i just installed Tado and changed the code in MMM-Tado.js from

        this.config.units = self.config.units ;

to

        this.config.units = config.units;

and used debug to verify that the correct value was picked up from the config file

one could also change all

self.config.units

to

config.units

as there is no need for the instance stored version