1
1
/*
2
2
*
3
- * Card : flex-horseshoe-card.js
3
+ * Card : flex-horseshoe-card.js
4
4
* Project : Home Assistant
5
5
* Repository: https://github.com/AmoebeLabs/
6
6
*
@@ -34,6 +34,7 @@ const TICKMARKS_RADIUS_SIZE = 0.43 * SVG_VIEW_BOX;
34
34
const HORSESHOE_PATH_LENGTH = 2 * 260 / 360 * Math . PI * HORSESHOE_RADIUS_SIZE ;
35
35
36
36
const DEFAULT_SHOW = {
37
+ horseshoe : true ,
37
38
scale_tickmarks : false ,
38
39
horseshoe_style : 'fixed' ,
39
40
}
@@ -629,7 +630,7 @@ class FlexHorseshoeCard extends LitElement {
629
630
.card--filter-none {
630
631
}
631
632
632
- # horseshoe__svg__group {
633
+ . horseshoe__svg__group {
633
634
transform: translateY(15%);
634
635
}
635
636
@@ -762,7 +763,6 @@ class FlexHorseshoeCard extends LitElement {
762
763
this . color0 = stroke ;
763
764
this . color1 = stroke ;
764
765
this . color1_offset = '0%' ;
765
-
766
766
}
767
767
else if ( strokeStyle == 'lineargradient' ) {
768
768
// This has taken a lot of time to get a satisfying result, and it appeared much simpler than anticipated.
@@ -787,9 +787,8 @@ class FlexHorseshoeCard extends LitElement {
787
787
if ( this . config . animations ) Object . keys ( this . config . animations ) . map ( animation => {
788
788
const entityIndex = animation . substr ( Number ( animation . indexOf ( '.' ) + 1 ) ) ;
789
789
this . config . animations [ animation ] . map ( item => {
790
-
791
790
// if animation state not equals sensor state, return... Nothing to animate for this state...
792
- if ( ! ( this . entities [ entityIndex ] . state === item . state ) ) return ;
791
+ if ( this . entities [ entityIndex ] . state . toLowerCase ( ) != item . state . toLowerCase ( ) ) return ;
793
792
794
793
if ( item . vlines ) {
795
794
item . vlines . map ( item2 => {
@@ -1087,8 +1086,10 @@ class FlexHorseshoeCard extends LitElement {
1087
1086
1088
1087
_renderHorseShoe ( ) {
1089
1088
1089
+ if ( ! this . config . show . horseshoe ) return ;
1090
+
1090
1091
return svg `
1091
- <g id="horseshoe__svg__group">
1092
+ <g id="horseshoe__svg__group" class="horseshoe__svg__group" >
1092
1093
<circle id="horseshoe__scale" class="horseshoe__scale" cx="50%" cy="50%" r="45%"
1093
1094
fill="${ this . config . fill || 'rgba(0, 0, 0, 0)' } "
1094
1095
stroke="${ this . config . horseshoe_scale . color || '#000000' } "
@@ -1287,7 +1288,7 @@ class FlexHorseshoeCard extends LitElement {
1287
1288
1288
1289
let uomStyle = { ...configStyle , ...UOM_STYLES , ...fsuomStr } ;
1289
1290
const uomStyleStr = JSON . stringify ( uomStyle ) . slice ( 1 , - 1 ) . replace ( / " / g, "" ) . replace ( / , / g, "" ) ;
1290
-
1291
+
1291
1292
const uom = this . _buildUom ( this . entities [ item . entity_index ] , this . config . entities [ item . entity_index ] ) ;
1292
1293
1293
1294
const state = ( this . config . entities [ item . entity_index ] . attribute &&
@@ -1652,7 +1653,6 @@ class FlexHorseshoeCard extends LitElement {
1652
1653
1653
1654
handlePopup ( e , entity ) {
1654
1655
e . stopPropagation ( ) ;
1655
- // console.log('handlePopup', e, entity);
1656
1656
1657
1657
this . _handleClick ( this , this . _hass , this . config ,
1658
1658
this . config . entities [ this . config . entities . findIndex (
@@ -1731,7 +1731,6 @@ class FlexHorseshoeCard extends LitElement {
1731
1731
*/
1732
1732
1733
1733
_buildState ( inState , entityConfig ) {
1734
- // console.log('buildstate', inState, entityConfig);
1735
1734
if ( isNaN ( inState ) )
1736
1735
return inState ;
1737
1736
@@ -1935,4 +1934,4 @@ class FlexHorseshoeCard extends LitElement {
1935
1934
}
1936
1935
}
1937
1936
1938
- customElements . define ( 'flex-horseshoe-card' , FlexHorseshoeCard ) ;
1937
+ customElements . define ( 'flex-horseshoe-card' , FlexHorseshoeCard ) ;
0 commit comments