@@ -431,6 +431,10 @@ class CompactPowerCard extends (window.LitElement ||
431431 label : "Power Threshold (in watts)" ,
432432 selector : { number : { step : 1 , } } ,
433433 } ,
434+ subtract_from_home : {
435+ label : "Subtract from Home?" ,
436+ selector : { boolean : { } } ,
437+ } ,
434438 force_hide_under_threshold : {
435439 label : "Force hide device when under Threshold?" ,
436440 selector : { boolean : { } } ,
@@ -2457,10 +2461,17 @@ class CompactPowerCard extends (window.LitElement ||
24572461 const { sources : normalizedSources , subtractFromHome } = this . _getSourcesConfig ( ) ;
24582462
24592463 let auxUsage = 0 ;
2464+ let hasPerDeviceInclude = false ;
24602465 for ( const src of normalizedSources ) {
24612466 const entity = src . entity || null ;
24622467 const attribute = src . attribute || null ;
24632468 if ( ! this . _isPowerDevice ( entity ) ) continue ;
2469+ const hasPerDeviceSubtract = Object . prototype . hasOwnProperty . call ( src , "subtract_from_home" ) ;
2470+ const includeInHome = hasPerDeviceSubtract
2471+ ? this . _coerceBoolean ( src . subtract_from_home , subtractFromHome )
2472+ : subtractFromHome ;
2473+ if ( ! includeInHome ) continue ;
2474+ if ( hasPerDeviceSubtract && includeInHome ) hasPerDeviceInclude = true ;
24642475 const srcUnit =
24652476 this . hass ?. states ?. [ entity ] ?. attributes ?. unit_of_measurement ||
24662477 "" ;
@@ -2474,14 +2485,15 @@ class CompactPowerCard extends (window.LitElement ||
24742485 const hasHomeEntity = Boolean ( homeCfg ?. entity ) ;
24752486 const baseHome = Number . isFinite ( homeRawW ) ? homeRawW : 0 ;
24762487 const inferredBase = pv + battery - grid ;
2488+ const allowSubtract = subtractFromHome || hasPerDeviceInclude ;
24772489 let homeEffectiveDisplay = 0 ;
24782490 let homeEffectiveFlow = 0 ;
24792491 if ( hasHomeEntity ) {
2480- const adjustedHome = subtractFromHome ? baseHome - auxUsage : baseHome ;
2492+ const adjustedHome = allowSubtract ? baseHome - auxUsage : baseHome ;
24812493 homeEffectiveDisplay = Math . max ( adjustedHome , 0 ) ;
24822494 homeEffectiveFlow = Math . max ( inferredBase , 0 ) ;
24832495 } else {
2484- const inferredDisplay = Math . max ( subtractFromHome ? inferredBase - auxUsage : inferredBase , 0 ) ;
2496+ const inferredDisplay = Math . max ( allowSubtract ? inferredBase - auxUsage : inferredBase , 0 ) ;
24852497 homeEffectiveDisplay = inferredDisplay ;
24862498 homeEffectiveFlow = Math . max ( inferredBase , 0 ) ;
24872499 }
0 commit comments