-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional repeat query parameter to repeat commands. #43
Conversation
I know nothing about MQTT so wasn't sure of how to implement this with it, as a result I only did this for HTTP. |
Why not just multiple requests? |
The use case I had in mind was for volume controls with Amazon Alexa/Google Home. It's awkward to have to say "turn the volume up", "turn the volume up", "turn the volume up". So you can setup "turn volume up" to make one request which specifies the number of times you want it to go up. Likewise, you can say something like "turn volume up 5 times" and still issue the request one time, but with repeat as 5. |
lmao, what's wrong with that? That should only take about 45 seconds to accomplish. Ok, lets figure out what the mqtt version of this looks like. I think this came up in the past. We could do some sort of serialized message I guess. Separated by a |
I think just having an optional ":repeatInt" following the command name should do the trick. That way we can split on ':', and we'll always get the command name as the first index, and either the repeat int, or undefined as the second index and we can treat that just like the ?repeat= request query. |
This is good, I like that. It feels real nice, just a count specifier for the command name. Love it. |
@@ -236,6 +250,9 @@ These are the endpoints you can hit to do things. | |||
PUT /hubs/:hub_slug/off => {message: "ok"} | |||
POST /hubs/:hub_slug/activities/:activity_slug => {message: "ok"} | |||
POST /hubs/:hub_slug/devices/:device_slug/commands/:command_slug => {message: "ok"} | |||
POST /hubs/:hub_slug/current_activity/commands/:command_slug => {message: "ok"} | |||
POST /hubs/:hub_slug/devices/:device_slug/commands/:command_slug/?repeat=3 => {message: "ok"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these shouldn't have slashes at the end:
POST /hubs/:hub_slug/devices/:device_slug/commands/:command_slug?repeat=3 => {message: "ok"}
Have you tested this, does it work well without any pause between sending the commands? |
I've tested the HTTP implementation, and use it with volume-up and volume-down, work's pretty nicely. |
I squashed all of the commits and merges into one. |
This adds the ability to specify an optional repeat query for command POSTS which will issue that command that number of times.