mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-25 13:04:10 +00:00
create i18n and align arrival-sensor-ha SA file
This commit is contained in:
@@ -11,6 +11,17 @@
|
|||||||
* for the specific language governing permissions and limitations under the License.
|
* for the specific language governing permissions and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Purpose: Arrival Sensor HA DTH File
|
||||||
|
*
|
||||||
|
* Filename: Arrival-Sensor-HA.src/Arrival-Sensor-HA.groovy
|
||||||
|
*
|
||||||
|
* Change History:
|
||||||
|
* 1. 20160115 TW - Update/Edit to support i18n translations
|
||||||
|
* 2. 20160121 TW - Update to V4 battery calcs, added pref's page title translations
|
||||||
|
*/
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "Arrival Sensor HA", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "Arrival Sensor HA", namespace: "smartthings", author: "SmartThings") {
|
||||||
capability "Tone"
|
capability "Tone"
|
||||||
@@ -32,7 +43,7 @@ metadata {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
input "checkInterval", "enum", title: "Presence timeout (minutes)",
|
input "checkInterval", "enum", title: "Presence timeout (minutes)", description: "Tap to set",
|
||||||
defaultValue:"2", options: ["2", "3", "5"], displayDuringSetup: false
|
defaultValue:"2", options: ["2", "3", "5"], displayDuringSetup: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +93,6 @@ def parse(String description) {
|
|||||||
|
|
||||||
private handleReportAttributeMessage(String description) {
|
private handleReportAttributeMessage(String description) {
|
||||||
def descMap = zigbee.parseDescriptionAsMap(description)
|
def descMap = zigbee.parseDescriptionAsMap(description)
|
||||||
|
|
||||||
if (descMap.clusterInt == 0x0001 && descMap.attrInt == 0x0020) {
|
if (descMap.clusterInt == 0x0001 && descMap.attrInt == 0x0020) {
|
||||||
handleBatteryEvent(Integer.parseInt(descMap.value, 16))
|
handleBatteryEvent(Integer.parseInt(descMap.value, 16))
|
||||||
}
|
}
|
||||||
@@ -94,6 +104,7 @@ private handleReportAttributeMessage(String description) {
|
|||||||
* @param volts Battery voltage in .1V increments
|
* @param volts Battery voltage in .1V increments
|
||||||
*/
|
*/
|
||||||
private handleBatteryEvent(volts) {
|
private handleBatteryEvent(volts) {
|
||||||
|
def descriptionText
|
||||||
if (volts == 0 || volts == 255) {
|
if (volts == 0 || volts == 255) {
|
||||||
log.debug "Ignoring invalid value for voltage (${volts/10}V)"
|
log.debug "Ignoring invalid value for voltage (${volts/10}V)"
|
||||||
}
|
}
|
||||||
@@ -107,15 +118,17 @@ private handleBatteryEvent(volts) {
|
|||||||
volts = minVolts
|
volts = minVolts
|
||||||
else if (volts > maxVolts)
|
else if (volts > maxVolts)
|
||||||
volts = maxVolts
|
volts = maxVolts
|
||||||
def pct = batteryMap[volts]
|
def value = batteryMap[volts]
|
||||||
if (pct != null) {
|
if (value != null) {
|
||||||
def linkText = getLinkText(device)
|
def linkText = getLinkText(device)
|
||||||
|
descriptionText = '{{ linkText }} battery was {{ value }}'
|
||||||
def eventMap = [
|
def eventMap = [
|
||||||
name: 'battery',
|
name: 'battery',
|
||||||
value: pct,
|
value: value,
|
||||||
descriptionText: "${linkText} battery was ${pct}%"
|
descriptionText: descriptionText,
|
||||||
|
translatable: true
|
||||||
]
|
]
|
||||||
log.debug "Creating battery event for voltage=${volts/10}V: ${eventMap}"
|
log.debug "Creating battery event for voltage=${volts/10}V: ${linkText} ${eventMap.name} is ${eventMap.value}%"
|
||||||
sendEvent(eventMap)
|
sendEvent(eventMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,13 +144,19 @@ private handlePresenceEvent(present) {
|
|||||||
stopTimer()
|
stopTimer()
|
||||||
}
|
}
|
||||||
def linkText = getLinkText(device)
|
def linkText = getLinkText(device)
|
||||||
|
def descriptionText
|
||||||
|
if ( present )
|
||||||
|
descriptionText = "{{ linkText }} has arrived"
|
||||||
|
else
|
||||||
|
descriptionText = "{{ linkText }} has left"
|
||||||
def eventMap = [
|
def eventMap = [
|
||||||
name: "presence",
|
name: "presence",
|
||||||
value: present ? "present" : "not present",
|
value: present ? "present" : "not present",
|
||||||
linkText: linkText,
|
linkText: linkText,
|
||||||
descriptionText: "${linkText} has ${present ? 'arrived' : 'left'}",
|
descriptionText: descriptionText,
|
||||||
|
translatable: true
|
||||||
]
|
]
|
||||||
log.debug "Creating presence event: ${eventMap}"
|
log.debug "Creating presence event: ${device.displayName} ${eventMap.name} is ${eventMap.value}"
|
||||||
sendEvent(eventMap)
|
sendEvent(eventMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#==============================================================================
|
||||||
|
# Copyright 2016 SmartThings
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
# use this file except in compliance with the License. You may obtain a copy
|
||||||
|
# of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#==============================================================================
|
||||||
|
# Purpose: Arrival Sensor HA i18n Translation File
|
||||||
|
#
|
||||||
|
# Filename: Arrival-Sensor-HA.src/i18n/messages.properties
|
||||||
|
#
|
||||||
|
# Change History:
|
||||||
|
# 1. 20160115 TW Initial release with informal Korean translation.
|
||||||
|
# 2. 20160121 TW Added def preference section titles.
|
||||||
|
#==============================================================================
|
||||||
|
# Korean (ko)
|
||||||
|
# Device Preferences
|
||||||
|
'''Give your device a name'''.ko=장치 이름을 지정
|
||||||
|
'''Set Device Image'''.ko=설정 장치 이미지
|
||||||
|
'''Presence timeout (minutes)'''.ko=현재 제한 시간 ( 분)
|
||||||
|
'''Tap to set'''.ko=설정 탭
|
||||||
|
'''Arrival Sensor'''.ko=도착 센서
|
||||||
|
# Events / Notifications
|
||||||
|
'''{{ linkText }} battery was {{ value }}'''.ko={{ linkText }} 배터리가 {{ value }}였습니다
|
||||||
|
'''{{ linkText }} has arrived'''.ko={{ linkText }} 도착
|
||||||
|
'''{{ linkText }} has left'''.ko={{ linkText }} 남아있다
|
||||||
|
#==============================================================================
|
||||||
Reference in New Issue
Block a user