-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Support Climate Devices v1 #64
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,6 +236,8 @@ class BannerCard extends LitElement { | |
return this.renderDomainCover(options); | ||
case "media_player": | ||
return this.renderDomainMediaPlayer(options); | ||
case "climate": | ||
return this.renderDomainClimate(options); | ||
} | ||
} | ||
return this.renderDomainDefault(options); | ||
|
@@ -381,6 +383,45 @@ class BannerCard extends LitElement { | |
</div> | ||
`; | ||
} | ||
|
||
renderDomainClimate(options) { | ||
let entity_id = options.entity.split(".")[1]; | ||
let thermostatTemperature = options.attributes.temperature; | ||
let callClimateService = (options) => { | ||
this._hass.callService("climate", "set_temperature", { "entity_id": options.entity, "temperature": options.attributes.temperature }); | ||
}; | ||
let onThermostatArrowClick = (diff) => { | ||
clearTimeout(this._updateThermostateTemperatureTimeout); | ||
options.attributes.temperature += diff; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modifying the passed state object is not a good idea. A pure HA state object has a single source or truth, but when modifying it it gets confusing. I get that waiting for state changes to come back from HA takes too long for climate devices though. Perhaps keeping a |
||
this.hass = this._hass; | ||
this._updateThermostateTemperatureTimeout = setTimeout(callClimateService, 3000, options); | ||
}; | ||
let onThermostatArrowUpClick = () => { | ||
onThermostatArrowClick(0.5); | ||
}; | ||
let onThermostatArrowDownClick = () => { | ||
onThermostatArrowClick(-0.5); | ||
}; | ||
return html` | ||
<div class="entity-state" style="${this.grid(options.size)}"> | ||
<span class="entity-name">${options.name}</span> | ||
<span class="entity-value ${entity_id}_editor"> | ||
<paper-icon-button | ||
icon="hass:arrow-up" | ||
role="button" | ||
@click=${onThermostatArrowUpClick} | ||
></paper-icon-button> | ||
<span class="${entity_id}_value">${thermostatTemperature.toFixed(1)}</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value + the heading should be clickable to bring up the native more info dialog like it works for for example sensors. |
||
<paper-icon-button | ||
icon="hass:arrow-down" | ||
role="button" | ||
@click=${onThermostatArrowDownClick} | ||
></paper-icon-button> | ||
</span> | ||
</span> | ||
</div> | ||
`; | ||
} | ||
|
||
getCardSize() { | ||
return 3; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please camelCase variables