Skip to content

Instantly share code, notes, and snippets.

@sdague
Created February 17, 2017 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdague/fe1015ea4e6f3b5d3ed707b3aa5d1a88 to your computer and use it in GitHub Desktop.
Save sdague/fe1015ea4e6f3b5d3ed707b3aa5d1a88 to your computer and use it in GitHub Desktop.
<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