Skip to content

Commit

Permalink
Update ultra-vehicle-card.js
Browse files Browse the repository at this point in the history
  • Loading branch information
WJDDesigns committed Aug 11, 2024
1 parent d4132c5 commit 092b175
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions ultra-vehicle-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UltraVehicleCardEditor } from "./ultra-vehicle-card-editor.js";
import { styles } from "./styles.js";


const version = "V1.2.0";
const version = "V1.2.1";


class UltraVehicleCard extends LitElement {
Expand Down Expand Up @@ -143,27 +143,27 @@ _renderEVInfo() {
`;
}

_isCharging(chargingStatusEntity) {
if (!chargingStatusEntity) return false;

const state = chargingStatusEntity.state.toLowerCase();
const entityId = chargingStatusEntity.entity_id.toLowerCase();

// Special handling for 'none_charging' entities
if (entityId.includes('none_charging')) {
return state === 'off'; // 'off' means it IS charging for this entity
}

// Handle boolean entities
if (chargingStatusEntity.attributes.device_class === 'battery_charging' || ['on', 'off'].includes(state)) {
return state === 'on';
_isCharging(chargingStatusEntity) {
if (!chargingStatusEntity) return false;

const state = chargingStatusEntity.state.toLowerCase();
const entityId = chargingStatusEntity.entity_id.toLowerCase();

// Special handling for 'none_charging' entities
if (entityId.includes('none_charging')) {
return state === 'on'; // 'on' means charging for this specific entity
}

// Handle boolean entities
if (chargingStatusEntity.attributes.device_class === 'battery_charging' || ['on', 'off'].includes(state)) {
return state === 'on';
}

// Handle string-based entities
const chargingStates = ['charging', 'in_charging', 'charge_start', 'in_progress', 'active', 'connected'];
return chargingStates.includes(state);
}

// Handle string-based entities
const chargingStates = ['charging', 'in_charging', 'charge_start', 'in_progress', 'active', 'connected'];
return chargingStates.includes(state);
}


_formatBinarySensorState(state, attributes) {
if (state === 'on') {
Expand Down Expand Up @@ -442,7 +442,6 @@ _renderInfoLine() {

_renderIconItem(entityId) {
if (!this.hass || !this.hass.states || !this.hass.states[entityId]) {
console.warn(`Entity ${entityId} not found. Skipping icon rendering.`);
return html``;
}

Expand Down

0 comments on commit 092b175

Please sign in to comment.