2016-01-30 16:32:55 +01:00
|
|
|
<link rel='import' href='../../bower_components/polymer/polymer.html'>
|
|
|
|
|
|
|
|
<link rel='import' href='../../bower_components/paper-button/paper-button.html'>
|
|
|
|
<link rel='import' href='../../bower_components/paper-input/paper-input.html'>
|
2017-01-25 18:30:02 +01:00
|
|
|
<link rel='import' href='../components/ha-attributes.html'>
|
2016-01-30 16:32:55 +01:00
|
|
|
|
|
|
|
<dom-module id='more-info-lock'>
|
|
|
|
<template>
|
2016-07-19 10:19:44 +02:00
|
|
|
<style>
|
|
|
|
paper-input {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2016-07-19 10:40:04 +02:00
|
|
|
<div hidden$='[[!stateObj.attributes.code_format]]'>
|
2016-02-25 07:03:43 +01:00
|
|
|
<paper-input label='code' value='{{enteredCode}}' pattern='[[stateObj.attributes.code_format]]' type='password'></paper-input>
|
2016-02-22 08:09:11 +01:00
|
|
|
<paper-button on-tap='handleUnlockTap' hidden$='[[!isLocked]]'>Unlock</paper-button>
|
|
|
|
<paper-button on-tap='handleLockTap' hidden$=[[isLocked]]>Lock</paper-button>
|
|
|
|
</div>
|
2017-01-25 18:30:02 +01:00
|
|
|
<ha-attributes state-obj='[[stateObj]]' extra-filters='code_format'></ha-attributes>
|
2016-01-30 16:32:55 +01:00
|
|
|
</template>
|
|
|
|
</dom-module>
|
2016-07-19 06:28:42 +02:00
|
|
|
|
|
|
|
<script>
|
|
|
|
Polymer({
|
|
|
|
is: 'more-info-lock',
|
|
|
|
properties: {
|
|
|
|
hass: {
|
|
|
|
type: Object,
|
|
|
|
},
|
|
|
|
|
|
|
|
stateObj: {
|
|
|
|
type: Object,
|
|
|
|
observer: 'stateObjChanged',
|
|
|
|
},
|
|
|
|
enteredCode: {
|
|
|
|
type: String,
|
|
|
|
value: '',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
handleUnlockTap: function () {
|
|
|
|
this.callService('unlock', { code: this.enteredCode });
|
|
|
|
},
|
|
|
|
|
|
|
|
handleLockTap: function () {
|
|
|
|
this.callService('lock', { code: this.enteredCode });
|
|
|
|
},
|
|
|
|
|
|
|
|
stateObjChanged: function (newVal) {
|
|
|
|
if (newVal) {
|
|
|
|
this.isLocked = newVal.state === 'locked';
|
|
|
|
}
|
|
|
|
this.async(function () {
|
|
|
|
this.fire('iron-resize');
|
|
|
|
}.bind(this), 500);
|
|
|
|
},
|
|
|
|
|
|
|
|
callService: function (service, data) {
|
|
|
|
var serviceData = data || {};
|
2017-01-30 03:34:45 +01:00
|
|
|
serviceData.entity_id = this.stateObj.entity_id;
|
|
|
|
this.hass.callService('lock', service, serviceData);
|
2016-07-19 06:28:42 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|