Skip to content

Commit

Permalink
Add disable-name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Nov 11, 2023
1 parent 65e3fd5 commit ab68ac7
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 60 deletions.
77 changes: 36 additions & 41 deletions dist/versatile-thermostat-ui-card.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/climate-card-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const HVAC_MODES: HvacMode[] = [
export type ClimateCardConfig = LovelaceCardConfig &
EntitySharedConfig &
{
disable_name?: boolean;
disable_window?: boolean;
disable_overpowering?: boolean;
disable_eco?: boolean;
Expand All @@ -36,6 +37,7 @@ export type ClimateCardConfig = LovelaceCardConfig &
disable_off?: boolean;
disable_menu?: boolean;
disable_security_warning?: boolean;
disable_power_infos?: boolean;
set_current_as_main?: boolean;
eco_temperature?: number;
disable_buttons?: boolean;
Expand All @@ -45,13 +47,15 @@ export const climateCardConfigStruct = assign(
lovelaceCardConfigStruct,
entitySharedConfigStruct,
object({
disable_name: optional(boolean()),
disable_window: optional(boolean()),
disable_overpowering: optional(boolean()),
disable_eco: optional(boolean()),
disable_heat: optional(boolean()),
disable_cool: optional(boolean()),
disable_off: optional(boolean()),
disable_security_warning: optional(boolean()),
disable_power_infos: optional(boolean()),
set_current_as_main: optional(boolean()),
eco_temperature: optional(number()),
disable_menu: optional(boolean()),
Expand Down
3 changes: 2 additions & 1 deletion src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"set_current_as_main": "Exchange target temperature and room temperature",
"disable_security_warning": "Disable battery warning",
"disable_buttons": "Disable plus/minus buttons",
"disable_power_infos": "Disable power infos"
"disable_power_infos": "Disable power infos",
"disable_name": "Disable name"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/localize/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"set_current_as_main": "Echanger temperature cible avec temperature locale",
"disable_security_warning": "Désactiver sécurité messages",
"disable_buttons": "Désactiver les boutons +/-",
"disable_power_infos": "Désactiver les infos de puissance"
"disable_power_infos": "Désactiver les infos de puissance",
"disable_name": "Désactiver le nom"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/versatile-thermostat-ui-card-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const loadHaComponents = (version: string) => {
}
};

const CLIMATE_LABELS = ["disable_window", "disable_overpowering", "disable_heat", "disable_cool", "disable_off", "disable_menu", "disable_security_warning", "disable_buttons", "set_current_as_main", "disable_power_infos"] as string[];
const CLIMATE_LABELS = ["disable_name", "disable_window", "disable_overpowering", "disable_heat", "disable_cool", "disable_off", "disable_menu", "disable_security_warning", "disable_buttons", "set_current_as_main", "disable_power_infos"] as string[];

const computeSchema = memoizeOne(
(): any[] => [
Expand All @@ -42,6 +42,7 @@ const computeSchema = memoizeOne(
type: "grid",
name: "",
schema: [
{ name: "disable_name", selector: { boolean: {} } },
{ name: "disable_window", selector: { boolean: {} } },
{ name: "disable_overpowering", selector: { boolean: {} } },
{ name: "disable_heat", selector: { boolean: {} } },
Expand Down
33 changes: 17 additions & 16 deletions src/versatile-thermostat-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
@property({ type: String }) public mode: string = "off";
@property({ type: String }) public preset: string = "manual";
@property({ type: Boolean, reflect: true }) public dragging = false;
@property({ type: String}) public name: string = "";

@state()
private changingHigh?: number;
Expand Down Expand Up @@ -412,7 +413,7 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
box-sizing: border-box;
border-radius: 100%;
left: 50%;
top: calc(50% - 20px);
top: calc(50% - 40px);
text-align: center;
overflow-wrap: break-word;
pointer-events: none;
Expand All @@ -425,10 +426,6 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
max-width: 155px;
}
#expand .content {
top: calc(50% - 40px);
}
#main {
transform: scale(2.3);
}
Expand Down Expand Up @@ -570,11 +567,8 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
align-items: center;
justify-content: flex-start;
overflow: hidden;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 5px;
padding-right: 5px;
height: 48px;
padding: 0px 0px;
height: 30px;
}
#vt-control-buttons {
Expand Down Expand Up @@ -777,6 +771,11 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
this.stateObj = stateObj;
const attributes = this.stateObj.attributes;
const stateMode = this.stateObj.state;

this.name = "";
if (!this._config.disable_name) {
this.name = this._config.name ? this._config.name : attributes.friendly_name;
}

this.mode = stateMode || "off";

Expand All @@ -785,7 +784,7 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
}

if (attributes.preset_modes) {
this.presets = Object.values(attributes.preset_modes);
this.presets = Object.values(attributes.preset_modes.filter((preset: string) => { return preset != "none"; }));
}

this.preset = attributes.preset_mode;
Expand Down Expand Up @@ -1085,7 +1084,7 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {

public render: () => TemplateResult = (): TemplateResult => {
return html `
<ha-card id="${this?._config?.disable_buttons ? '' : 'expand'}" class=${classMap({
<ha-card class=${classMap({
[this.mode]: true,
})}
>
Expand All @@ -1100,9 +1099,11 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
tabindex="0"
></ha-icon-button>
`}
${this?._config?.name?.length || 0 > 0 ? html`
<div class="name">${this._config?.name}</div>
` : html`<div class="name">&nbsp;</div>`}
${this.name.length > 0 ? html`
<div class="name">${this.name}</div>
` : ``}
${this.security_state !== null ? html`
<div class="security">
<ha-icon-button class="alert" .path=${mdiThermometerAlert}>
Expand Down Expand Up @@ -1156,7 +1157,7 @@ export class VersatileThermostatUi extends LitElement implements LovelaceCard {
>
`
}
<div class="content ${this.security_state !== null || this.error.length > 0 ? 'security_msg': ''} ${this.window ? 'window_open': ''} ${(this?.stateObj?.attributes?.saved_temperature && this?.stateObj?.attributes?.saved_temperature !== null) ? 'eco' : ''} ${this.overpowering ? 'overpowering': ''} ${this.presence ? 'presence': ''} ${this.motion ? 'motion': ''} ${this.windowByPass ? 'windowByPass': ''} " >
<div class="content ${this.name.length == 0 ? 'noname':''} ${this.security_state !== null || this.error.length > 0 ? 'security_msg': ''} ${this.window ? 'window_open': ''} ${(this?.stateObj?.attributes?.saved_temperature && this?.stateObj?.attributes?.saved_temperature !== null) ? 'eco' : ''} ${this.overpowering ? 'overpowering': ''} ${this.presence ? 'presence': ''} ${this.motion ? 'motion': ''} ${this.windowByPass ? 'windowByPass': ''} " >
<svg id="main" viewbox="0 0 125 100">
<g transform="translate(57.5,37) scale(0.35)">
${(this._hasWindow && !this._config?.disable_window) ? svg`
Expand Down

0 comments on commit ab68ac7

Please sign in to comment.