Skip to content
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

Merged
merged 1 commit into from
Nov 29, 2016
Merged

Add optional repeat query parameter to repeat commands. #43

merged 1 commit into from
Nov 29, 2016

Conversation

farooqu
Copy link
Contributor

@farooqu farooqu commented Nov 28, 2016

This adds the ability to specify an optional repeat query for command POSTS which will issue that command that number of times.

@farooqu
Copy link
Contributor Author

farooqu commented Nov 28, 2016

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.

@maddox
Copy link
Owner

maddox commented Nov 28, 2016

Why not just multiple requests?

@farooqu
Copy link
Contributor Author

farooqu commented Nov 28, 2016

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.

@maddox
Copy link
Owner

maddox commented Nov 28, 2016

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".

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 | or something? Would love to hear some ideas.

@farooqu
Copy link
Contributor Author

farooqu commented Nov 29, 2016

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.

@maddox
Copy link
Owner

maddox commented Nov 29, 2016

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"}
Copy link
Owner

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"}

@maddox
Copy link
Owner

maddox commented Nov 29, 2016

Have you tested this, does it work well without any pause between sending the commands?

@farooqu
Copy link
Contributor Author

farooqu commented Nov 29, 2016

I've tested the HTTP implementation, and use it with volume-up and volume-down, work's pretty nicely.

@farooqu
Copy link
Contributor Author

farooqu commented Nov 29, 2016

I squashed all of the commits and merges into one.

@maddox maddox merged commit f2e0d32 into maddox:master Nov 29, 2016
@farooqu farooqu deleted the repeat-commands branch November 29, 2016 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants