Created
February 17, 2017 19:14
-
-
Save sdague/fe1015ea4e6f3b5d3ed707b3aa5d1a88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../../../bower_components/polymer/polymer.html"> | |
<link rel="import" href="../../../bower_components/iron-icon/iron-icon.html"> | |
<dom-module id="ha-state-icon"> | |
<template> | |
<iron-icon icon="[[computeIcon(stateObj)]]"></iron-icon> | |
</template> | |
</dom-module> | |
<script> | |
Polymer({ | |
is: 'ha-state-icon', | |
properties: { | |
stateObj: { | |
type: Object, | |
observer: 'computeRotation', | |
}, | |
}, | |
computeIcon: function (stateObj) { | |
return window.hassUtil.stateIcon(stateObj); | |
}, | |
computeRotation: function (stateObj) { | |
var units = stateObj.attributes.unit_of_measurement; | |
if (units === '°') { | |
var deg = Number(stateObj.state) % 360; | |
this.children[0].style.transform = 'rotate(' + deg + 'deg)'; | |
} | |
console.dir(stateObj); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment