We’re developing an OAuth API app.
We have a subscription to a power outlet. We want to know when someone turns the device attached to it on or off (not the outlet itself, but whatever is plugged into it).
We use a subscription like this:
{
"id": "*****",
"installedAppId": "*****",
"sourceType": "CAPABILITY",
"capability": {
"locationId": "*****",
"capability": "powerMeter",
"attribute": "power",
"value": "*",
"stateChangeOnly": true,
"subscriptionName": "all_power_sub",
"modes": []
}
}
This works well for OFF events (when value == 0), but we get a deluge of ON events, as each small fluctuation in power consumption fires.
We’ve tried also subscribing to other capabilities: energyMeter, switch, voltageMeasurement - but these don’t help.
This seems quite a basic requirement for a smart plug, so we think we must be missing something. We hoped “stateChangeOnly” would limit the triggers to on/off, but that doesn’t seem to be the case.
Is there any way (without ourselves storing the state of the device) to limit the trigger to when the powerMeter moves from 0 to >0, or to throttle it so the change in power needs to be a specific minimum number? Can we add some kind of formula to the ‘value’ field, or is there another way to solve this?