I have updated my device handler to include additional Power and Voltage capabilities. These have worked before but have now stopped working when Querying from the REST API.
If I make a Query to get the device the following is returned from the endpoint https://api.smartthings.com/v1/devices
{
"deviceId": "c08f78d4-a8fb-461d-9b22-16b87f6dc058",
"name": "Aeotec Outlet",
"label": "Aeotec Outlet",
"manufacturerName": "SmartThings",
"presentationId": "SmartThings-smartthings-Aeon_Outlet",
"deviceManufacturerCode": "0086-0003-0060",
"locationId": "XXXXXXXXXXXXXXXXXXXXXXXXXXX",
"roomId": "1bc68cbb-9207-46fa-81d0-46763a1fa835",
"deviceTypeId": "472ab328-ab65-468c-aeb3-fafe80b5b0b6",
"deviceTypeName": "Aeon Outlet",
"deviceNetworkType": "ZWAVE",
"components": [
{
"id": "main",
"capabilities": [
{
"id": "switch",
"version": 1
},
{
"id": "configuration",
"version": 1
},
{
"id": "refresh",
"version": 1
},
{
"id": "energyMeter",
"version": 1
},
{
"id": "powerMeter",
"version": 1
},
{
"id": "sensor",
"version": 1
},
{
"id": "actuator",
"version": 1
},
{
"id": "voltageMeasurement",
"version": 1
}
],
"categories": [
{
"name": "SmartPlug"
}
]
}
],
"dth": {
"deviceTypeId": "472ab328-ab65-468c-aeb3-fafe80b5b0b6",
"deviceTypeName": "Aeon Outlet",
"deviceNetworkType": "ZWAVE",
"completedSetup": true,
"networkSecurityLevel": "ZWAVE_LEGACY_NON_SECURE",
"hubId": "5347764a-2b3b-4be5-a9d1-515f519f0e5f",
"executingLocally": false
},
"type": "DTH",
"restrictionTier": 0
}
From this it is registering that the capabilities have been added, however when I make a request to get the status of the device the following is returned. There is no powerMeter
or voltageMeasurement
present. This is returned from the endpoint https://api.smartthings.com/v1/devices/c08f78d4-a8fb-461d-9b22-16b87f6dc058/status
{
"components": {
"main": {
"actuator": {},
"configuration": {},
"energyMeter": {
"energy": {
"value": 0.595,
"unit": "kWh",
"timestamp": "2020-11-09T10:29:44.216+0000"
}
},
"refresh": {},
"sensor": {},
"switch": {
"switch": {
"value": "off",
"timestamp": "2020-11-09T10:30:32.232+0000"
}
}
}
}
}
Trying to query the capabilities directly from https://api.smartthings.com/v1/devices/c08f78d4-a8fb-461d-9b22-16b87f6dc058/components/main/capabilities/voltageMeasurement/status
and https://api.smartthings.com/v1/devices/c08f78d4-a8fb-461d-9b22-16b87f6dc058/components/main/capabilities/powerMeter/status
returns an error shown below.
{
"requestId": "1C2B74F5-9884-46F3-9BBF-C054B2086DF5",
"error": {
"code": "ConstraintViolationError",
"message": "The request is malformed.",
"details": [
{
"target": "capability",
"message": "can't read capability!",
"details": []
}
]
}
}
However issuing the same request to the Energy Meter at https://api.smartthings.com/v1/devices/c08f78d4-a8fb-461d-9b22-16b87f6dc058/components/main/capabilities/energyMeter/status
returns the expected output.
{
"energy": {
"value": 0.595,
"unit": "kWh",
"timestamp": "2020-11-09T10:29:44.216+0000"
}
}
The values on the device handler are updating within SmartThings but its just the API which is causing a problem. I know they are updating as I can see it in my events log.
My Device Handler Definition.
metadata {
definition (name: "Aeon Outlet", namespace: "smartthings", author: "SmartThings", runLocally: true, minHubCoreVersion: '000.017.0012', executeCommandsLocally: false) {
capability "Voltage Measurement"
capability "Energy Meter"
capability "Power Meter"
capability "Actuator"
capability "Switch"
capability "Configuration"
capability "Refresh"
capability "Sensor"
command "reset"
fingerprint deviceId: "0x1001", inClusters: "0x25,0x32,0x27,0x2C,0x2B,0x70,0x85,0x56,0x72,0x86", outClusters: "0x82", deviceJoinName: "Aeon Outlet"
}
// simulator metadata
simulator {
status "on": "command: 2003, payload: FF"
status "off": "command: 2003, payload: 00"
for (int i = 0; i <= 10000; i += 1000) {
status "power ${i} W": new physicalgraph.zwave.Zwave().meterV3.meterReport(
scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()
}
for (int i = 0; i <= 100; i += 10) {
status "energy ${i} kWh": new physicalgraph.zwave.Zwave().meterV3.meterReport(
scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()
}
// reply messages
reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
reply "200100,delay 100,2502": "command: 2503, payload: 00"
}
// tile definitions
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "generic", width: 6, height: 4, canChangeIcon: true){
tileAttribute("device.switch", key: "PRIMARY_CONTROL") {
attributeState("on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00a0dc")
attributeState("off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff")
}
}
valueTile("energy", "device.energy", decoration: "flat", width: 2, height: 2) {
state "default", label:'${currentValue} kWh'
}
valueTile("voltage", "device.voltage", decoration: "flat", width: 2, height: 2) {
state "default", label:'${currentValue} V'
}
valueTile("power", "device.power", decoration: "flat", width: 2, height: 2) {
state "default", label:'${currentValue} W'
}
standardTile("reset", "device.energy", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "default", label:'reset kWh', action:"reset"
}
standardTile("configure", "device.power", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
}
main "switch"
details(["switch","energy","voltage","power","reset","refresh","configure"])
}
}