Hi,
I’m trying to get my devices to only subscribe to a webhook if it’s relevant to them. I have a number of devices controlling lights around my home, and want to push updated schedules to them when I make changes to them. At the moment, if I save the schedules for one device, all devices receive the updates, and have to trawl through to find the data relevant to them (by deviceID).
I’ve been reading through a number of topics here, and especially this one: Subscribe to a Webhook response triggered by a specific device, but if I implement {{SPARK_CORE_ID}} in the responseTopic then it is evaluated to an empty string. I can see that the value is evaluated in the query section, as the data returned is filtered down to only one device.
Here’s my webhook json (I’ve added the last two keys in an attempt for that to kick something, json and auth could probably be removed too).
When subscribing to events, I can see that the response is posted to hook-response/device_schedules_ (i.e. {{SPARK_CORE_ID}} is evaluated to empty string. Removing the responseTopic makes the response go back to hook-response/device_schedules_hook.
Please would you help me out, I’ve generated and destroyed dozens of hooks trying to make this work! Really feels like something in the background is buggy, and/or has changed since the last good advice was written up here.
It's not clear why you are using a webhook. If you want to send something to only one device, you could publish a update_schedule/DEVICE_ID event and have each device subscribe with its own id.
My data is currently around 1500 characters, so will have to chunk down the data myself. Was keen to use built-in functionality wherever possible, but may give your idea a go and send each updated schedule one record at a time.
Either way, I’m very sure the {{SPARK_CORE_ID}} should be getting evaluated in the responseTopic.
does work. The core id is appended to the response topic.
This might be ok for you, but I need to set noDefaults to false for other reasons, so I am trying to pass data to the webhook and cannot get this to work: