Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Climate component #114

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/v3/src/css/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css } from "lit";
export default css`
.flex-grid-half {
display: grid;
grid-template-columns: 600px 2fr;
grid-template-columns: 700px 2fr;
}
.flex-grid-half.expanded_entity,
.flex-grid-half.expanded_logs {
Expand Down
19 changes: 18 additions & 1 deletion packages/v3/src/css/esp-entity-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,24 @@ export default css`
margin: auto;
display: flex;
}

.climate-wrap{
width: 100%;
margin: 10px 0 10px 0;
}
.climate-row {
width: 100%;
display: inline-flex;
flex-wrap: wrap;
text-align: left;
}
.climate-row > select{
width: 50%;
}
.climate-row > label{
align-content: center;
width: 150px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
padding: 0 !important;
}
Expand Down
106 changes: 57 additions & 49 deletions packages/v3/src/esp-entity-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,65 +617,73 @@ class ActionRenderer {

render_climate() {
if (!this.entity) return;
let target_temp_slider, target_temp_label;
let target_temp_slider, target_temp_label, target_temp;
let current_temp = html`<div class="climate-row" style="padding-bottom: 10px";>
<label>Current:&nbsp;${this.entity.current_temperature} °C</label>
</div>`;

if (
this.entity.target_temperature_low !== undefined &&
this.entity.target_temperature_high !== undefined
) {
target_temp_label = html`${this.entity
.target_temperature_low}&nbsp;..&nbsp;${this.entity
.target_temperature_high}`;
target_temp_slider = html`
${this._range(
this.entity,
"set",
"target_temperature_low",
this.entity.target_temperature_low,
this.entity.min_temp,
this.entity.max_temp,
this.entity.step
)}
${this._range(
this.entity,
"set",
"target_temperature_high",
this.entity.target_temperature_high,
this.entity.min_temp,
this.entity.max_temp,
this.entity.step
)}
`;
target_temp = html`
<div class="climate-row">
<label>Target Low:&nbsp;</label>
${this._range(
this.entity,
"set",
"target_temperature_low",
this.entity.target_temperature_low,
this.entity.min_temp,
this.entity.max_temp,
this.entity.step
)}
</div>
<div class="climate-row">
<label>Target High:&nbsp;</label>
${this._range(
this.entity,
"set",
"target_temperature_high",
this.entity.target_temperature_high,
this.entity.min_temp,
this.entity.max_temp,
this.entity.step
)}
</div>`;
} else {
target_temp_label = html`${this.entity.target_temperature}`;
target_temp_slider = html`
${this._range(
this.entity,
"set",
"target_temperature",
this.entity.target_temperature!!,
this.entity.min_temp,
this.entity.max_temp,
this.entity.step
)}
`;
target_temp = html`
<div class="climate-row">
<label>Target:&nbsp;</label>
${this._range(
this.entity,
"set",
"target_temperature",
this.entity.target_temperature!!,
this.entity.min_temp,
this.entity.max_temp,
this.entity.step
)}
</div>`;
}
let modes = html``;
if ((this.entity.modes ? this.entity.modes.length : 0) > 0) {
modes = html`Mode:<br />
${this._select(
this.entity,
"set",
"mode",
this.entity.modes || [],
this.entity.mode || ""
)}`;
modes = html`
<div class="climate-row">
<label>Mode:&nbsp;</label>
${this._select(
this.entity,
"set",
"mode",
this.entity.modes || [],
this.entity.mode || ""
)}
</div>`;
}
return html`
<label
>Current:&nbsp;${this.entity.current_temperature},
Target:&nbsp;${target_temp_label}</label
>
${target_temp_slider} ${modes}
<div class="climate-wrap">
${current_temp} ${target_temp} ${modes}
</div>
`;
}
}
3 changes: 2 additions & 1 deletion packages/v3/src/esp-range-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export class EspRangeSlider extends LitElement {
cssReset,
css`
:host {
width: 100%;
min-width: 150px;
flex: 1;
}
input[type=range] {
-webkit-appearance: none;
Expand Down