generated from ludeeus/integration_blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from krahabb/dev
upgrade HA core compatibility to 2024.9
- Loading branch information
Showing
5 changed files
with
146 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { | ||
LitElement, | ||
html, | ||
customElement, | ||
property, | ||
CSSResult, | ||
TemplateResult, | ||
css, | ||
PropertyValues, | ||
internalProperty, | ||
} from 'lit-element'; | ||
import { | ||
HomeAssistant, | ||
hasConfigOrEntityChanged, | ||
hasAction, | ||
ActionHandlerEvent, | ||
handleAction, | ||
//LovelaceCardEditor, | ||
getLovelace, | ||
ActionConfig, LovelaceCard, LovelaceCardConfig, LovelaceCardEditor | ||
} from 'custom-card-helpers'; // This is a community maintained npm module with common helper functions/types | ||
|
||
|
||
export const CARD_VERSION = '0.0.1'; | ||
// TODO Add your configuration elements here for type-checking | ||
/* | ||
export interface BoilerplateCardConfig extends LovelaceCardConfig { | ||
type: string; | ||
name?: string; | ||
show_warning?: boolean; | ||
show_error?: boolean; | ||
test_gui?: boolean; | ||
entity?: string; | ||
tap_action?: ActionConfig; | ||
hold_action?: ActionConfig; | ||
double_tap_action?: ActionConfig; | ||
}*/ | ||
|
||
function localize(msg, search = '', replace = '') { | ||
return msg | ||
} | ||
|
||
class MotionFrontendCameraCard extends LitElement { | ||
|
||
/*static async getConfigElement() { | ||
return document.createElement('motion-frontend-camera-card-editor'); | ||
} | ||
static getStubConfig() { | ||
return {}; | ||
}*/ | ||
|
||
static get properties() { | ||
return { | ||
hass: {}, | ||
config: {} | ||
}; | ||
} | ||
|
||
|
||
setConfig(config) { | ||
if (!config) { | ||
throw new Error(localize('common.invalid_configuration')); | ||
} | ||
|
||
if (config.test_gui) { | ||
getLovelace().setEditMode(true); | ||
} | ||
|
||
this.config = { | ||
name: 'Motion Frontend Camera Name', | ||
...config, | ||
}; | ||
} | ||
|
||
|
||
render() { | ||
// TODO Check for stateObj or other necessary things and render a warning if missing | ||
if (this.config.show_warning) { | ||
return this._showWarning(localize('common.show_warning')); | ||
} | ||
|
||
if (this.config.show_error) { | ||
return this._showError(localize('common.show_error')); | ||
} | ||
|
||
return html` | ||
<ha-card | ||
.header=${this.config.name} | ||
@action=${this._handleAction} | ||
.actionHandler=${actionHandler({ | ||
hasHold: hasAction(this.config.hold_action), | ||
hasDoubleClick: hasAction(this.config.double_tap_action), | ||
})} | ||
tabindex="0" | ||
.label=${`Boilerplate: ${this.config.entity || 'No Entity Defined'}`} | ||
></ha-card> | ||
`; | ||
} | ||
|
||
_handleAction(ev) { | ||
if (this.hass && this.config && ev.detail.action) { | ||
handleAction(this, this.hass, this.config, ev.detail.action); | ||
} | ||
} | ||
|
||
_showWarning(warning) { | ||
return html` | ||
<hui-warning>${warning}</hui-warning> | ||
`; | ||
} | ||
|
||
_showError(error) { | ||
const errorCard = document.createElement('hui-error-card'); | ||
errorCard.setConfig({ | ||
type: 'error', | ||
error, | ||
origConfig: this.config, | ||
}); | ||
|
||
return html` | ||
${errorCard} | ||
`; | ||
} | ||
|
||
} | ||
|
||
|
||
// This puts your card into the UI card picker dialog | ||
window.customCards = window.customCards || []; | ||
window.customCards.push({ | ||
type: "motion-frontend-camera-card", | ||
name: "Motion Frontend Camera Card", | ||
preview: false, // Optional - defaults to false | ||
description: "A custom card made by me!" // Optional | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "Motion Frontend", | ||
"homeassistant": "2024.1.0", | ||
"homeassistant": "2024.9.0", | ||
"render_readme": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#pytest-homeassistant-custom-component==0.3.2 | ||
#pytest-homeassistant-custom-component @ git+https://github.com/MatthewFlamm/[email protected] # HA core 2024.1.0 | ||
pytest-homeassistant-custom-component @ git+https://github.com/MatthewFlamm/[email protected] # HA core 2024.3.0 | ||
#pytest-homeassistant-custom-component @ git+https://github.com/MatthewFlamm/[email protected] # HA core 2024.3.0 | ||
pytest-homeassistant-custom-component @ git+https://github.com/MatthewFlamm/[email protected] # HA core 2024.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters