Skip to content

Commit

Permalink
Merge pull request #64 from AmoebeLabs/fix-home-assistant-2023.4
Browse files Browse the repository at this point in the history
Fix Home Assistant 2023.4 Lovelace issues
  • Loading branch information
AmoebeLabs authored Apr 27, 2023
2 parents 218ca58 + ed12b19 commit f0322b8
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions flex-horseshoe-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,19 @@ import {
return (Math.min(Math.max(val, start), end) - start) / (end - start);
}

_getLovelacePanel() {
var root = document.querySelector('home-assistant');
root = root && root.shadowRoot;
root = root && root.querySelector('home-assistant-main');
root = root && root.shadowRoot;
root = root && root.querySelector('app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver');
root = (root && root.shadowRoot) || root;
root = root && root.querySelector('ha-panel-lovelace');
if (root) {
return root;
}
return null;
}
/*******************************************************************************
* _getColorVariable()
*
Expand All @@ -1826,11 +1839,12 @@ import {
const newColor = inColor.substr(4, inColor.length-5);

if (!this.lovelace) {
const root = document.querySelector('home-assistant');
const main = root.shadowRoot.querySelector('home-assistant-main');
const drawer_layout = main.shadowRoot.querySelector('app-drawer-layout');
const pages = drawer_layout.querySelector('partial-panel-resolver');
this.lovelace = pages.querySelector('ha-panel-lovelace');
this.lovelace = this._getLovelacePanel();
// const root = document.querySelector('home-assistant');
// const main = root.shadowRoot.querySelector('home-assistant-main');
// const drawer_layout = main.shadowRoot.querySelector('app-drawer-layout');
// const pages = drawer_layout.querySelector('partial-panel-resolver');
// this.lovelace = pages.querySelector('ha-panel-lovelace');
} else { }

const returnColor = window.getComputedStyle(this.lovelace).getPropertyValue(newColor);
Expand Down Expand Up @@ -1939,4 +1953,4 @@ import {
}

customElements.define('flex-horseshoe-card', FlexHorseshoeCard);


0 comments on commit f0322b8

Please sign in to comment.