Skip to content

Commit

Permalink
Support entity+attribute combo for sensors. Fixes #50
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed May 18, 2019
1 parent ce6d733 commit e8e9ad8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ resources:
- `hide` _object_: Control specifically information fields to show. Defaults to showing everything
- `temperature`: _bool_ (Default to `false`)
- `state`: _bool_ (Default to `false`)
- ~`mode`: _bool_ (Default to `false`)~ **DEPRECATED IN 0.19**
- `away`: _bool_ (Default to `true`)
t - `away`: _bool_ (Default to `true`)
- `modes` _object|bool_ (From 0.19)
- `{mode_key}` _object|bool_: The key of the mode to define
- `include` _bool_: Whether to include this mode in the list or not
Expand All @@ -60,7 +59,7 @@ resources:
- `sensors` _array_
- `entity` _string_: A sensor value entity id
- `name` _string_: Specify a sensor name to use instead of the default friendly_name
- `attribute` _string_: The key for an attribute provided by the main entity (for example `min_temp`)
- `attribute` _string_: The key for an attribute to use instead of state. If this sensor has no entity it will use the main entity's attributes
- `unit` _string_: When specifying an attribute you can manually set the unit to display

## A note on modes
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ class SimpleThermostat extends LitElement {
name.push(
state && state.attributes && state.attributes.friendly_name
)
if (attribute) {
state = state.attributes[attribute] + unit
}
} else if (attribute && attribute in this.entity.attributes) {
state = this.entity.attributes[attribute] + unit
name.push(attribute)
Expand Down

0 comments on commit e8e9ad8

Please sign in to comment.