fineemb / lovelace-thermostat-card

Thermostat Lovelace card
Other
109 stars 27 forks source link

Reopening #5 #8

Closed peetereczek closed 4 years ago

peetereczek commented 4 years ago
Uncaught TypeError: Cannot read property 'toLowerCase' of null
    at ThermostatUI._updateColor (thermostat_card.lib.js?v=0.1.1:332)
    at ThermostatUI.updateState (thermostat_card.lib.js?v=0.1.1:188)
    at HTMLElement.set hass [as hass] (main.js:42)
    at HTMLElement.value (hui-view.ts:61)
    at HTMLElement.value (hui-view.ts:337)
    at HTMLElement.<anonymous> (hui-view.ts:68)
    at r (fire_event.ts:76)
    at create-element-base.ts:92

Still error occurs.

fineemb commented 4 years ago

Please replace the following code (thermostat_card.lib.js)try, and feedback. Remember to clean up your browser cache after changes Thank you for your work.

  _updateColor(state, preset_mode) {

    if(Object.prototype.toString.call(preset_mode) === "[object String]"){

      if(state != 'off' && preset_mode.toLowerCase() == 'idle')
      state = 'idle'

      this._root.classList.forEach(c => {
        if (c.indexOf('dial--state--') != -1)
          this._root.classList.remove(c);
      });
      this._root.classList.add('dial--state--' + state);
    }
  }
peetereczek commented 4 years ago

Fix you shared works, thanks!