syepes
November 2, 2019, 11:43pm
1
Hello All,
Does someone know if its possible to define a custom command of type "ENUM?
I have tried the below code but does not seam to work
metadata {
definition (name: "Pilot Wire", namespace: "syepes") {
command "pilotMode", [[name:"mode",type:"enum", description:"Pilot mode", options:[[0:"Stop"],[15:"Anti Freeze"],[25:"Eco"],[35:"Comfort-2"],[45:"Comfort-1"],[100:"Comfort"]]]]
}
}
This is the only documentation i could find around this topic, does someone know another resource?
https://docs.smartthings.com/en/latest/device-type-developers-guide/definition-metadata.html#commands
Best regards,
Seb
ogiewon
November 2, 2019, 11:58pm
2
Here is a post that I had bookmarked that might be useful.
This was intended for documentation but slipped...
The command definition in drivers allows now for an optional 3 map to be passed into commands
Original code:
command "testEnum", ["Enum"]
resulted in this:
[image]
with 2.0 we added support for defining a few things:
command "testEnum", [[name:"Testing Enum", type: "ENUM", description: "Pick an option", constraints: ["one","two","three"] ] ]
will result in this:
[image]
What has happened is we have expanded the 2nd parameter to command…
I couldn’t get a map enum to work either. I ended up creating a helper function that would turn the chosen input value into the number I was looking for based on the string. Ugly but worked.
syepes
November 3, 2019, 9:19am
4
Thanks this is just what I was looking for.
1 Like