키 값 API는 기기, 방, 자동화 객체를 위한 새로운 맞춤 데이터 관리 API를 제공합니다. 맞춤 데이터의 수명 주기는 연결된 객체의 수명 주기로 엄격하게 범위가 지정됩니다. 예를 들어 회의실 객체와 연결된 맞춤 데이터('루시의 방' 등)는 회의실 객체와 함께 자동으로 삭제, 이동 또는 전송됩니다 (구조 간).
Kotlin API 변경사항은 hasCustomAppData 인터페이스를 중심으로 하며, 맞춤 애플리케이션 데이터가 속한 객체에 확장 프로그램을 제공하고 표준 생성, 읽기, 업데이트, 삭제(CRUD) 함수를 포함합니다.
기기 예시
val device = homeClient.devicesWithLogging().findDeviceByName(deviceName)
var response = device.getValue(key)
println("Before: $response")
device.updateValue(key, value)
response = device.getValue(key)
println("After: $response")
device.deleteValue(key)
Room 예시
val room = homeClient.rooms().findRoomByName(roomName)
room.updateValue("nickname", "Lucy's Room")
val response = room.getValue("nickname")
room.deleteValue("nickname")
자동화 예시
val automation = homeClient.automations().findAutomationByName(automationName)
var response = automation.getValue(key)
println("Before: $response")
automation.updateValue(key, value)
response = automation.getValue(key)
println("After: $response")
automation.deleteValue(key)
제한사항
- 키는 유효한 UTF-8 문자로 구성된 문자열이어야 하며 최대 길이는 128입니다. 키는 빈 문자열일 수 있습니다.
- 값은 유효한 UTF-8 문자로 구성된 문자열이어야 하며 최대 길이는 1024입니다. 값은 빈 문자열일 수 있습니다.
- 각 객체에는 10개의 키-값 쌍 행이 있을 수 있습니다.