Skip to content

Commit

Permalink
Fix override of unit for sensors. Fixes #86
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed Jan 2, 2020
1 parent c81f717 commit 99c3033
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class SimpleThermostat extends LitElement {
name: name.find(n => !!n),
state,
entity,
unit,
}
}
)
Expand Down Expand Up @@ -375,9 +376,10 @@ class SimpleThermostat extends LitElement {
this.localize(action, 'state_attributes.climate.hvac_action.'),
{ heading: (this.config.label && this.config.label.state) || 'State' }
),
sensors.map(({ name, icon, state }) => {
sensors.map(({ name, icon, state, unit }) => {
return (
state && this.renderInfoItem(false, state, { heading: name, icon })
state &&
this.renderInfoItem(false, state, { heading: name, icon, unit })
)
}) || null,
].filter(it => it !== null)
Expand Down Expand Up @@ -503,7 +505,7 @@ class SimpleThermostat extends LitElement {
// Preset mode can be one of: none, eco, away, boost, comfort, home, sleep, activity
// See https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/climate/const.py#L36-L57

renderInfoItem(hide, state, { heading, icon }) {
renderInfoItem(hide, state, { heading, icon, unit }) {
if (hide || !state) return

let valueCell
Expand All @@ -521,7 +523,7 @@ class SimpleThermostat extends LitElement {
class="clickable"
@click="${() => this.openEntityPopover(state.entity_id)}"
>
${value} ${state.attributes.unit_of_measurement}
${value} ${unit || state.attributes.unit_of_measurement}
</div>
`
} else {
Expand Down

0 comments on commit 99c3033

Please sign in to comment.