I am using Nest Direct device type to get Nest into v2 hub and it works perfectly
I have changed a few things and added the multiAttributeTile.
Now I am trying to have the color of the thermostat tile depending upon the target temperature. Basically I would like it to be red if the target temperature is higher than the ambient remperature.
Apologies for bringing this post to your attention again, but I have spent the last two days looking at different device type in order to find a solution without success.
Could someone tell me if this can be done or not?
I’m unsure at the moment as I haven’t had chance to play much and am very new to Groovy and the API but from what I can see you can use variable binding (e.g. ${currentValue}) it might be possible to make a variable and then whenever the temperature is updated, update the variable…
with 2 different temperatures I get tempcolour changing to #008000 therefore there must be something wrong in the test. I have also tried to add .currentvalue to both with no success…
Thanks anyway for helping.
Will do more tests
cheers
fab
I think this is a limitation of the ST platform. It looks like you can’t call any attribute from the metadata section of a devicetype. I did some testing and it looks like every time a devicetype is called it runs the metadata section again after it nulls all attributes.
below are some ways i tried using log.debug and the errors
groovy.lang.MissingPropertyException: No such property: attributename for class: physicalgraph.device.cache.DeviceDTO
device.attributename
Returns null
attributenameState
java.lang.NullPointerException: Cannot get property ‘attributename’ on null object
currentState.attributename
currentValue.attributename
groovy.lang.MissingMethodException: No signature of method: script.currentState() is applicable for argument types: (java.lang.String) values: [attributename]
The metadata bit is just a descriptor/definition of the device and how the UI is constructed. I believe that the ${currentValue} templates are replaced on the client side. Groovy does support lazy evaluation but only in double quote strings, and obviously this is in single quotes which makes a normal Java string which will likely get returned to the client in that form.
At least that’s what I think I’m seeing
Someone will probably come along who’s been using this stuff for a long time and say “Well, duh!”.
I know how to do this for a tile based on an attribute that said what the thermostat was currently doing (heating, cooling, idle) but I don’t know how you’d display the temperature within that tile as you’re not within the correct context.
I have a modified CT100 handler that I’m using that changes the multiAttribute tile color based on an attribute value. It’s not exactly what you’re looking for, but it might be a starting point. Try something like this:
That’s how you would need to do a color gradient. I’m not sure if it can be adapted into something more dynamic like what you’re suggesting, but maybe if you get creative with your use of attributes…
thanks for your input.
Unfortunately I cannot change the color depending on the value. I had originally a similar code in place but I only want to be able to visually understand is the thermostat is on.
Not sure if you have already picked this up, but for completeness (and others searching the forums for answers) I think this issue is now resolved in the documentation.