1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00
Files
frontend/js/common/component/condition/numeric_state.js
Paulus Schoutsen 0707528bd7 Entity dropdown improvement (#674)
* Ignore hass changes while dropdown is open

* Upgrade vaadin-combo-box

* Fix styling on dev-service panel

* Fix styling for ha-entity-dropdown

* Fix height vaadin-combo-box dropdown

* Rename ha-entity-dropdown to ha-entity-picker

* More entity improvement (#675)

* Update script and automation editor to use entity picker

* Add entity and service picker to service dev panel

* Lint
2017-11-25 16:00:43 -08:00

59 lines
1.3 KiB
JavaScript

import { h, Component } from 'preact';
import { onChangeEvent } from '../../util/event.js';
export default class NumericStateCondition extends Component {
constructor() {
super();
this.onChange = onChangeEvent.bind(this, 'condition');
this.entityPicked = this.entityPicked.bind(this);
}
entityPicked(ev) {
this.props.onChange(this.props.index, {
...this.props.condition,
entity_id: ev.target.value,
});
}
/* eslint-disable camelcase */
render({ condition, hass }) {
const {
value_template, entity_id, below, above
} = condition;
return (
<div>
<ha-entity-picker
value={entity_id}
onChange={this.entityPicked}
hass={hass}
allowCustomEntity
/>
<paper-input
label="Above"
name="above"
value={above}
onChange={this.onChange}
/>
<paper-input
label="Below"
name="below"
value={below}
onChange={this.onChange}
/>
<paper-textarea
label="Value template (optional)"
name="value_template"
value={value_template}
onvalue-changed={this.onChange}
/>
</div>
);
}
}
NumericStateCondition.defaultConfig = {
entity_id: '',
};