gurbyz/power-wheel-card

Card does not render in 0.116b1

firstof9 opened this issue · 6 comments

Which version of HA do you use?
0.116b1

Which version of the card do you use?
3.1.7

Describe the bug
The card does not render in 0.116b1

Configuration of the card
Copy the complete configuration of the card, even if you think it isn't relevant.

  - auto_toggle_view_period: 10
    color_icons: true
    consuming_color: '#d41b1b'
    debug: false
    energy_consumption_rate: 0.25
    energy_decimals: 3
    energy_production_rate: 0.25
    grid_energy_consumption_entity: sensor.grid_energy_consumption
    grid_energy_production_entity: sensor.grid_energy_production
    grid_power_consumption_entity: sensor.grid_power_consumption
    grid_power_production_entity: sensor.grid_power_production
    initial_auto_toggle_view: false
    initial_view: power
    money_decimals: 2
    money_unit: $
    power_decimals: 2
    producing_color: '#53a122'
    production_is_positive: 1
    solar_energy_entity: sensor.solar_energy_production
    solar_power_entity: sensor.solar_power_production
    solar_power_icon: 'mdi:solar-power'
    title: Power Distribution
    title_energy: Power Distribution
    title_money: Power Distribution
    title_power: Power Distribution
    type: 'custom:power-wheel-card'
    view: power

Dev console debug output

power-wheel-cardVersion: 0.1.2Lovelace resource: power-wheel-card.jsHA version: 0.116.0b1Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36Report issues here: https://github.com/gurbyz/power-wheel-card/issuesProcessed config: { "auto_toggle_view_period": 10, "color_icons": true, "consuming_color": "#d41b1b", "debug": "fals", "energy_consumption_rate": 0.25, "energy_decimals": 3, "energy_production_rate": 0.25, "grid_energy_consumption_entity": "sensor.grid_energy_consumption", "grid_energy_production_entity": "sensor.grid_energy_production", "grid_power_consumption_entity": "sensor.grid_power_consumption", "grid_power_production_entity": "sensor.grid_power_production", "initial_auto_toggle_view": false, "initial_view": "power", "money_decimals": 2, "money_unit": "$", "power_decimals": 2, "producing_color": "#53a122", "production_is_positive": 1, "solar_energy_entity": "sensor.solar_energy_production", "solar_power_entity": "sensor.solar_power_production", "solar_power_icon": "mdi:solar-power", "title": "Power Distribution", "title_energy": "Power Distribution", "title_money": "Power Distribution", "title_power": "Power Distribution", "type": "custom:power-wheel-card", "view": "power", "charging_is_positive": 1, "invert_grid_colors": false, "active_arrow_color": "var(--paper-item-icon-active-color, #fdd835)"}Registered sensors: [ "sensor.solar_power_production", "sensor.grid_power_consumption", "sensor.grid_power_production", "sensor.solar_energy_production", "sensor.grid_energy_consumption", "sensor.grid_energy_production"]Views object: { "power": {  "title": "Power Distribution",  "oneGridSensor": false,  "twoGridSensors": true,  "batteryCapable": false,  "capable": true }, "energy": {  "title": "Power Distribution",  "oneGridSensor": false,  "twoGridSensors": true,  "capable": true }, "money": {  "title": "Power Distribution",  "oneGridSensor": false,  "twoGridSensors": true,  "capable": true }}

Expected behavior
I expect the card to display.

Screenshots
n/a

Additional context
n/a

Thx Chris, for your early report. I'm not sure yet, but I think the card isn't acting well on implementing this architectural change in HA 0.116. Something to do with templates that update too often. Since power-wheel-card listens to many input sensors, it is a candidate to update too often. I tried to prevent that in 2019 by decreasing the amount of updates:

_sensorChangeDetected(oldValue) {
    return this.sensors.reduce((change, sensor) => {
      return change || this.hass.states[sensor].state !== oldValue.states[sensor].state;
    }, false);
  }

  shouldUpdate(changedProperties) {
    // Don't update when there is a new value for a hass property that's not a registered sensor.
    // Update in all other cases, e.g. when there is a change of config or old values are undefined.
    let update = true;
    Array.from(changedProperties.keys()).some((propName) => {
      const oldValue = changedProperties.get(propName);
      if (propName === "hass" && oldValue) {
        update = update && this._sensorChangeDetected(oldValue);
      }
      return !update;
    });
    return update;
  }

But in 0.116.0b1 I guess that's not working. I saw there were some fixes to the architectural change already in 0.116.0b2. I'm only running my production 0.115.x. Could you, by any change, check again in 0.116.0b2 for me?

I'll try to look for documentation how custom cards should cope with this architectural change in the mean time.

New hypothesis, because I was misreading the architectural change in HA a bit.

It's about a breaking change on template sensors. I found a pull request for that that's labeled with 'breaking change' for next release (0.116.0).

If users of the power-wheel-card will use template sensors as input and they are impacted by this breaking change, then their template sensors won't update as usual. If their template sensors won't update, the card won't detect and re-render.

(It's still a hypothesis though... but) could you check your template sensors? One use case that would have impact would be a template sensor that uses now().

Or: could be this announced breaking change for custom cards. Unfortunately the suggested solution to use hui-masonry-view doesn't work for me.

I released a new version of power-wheel-card: 0.1.3. I did a small fix to prevent impact by the breaking change for custom cards mentioned in my last message. It's not fixed like the blog suggests, because that didn't work. But I looked in other custom cards how it currently was done to get LitElement.

@firstof9 Chris, could you check if the new release does fix anything for you? If not, is there any error shown in HA or in the console?

about the template jinja change: this wont impact here.
It has all been about the change in HA 115 that made templates find the states much better than before, and hence the need for the 'entity_id:' line which was used for these cases is no linger required. If anything, the template sensors update far too frequently now (especially when using jinja like {{states|...} which would cause listeners for all states....).
because of that the new PRs are made to bring those down a bit. Any case, the template sensors for Powerwheel card didn't need the entity_id line at all, and are updating nicely, so no worries there for this card.

Confirming your change did indeed resolve the issue and the card is now rendering.