Hello,
I would like to create a device that can send our this http api:
http://{username}:{password}@{ipaddress}:{port}/api/callAction?deviceID=4&name=turnOff
I have tried this on browser and it works but I need a smart device that can pre-input device preferences including username, password, ip, port, and the api command. I think it would be something like the code for Generic Camera Device but used to send out command:
Preferences (edit)
Camera IP Address: 192.168.2.7
Camera Port: 80
Camera Path to Image: /api/callAction?deviceID=33&name=turnOn
Does Camera require User Auth?: false
Does Camera use a Post or Get, normally Get?: Get
Camera User: admin
Camera Password: admin
Can someone provide help on this code or advice which sample code I should look into?
Thank you so much.
Billy
just to get you some light reading for the day
1
https://support.smartthings.com/hc/en-us/articles/200901260-HTTP-Methods
2
http://docs.smartthings.com/en/latest/smartapp-developers-guide/calling-web-services-in-smartapps.html?highlight=httpget
3
Has anyone successfully retrieved data out of a web call? I have the below code along with results.
def successWebcall = { response ->
log.debug “Response was successful, $response”
}
def params = [
uri: “http://home.automation.server/IsAnyoneInTheHouse.php ”,
success: successWebcall
];
httpGet(params);
}
The above code returns: Response was successful, groovyx.net.http.HttpResponseDecorator@2162e9b7
I’ve looked up groovyx.net.http.HttpResponseDecorator and found there are many methods out there but I haven’t figured out how to access that data within SmartThings. 1) Has anyone been able to retrieve data from a website, and 2) is there an easy way for me/anyone to determine what is inside an object via a debug statement (or something).
Thanks in advance!
4
/**
* Traffic Report
*
* Copyright 2014 Brian Critchlow
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*
* --This SmartApp has the intention of notifying you of traffic conditions on your Hue bulbs and alerting you of departure time
* --based on that traffic. The app will request two locations, the expected time of arrival, and when to start polling for traffic.
* --It will also allow you to set the thresholds for traffic and what colors to change the Hue to.
*
* --Special thanks to scottinpollock for code examples
This file has been truncated. show original
5
/**
* ThermostatLogger. Logs thermostat temperature and operating state to Xively feed.
* See http://build.smartthings.com/projects/xively/ for more information.
*
* Author: @kernelhack
* Date: 2014-01-21
*/
// Automatically generated. Make future change here.
definition(
name: "Log to Xively",
namespace: "docwisdom",
author: "Brian Critchlow",
description: "Logging thermostat to Xively",
category: "Green Living",
iconUrl: "https://mbed.org/media/thumbs/f5/1b/f51b2107e58df9cffd95cfdec1a9bdec.jpg",
iconX2Url: "https://mbed.org/media/thumbs/f5/1b/f51b2107e58df9cffd95cfdec1a9bdec.jpg")
preferences {
section("Configure") {
This file has been truncated. show original
1 Like