Skip to content

Commit

Permalink
Merge pull request #11 from tomvanswam/dev
Browse files Browse the repository at this point in the history
Fix issue #10
  • Loading branch information
tomvanswam committed Aug 11, 2020
2 parents ddebe76 + a799747 commit 3110695
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ input_number:
entity:
name: Entity
initial: 30
min: 0
min: -359.9
max: 359.9
step: 0.1
step: 1
unit_of_measurement: °
icon: mdi:compass
secondary_entity:
Expand Down
4 changes: 2 additions & 2 deletions dist/compass-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ found at http://polymer.github.io/PATENTS.txt
left: calc((100% - 16px) / 2);
z-index: 99;
}
`;var Ne={version:"Version",description:"Show a compass with an indicator in the direction of the entity's value",invalid_configuration:"Invalid configuration",no_entity:"Entity not configured",offset_not_a_number:"Direction offset is not a number",invalid:"invalid"},Pe={common:Ne},Ce={version:"Versie",description:"Toon een kompas met een pijl wijzend naar de waarde van de entity",invalid_configuration:"Foutieve configuratie",no_entity:"Entity niet geconfigureerd",offset_not_a_number:"Direction offset is geen nummer",invalid:"ongeldig"},Me={common:Ce};const Ee={en:Object.freeze({__proto__:null,common:Ne,default:Pe}),nl:Object.freeze({__proto__:null,common:Ce,default:Me})};function ke(e,t="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=e.split(".").reduce((e,t)=>e[t],Ee[n])}catch(t){s=e.split(".").reduce((e,t)=>e[t],Ee.en)}return void 0===s&&(s=e.split(".").reduce((e,t)=>e[t],Ee.en)),""!==t&&""!==i&&(s=s.replace(t,i)),s}const Te="mdi:compass",Ae={N:0,NNE:22.5,NE:45,ENE:67.5,E:90,ESE:112.5,SE:135,SSE:157.5,S:180,SSW:202.5,SW:225,WSW:247.5,W:270,WNW:292.5,NW:315,NNW:337.5},Ve=Object.keys(Ae),Oe=ke("common.invalid");var De;console.info(`%c COMPASS-CARD \n%c ${ke("common.version")} 0.0.4 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"compass-card",name:"Compass Card",preview:!0,description:ke("common.description")});let ze=De=class extends te{static async getConfigElement(){return document.createElement("compass-card-editor")}static getStubConfig(){return{entity:"",secondary_entity:"",direction_offset:0,name:"Compass Card"}}setConfig(e){if(!e)throw new Error(ke("common.invalid_configuration"));e.test_gui&&function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null}().setEditMode(!0),this._config=Object.assign({},e)}shouldUpdate(e){if(e.has("_config"))return!0;if(this._config.entity){const t=e.get("hass");if(t&&t.states[this._config.entity]!==this.hass.states[this._config.entity])return!0}if(this._config.secondary_entity){const t=e.get("hass");if(t&&t.states[this._config.secondary_entity]!==this.hass.states[this._config.secondary_entity])return!0}return!1}render(){if(!this._config||!this.hass)return $``;let e=0;Number.isNaN(Number(this._config.direction_offset))||(e=+this._config.direction_offset<0?+this._config.direction_offset+360*(Math.abs(Math.ceil(+this._config.direction_offset/360))+1):+this._config.direction_offset);const t=this.hass.states[this._config.entity],i=this._config.secondary_entity?this.hass.states[this._config.secondary_entity]:void 0,n=t?t.attributes.friendly_name:this._config.entity;return $`
`;var Ne={version:"Version",description:"Show a compass with an indicator in the direction of the entity's value",invalid_configuration:"Invalid configuration",no_entity:"Entity not configured",offset_not_a_number:"Direction offset is not a number",invalid:"invalid"},Pe={common:Ne},Ce={version:"Versie",description:"Toon een kompas met een pijl wijzend naar de waarde van de entity",invalid_configuration:"Foutieve configuratie",no_entity:"Entity niet geconfigureerd",offset_not_a_number:"Direction offset is geen nummer",invalid:"ongeldig"},Me={common:Ce};const Ee={en:Object.freeze({__proto__:null,common:Ne,default:Pe}),nl:Object.freeze({__proto__:null,common:Ce,default:Me})};function ke(e,t="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=e.split(".").reduce((e,t)=>e[t],Ee[n])}catch(t){s=e.split(".").reduce((e,t)=>e[t],Ee.en)}return void 0===s&&(s=e.split(".").reduce((e,t)=>e[t],Ee.en)),""!==t&&""!==i&&(s=s.replace(t,i)),s}const Te="mdi:compass",Ae={N:0,NNE:22.5,NE:45,ENE:67.5,E:90,ESE:112.5,SE:135,SSE:157.5,S:180,SSW:202.5,SW:225,WSW:247.5,W:270,WNW:292.5,NW:315,NNW:337.5},Ve=Object.keys(Ae),Oe=ke("common.invalid");var De;console.info(`%c COMPASS-CARD \n%c ${ke("common.version")} 0.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"compass-card",name:"Compass Card",preview:!0,description:ke("common.description")});let ze=De=class extends te{static async getConfigElement(){return document.createElement("compass-card-editor")}static getStubConfig(){return{entity:"",secondary_entity:"",direction_offset:0,name:"Compass Card"}}setConfig(e){if(!e)throw new Error(ke("common.invalid_configuration"));e.test_gui&&function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null}().setEditMode(!0),this._config=Object.assign({},e)}shouldUpdate(e){if(e.has("_config"))return!0;if(this._config.entity){const t=e.get("hass");if(t&&t.states[this._config.entity]!==this.hass.states[this._config.entity])return!0}if(this._config.secondary_entity){const t=e.get("hass");if(t&&t.states[this._config.secondary_entity]!==this.hass.states[this._config.secondary_entity])return!0}return!1}render(){if(!this._config||!this.hass)return $``;let e=0;Number.isNaN(Number(this._config.direction_offset))||(e=+this._config.direction_offset<0?+this._config.direction_offset+360*(Math.abs(Math.ceil(+this._config.direction_offset/360))+1):+this._config.direction_offset);const t=this.hass.states[this._config.entity],i=this._config.secondary_entity?this.hass.states[this._config.secondary_entity]:void 0,n=t?t.attributes.friendly_name:this._config.entity;return $`
<ha-card tabindex="0" aria-label=${"Compass: "+n} class="flex" style="font-size: 14px;">
${this.renderHeader(t)}${this.renderCompass(t,i,e)}
</ha-card>
Expand Down Expand Up @@ -782,4 +782,4 @@ found at http://polymer.github.io/PATENTS.txt
<div class="name flex">
<span class="ellipsis">${this.computeName()}</span>
</div>
`}getCardSize(){return 4}computeName(){if(this._config.name&&this._config.name.trim().length>0)return this._config.name}computeIcon(e){return e&&e.attributes.icon?e.attributes.icon:Te}static get styles(){return xe}static get_degrees(e){return Ae[e]?Ae[e]:0}static get_compass_point(e){let t=Math.round((e+11.25)%360/22.5);return t-=1,t<0&&(t=0),Ve[t]}};e([Z()],ze.prototype,"hass",void 0),e([Z()],ze.prototype,"_config",void 0),ze=De=e([B("compass-card")],ze);export{ze as CompassCard};
`}getCardSize(){return 4}computeName(){if(this._config.name&&this._config.name.trim().length>0)return this._config.name}computeIcon(e){return e&&e.attributes.icon?e.attributes.icon:Te}static get styles(){return xe}static get_degrees(e){return Ae[e]?Ae[e]:0}static get_compass_point(e){const t=e<0?e+360*(Math.abs(Math.ceil(e/360))+1):e,i=Math.round(t%360/22.5);return i>15?Ve[0]:Ve[i]}};e([Z()],ze.prototype,"hass",void 0),e([Z()],ze.prototype,"_config",void 0),ze=De=e([B("compass-card")],ze);export{ze as CompassCard};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "compass-card",
"version": "0.0.4",
"version": "0.0.5",
"description": "Lovelace compass-card",
"keywords": [
"home-assistant",
Expand Down
8 changes: 4 additions & 4 deletions src/compass-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ export class CompassCard extends LitElement {
}

static get_compass_point(degrees: number): string {
let index = Math.round(((degrees + 11.25) % 360) / 22.5);
index = index - 1;
if (index < 0) {
index = 0;
const positiveDegrees = degrees < 0 ? degrees + (Math.abs(Math.ceil(degrees / 360)) + 1) * 360 : degrees;
const index = Math.round((positiveDegrees % 360) / 22.5);
if (index > 15) {
return COMPASS_ABBREVIATIONS[0];
}
return COMPASS_ABBREVIATIONS[index];
}
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { localize } from './localize/localize';

export const CARD_VERSION = '0.0.4';
export const CARD_VERSION = '0.0.5';
export const FONT_SIZE = 14;
export const FONT_SIZE_HEADER = 14;
export const ICONS = {
Expand Down

0 comments on commit 3110695

Please sign in to comment.