Skip to content

Commit

Permalink
fix: Hiding all setpoints didn't actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed Apr 8, 2021
1 parent fcc30b0 commit 3bc227c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/config/setpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default function parseSetpoints(
setpoints: Setpoints | false,
attributes: any
) {
if (setpoints === false) {
return {}
}

if (setpoints) {
const def = Object.keys(setpoints)
return def.reduce((result, name: string) => {
Expand Down
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ function getModeList(
return attributes[`${type}_modes`]
.filter((modeOption) => shouldShowModeControl(modeOption, specification))
.map((modeOption) => {
const values = typeof specification[modeOption] === 'object' ? specification[modeOption] : {} as {}
const values =
typeof specification[modeOption] === 'object'
? specification[modeOption]
: ({} as {})
return {
icon: MODE_ICONS[modeOption],
value: modeOption,
Expand Down Expand Up @@ -166,7 +169,7 @@ export default class SimpleThermostat extends LitElement {

const attributes = entity.attributes

let values = parseSetpoints(this.config?.setpoints ?? false, attributes)
let values = parseSetpoints(this.config?.setpoints ?? null, attributes)

// If we are updating the values, and they are now equal
// we can safely assume we've been able to update the set points
Expand Down

0 comments on commit 3bc227c

Please sign in to comment.