Hi all! New SmartThings convert here, looking for a little help on setting up a custom device:
I have a virtual switch setup to control my arduino blinds through a GET link, and it works great. But my question is how can I tweak my virtual driver code to show tiles with the battery percentage and voltage values the blinds return? This would be super helpful to keep an eye on my solar blinds batteries!
Driver code:
/*
* Http GET Switch
*
* Calls URIs with HTTP GET for switch on or off
*
*/
metadata {
definition(name: "Http GET Switch", namespace: "community", author: "Community", importUrl: "https://raw.githubusercontent.com/hubitat/HubitatPublic/master/examples/drivers/httpGetSwitch.groovy") {
capability "Actuator"
capability "WindowShade"
capability "Switch"
capability "Sensor"
}
}preferences { section("URIs") { input "onURI", "text", title: "On URI", required: false input "offURI", "text", title: "Off URI", required: false input "openURI", "text", title: "Open URI", required: false input "closeURI", "text", title: "Close URI", required: false input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true } } def logsOff() { log.warn "debug logging disabled..." device.updateSetting("logEnable", [value: "false", type: "bool"]) } def updated() { log.info "updated..." log.warn "debug logging is: ${logEnable == true}" if (logEnable) runIn(1800, logsOff) } def parse(String description) { if (logEnable) log.debug(description) } def on() { if (logEnable) log.debug "Sending on GET request to [${settings.onURI}]" try { httpGet(settings.onURI) { resp -> if (resp.success) { sendEvent(name: "switch", value: "on", isStateChange: true) } if (logEnable) if (resp.data) log.debug "${resp.data}" } } catch (Exception e) { log.warn "Call to on failed: ${e.message}" } } def off() { if (logEnable) log.debug "Sending off GET request to [${settings.offURI}]" try { httpGet(settings.offURI) { resp -> if (resp.success) { sendEvent(name: "switch", value: "off", isStateChange: true) } if (logEnable) if (resp.data) log.debug "${resp.data}" } } catch (Exception e) { log.warn "Call to off failed: ${e.message}" } } def open() { if (logEnable) log.debug "Sending open GET request to [${settings.openURI}]" try { httpGet(settings.openURI) { resp -> if (resp.success) { sendEvent(name: "switch", value: "on", isStateChange: true) sendEvent(name: "windowShade", value: "open", isStateChange: true) } if (logEnable) if (resp.data) log.debug "${resp.data}" } } catch (Exception e) { log.warn "Call to open failed: ${e.message}" } } def close() { if (logEnable) log.debug "Sending close GET request to [${settings.closeURI}]" try { httpGet(settings.closeURI) { resp -> if (resp.success) { sendEvent(name: "switch", value: "off", isStateChange: true) sendEvent(name: "windowShade", value: "closed", isStateChange: true) } if (logEnable) if (resp.data) log.debug "${resp.data}" } } catch (Exception e) { log.warn "Call to close failed: ${e.message}" } }
Example response from HTTP GET as seen in browser:
Blind ID: 2 Group: 1 Level: 0 Battery: 97 Voltage: 4.19 Charging: N Success.