diff --git a/src/dialogs/more-info/controls/more-info-lock.js b/src/dialogs/more-info/controls/more-info-lock.js index 999d64967a..703c5a86f8 100644 --- a/src/dialogs/more-info/controls/more-info-lock.js +++ b/src/dialogs/more-info/controls/more-info-lock.js @@ -5,30 +5,32 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import '../../../components/ha-attributes.js'; -class MoreInfoLock extends PolymerElement { +import LocalizeMixin from '../../../mixins/localize-mixin.js'; + +/* + * @appliesMixin LocalizeMixin + */ +class MoreInfoLock extends LocalizeMixin(PolymerElement) { static get template() { return html` - + -
- - Unlock - Lock -
- -`; + + + `; } static get properties() { return { - hass: { - type: Object, - }, - + hass: Object, stateObj: { type: Object, observer: 'stateObjChanged', @@ -37,28 +39,23 @@ class MoreInfoLock extends PolymerElement { type: String, value: '', }, - isLocked: Boolean, + isLocked: Boolean }; } - handleUnlockTap() { - this.callService('unlock', { code: this.enteredCode }); - } - - handleLockTap() { - this.callService('lock', { code: this.enteredCode }); - } - stateObjChanged(newVal) { if (newVal) { this.isLocked = newVal.state === 'locked'; } } - callService(service, data) { - var serviceData = data || {}; - serviceData.entity_id = this.stateObj.entity_id; - this.hass.callService('lock', service, serviceData); + callService(ev) { + const service = ev.target.getAttribute('data-service'); + const data = { + entity_id: this.stateObj.entity_id, + code: this.enteredCode + }; + this.hass.callService('lock', service, data); } } diff --git a/src/translations/en.json b/src/translations/en.json index 7ec899fe4d..dee1cc046f 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -344,6 +344,11 @@ "white_value": "White value", "effect": "Effect" }, + "lock": { + "code": "[%key:ui::card::alarm_control_panel::code%]", + "lock": "Lock", + "unlock": "Unlock" + }, "media_player": { "text_to_speak": "Text to speak" },