I’m having a problem with a variable or state. I have created a stare named bgC and I am using this as a variable to store a colour in HEX, eg #223C4A. This value changes based on a colour changer tile for a lightbulb.
What I am trying to do is call this HEX value as a label for a tile.
What does your full tile code look like? I don’t think tile labels can run code dynamically. The best practice would be to use an attribute, and it will update when an event updates that attribute.
For color in hex, you can just use the color attribute which is the hex value from the color picker.
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
3
You need to use sendEvent() to update the State of an Attribute or Value used in a Tile.
Sorry guys, I just noticed I have put some incorrect information in my original post. I have updated this now. I am using the following to call the function in order to get the value of the state.
state "colorName", label:getBgHex()
As I said before, if I manually set a value in my function, like this,
private getBgHex(){
return "#FFFFFF"
}
My tile will update to display #FFFFFF as its label, no I need to be able to return the value of a state but when I attempt to use the following code my tile displays the word NULL but I can see in the debug log that the state is set correctly to a HEX value.
You can’t call a function in the tiles section. The tiles aren’t dynamic. They only load/reload on event changes, which is why you can’t have a tile background color match a dynamic hex value. The second instance probably works because the function effectively is a constant.
If you post your entire device handler code, maybe we can see what you’re trying to do and help you find he best solution available with the current constraints of the API.