armzilla / amazon-echo-ha-bridge

emulates philips hue api to other home automation gateways
Apache License 2.0
732 stars 168 forks source link

Script support #25

Closed ggrip closed 9 years ago

ggrip commented 9 years ago

Arm,

 Firstly, thanks for this amazing piece of software.  I now have all my lights talking to Alexa.  So, to my

request; as I don't know Java, I really can't help with this, but it would be nice to have a drop down that let you put in local scripts instead of URLs for on and off. I use a mix of Wemo and Lifx bulbs and neither have a RESTful interface that I can use with your software (Lifx's RESTful interface requires you to POST or PUT instead of a GET). Again, not really an issue, but more of an enhancement request. Thanks again.

Dan-

maddox commented 9 years ago

RESTful interface requires you to POST or PUT instead of a GET

It would be nice if we could have the option to provide the HTTP method for the URL.

I too have some of my own custom software that I have amazon-echo-ha-bridge pointing at and had to make my URL endpoints GETs. I'm not very comfortable with this, as GET urls are easy to hit and these URLs are pointing at potentially important things. I'd prefer they be POSTs or PUTs. If anything, it's more compliant with a REST system.

If anything, it'd be nice the default was POST.

armzilla commented 9 years ago

I agree. I was initially worried/lazy about the difficulty of creating templates for the post/put body nor had any use case that required a different http method . Should be an easy add. Should be in the next release this week.

On Wed, Aug 12, 2015, 12:23 Jon Maddox notifications@github.com wrote:

RESTful interface requires you to POST or PUT instead of a GET

It would be nice if we could have the option to provide the HTTP method for the URL.

I too have some of my own custom software that I have amazon-echo-ha-bridge pointing at and had to make my URL endpoints GETs. I'm not very comfortable with this, as GET urls are easy to hit and these URLs are pointing at potentially important things. I'd prefer they be POSTs or PUTs. If anything, it's more compliant with a REST system.

If anything, it'd be nice the default was POST.

— Reply to this email directly or view it on GitHub https://github.com/armzilla/amazon-echo-ha-bridge/issues/25#issuecomment-130381965 .

maddox commented 9 years ago

Should be in the next release this week

Nice!! Thanks!

armzilla commented 9 years ago

added in 28ba226b7a2c649a115f0809bf69855eb5c4bec6

armzilla commented 9 years ago

please try out in the preview v0.2.1 release. create a new device

{ "name": "test device", "deviceType": "switch", "offUrl": "http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31", "onUrl": "http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}", "contentType" : "application/json", "httpVerb":"POST", "contentBody" : "{\"fooBar\":\"baz\"}" }

note the escape of quotes in the content body. currently no validation of the content type, invalid content types WILL explode!