Can currentValue from one tileAttribute be used in another?

Apologies for the vague question/topic.

Reference this snippet of code:

    multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true, decoration: "flat"){
        tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
            attributeState "on", action: "switch.off", label: 'OPEN', icon: "st.vents.vent-open", backgroundColor: "#53a7c0"
            attributeState "off", action: "switch.on", label: "CLOSED", icon: "st.vents.vent-open", backgroundColor: "#ffffff"
            attributeState "obstructed", action: "clearObstruction", label: "OBSTRUCTION", icon: "st.vents.vent-open", backgroundColor: "#ff0000"
            attributeState "clearing", action: "", label: "CLEARING", icon: "st.vents.vent-open", backgroundColor: "#ffff33"
        }
        tileAttribute ("device.level", key: "SLIDER_CONTROL") {
            attributeState "level", action:"switch level.setLevel"
        }
    }

I would really like the value from “level” to be included in the label for OPEN (on attributeState). The reason why is that when you look at the list of devices in a Room, vents in this example, they just show as OPEN or CLOSED.

It would be nice if I could make it look like this:

I guess it’s all just “look and feel”, but that additional information would keep me from having to go into each device to check that it’s set to where I want it.

I would appreciate the feedback from developers more experienced than me cause I’m not sure how to do that, and/or if it can be done.

Anyone?

2 Likes

How about a “vague answer” for now then?

You can create arbitrary Attributes and Values internally in any Device type; you just have to also decide on what official Capabilities you provide and what official Attributes, Commands, and Values you support externally.

So there’s nothing preventing you from creating a compound Attribute that has a Value of “50% Open” … you’ll just need to write extra Methods that issue and handle regular “open/closed” Events as well.

That said… there are some firm limitations that are hard to predict in advance. Combining Value and State on one Tile is going to take a lot of frustrating attempts with creative approaches and many approaches won’t work.

Hopefully someone has already done that legwork and will respond…; but I do have a very similar use case in the works, so I might get there soon too.

2 Likes