Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set icons for sensors that are in units of degrees #213

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/components/entity/ha-state-icon.html
Expand Up @@ -4,6 +4,11 @@

<dom-module id="ha-state-icon">
<template>
<style>
iron-icon {
transition: 1s ease-out;
}
</style>
<iron-icon icon="[[computeIcon(stateObj)]]"></iron-icon>
</template>
</dom-module>
Expand All @@ -15,11 +20,22 @@
properties: {
stateObj: {
type: Object,
observer: 'computeRotation',
},
},

computeIcon: function (stateObj) {
return window.hassUtil.stateIcon(stateObj);
},

computeRotation: function (stateObj) {
var units = stateObj.attributes.unit_of_measurement;
// TODO(sdague): we honestly probably want semantic meaning for
// sensors which we could select on, but use this as a shortcut.
if (units === '°') {
var deg = Number(stateObj.state) % 360;
this.children[0].style.transform = 'rotate(' + deg + 'deg)';
}
}
});
</script>
2 changes: 2 additions & 0 deletions src/util/hass-util.html
Expand Up @@ -373,6 +373,8 @@
if (unit && domain === 'sensor') {
if (unit === '°C' || unit === '°F') {
return 'mdi:thermometer';
} else if (unit === '°') {
return 'mdi:navigation';
} else if (unit === 'Mice') {
return 'mdi:mouse-variant';
}
Expand Down