Hi @erickv - first, thank you for your patience in helping me. I am no developer and learning as we go. Second, is it ok to share my namespace? Wasnβt sure if this was sensitive info or not.
Here is the updated 2 custom capabilities. Did I configure them right?
Capability: fieldoften55628.petfeeder
Attributes:
ββββββββββ¬βββββββββ¬βββββββββ
β Name β Type β Setter β
ββββββββββΌβββββββββΌβββββββββ€
β Status β string β β
ββββββββββ΄βββββββββ΄βββββββββ
Commands:
ββββββββββββββββ¬βββββββββββββββββββββββββββ
β Name β Arguments β
ββββββββββββββββΌβββββββββββββββββββββββββββ€
β dispenseFood β bfeed: string (optional) β
β β sfeed: string (optional) β
β β vfeed: string (optional) β
ββββββββββββββββ΄βββββββββββββββββββββββββββ
Capability: fieldoften55628.petfeederstatus
Attributes:
ββββββββββ¬ββββββββββ¬ββββββββββββ
β Name β Type β Setter β
ββββββββββΌββββββββββΌββββββββββββ€
β Status β boolean β setStatus β
ββββββββββ΄ββββββββββ΄ββββββββββββ
Commands:
βββββββββββββ¬βββββββββββββββββ
β Name β Arguments β
βββββββββββββΌβββββββββββββββββ€
β isOnline β value: boolean β
β isOffline β value: boolean β
β setStatus β value: boolean β
βββββββββββββ΄βββββββββββββββββ
Here is where I am with the DTH code. I would like on the dashboard a button to execute βbfeedβ and I would like to see the status βOnlineβ or βOfflineβ. How will I go about getting the status from the device? I just want to see if its connected to the internet. I think I can do this with another httppost if that is an option. Is there an easier way? Now for each command in the detailView, I only need an actual button for the βbfeedβ command. The other 2 commands I would like to execute via a schedule using smartthings (sfeed) and via Alexa voice command (vfeed). Hope this makes sense. If all three buttons will be there, that is fine, just not necessary. I am also not sure how the βpetfeederstatusβ capability fits in here. Thanks for your help!
/**
* Pet feeder capability
*
*/
preferences {
section("Your Particle credentials and device Id:") {
input("token", "text", title: "Access Token")
input("deviceId", "text", title: "Device ID")
}
}
metadata {
definition (name: "Pet feeder testing button", namespace: "fieldoften55628", author: "CHRIS KULAKOWSKI", cstHandler: true){
capability "fieldoften55628.petfeeder"
capability "fieldoften55628.petfeederstatus"
}
simulator {}
tiles {
}
}
{
// This section will allow you to get
// the current state of the capability.
// However, there's no action permitted
// here. Action will be available at the
// detailView section.
"dashboard": {
"states": [
{
"label": "{{Status.value}}"
}
],
"actions": [
{
"pushButton": {
"command": "dispenseFood",
"argument": "bfeed"
},
"state": {
"value": "fieldoften55628.petfeederstatus",
}
}
]
}
// This section will provide access to the
// supported arguments/values that the capability
// can display.
// Each alternative will display an individual
// option.
"detailView": [
{
"label": "Feeder status:",
"displayType": "list",
"list": {
"state": {
"label": "Status.value",
"value": "Status.value",
"alternatives": [
{
"key": "bfeed",
"value": "Fed by button"
},
{
"key": "vfeed",
"value": "Fed by voice command"
},
{
"key": "sfeed",
"value": "Fed by schedule"
}
]
},
"command": {
"name": "dispenseFood",
"alternatives": [
{
"key": "bfeed",
"value": "Feed by button"
},
{
"key": "vfeed",
"value": "Feed by voice command"
},
{
"key": "sfeed",
"value": "Feed by schedule"
}
]
}
}
}
]
}
def dispenseFood () {
log.debug "Dispensing food"
httpPost(
uri: "https://api.particle.io/v1/devices/${deviceId}/feed",
body: [access_token: token, command: cmd],
) {response -> log.debug (response.data)}
}