diff --git a/package-lock.json b/package-lock.json index 11f7ec1..89751bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "eviqo-monorepo", - "version": "1.0.0", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "eviqo-monorepo", - "version": "1.0.0", + "version": "1.0.4", "license": "MIT", "workspaces": [ "packages/*" @@ -6396,7 +6396,7 @@ } }, "packages/eviqo-client-api": { - "version": "1.0.0", + "version": "1.0.4", "license": "MIT", "dependencies": { "dotenv": "^16.3.0", @@ -6422,7 +6422,7 @@ } }, "packages/eviqo-mqtt": { - "version": "1.0.0", + "version": "1.0.4", "license": "MIT", "dependencies": { "dotenv": "^16.3.0", diff --git a/packages/eviqo-mqtt/src/gateway.ts b/packages/eviqo-mqtt/src/gateway.ts index 7604712..855158c 100644 --- a/packages/eviqo-mqtt/src/gateway.ts +++ b/packages/eviqo-mqtt/src/gateway.ts @@ -24,6 +24,11 @@ import { getTopicId, } from './ha-discovery'; +/** + * Session entity names - these are only updated during charging + */ +const SESSION_ENTITIES = new Set(['Session duration', 'Session power', 'Session cost']); + /** * Value transformers for specific widgets * Maps widget name to a function that transforms the raw value @@ -404,6 +409,15 @@ export class EviqoMqttGateway extends EventEmitter { // Only publish widgets that have a mapping defined if (!isInWidgetMappings && !controlSettings) return; + // Session entities are only updated during charging + if (SESSION_ENTITIES.has(widgetName)) { + const currentStatus = this.deviceStatus.get(String(deviceId)); + if (currentStatus !== '2') { + logger.debug(`Skipping ${widgetName} update for device ${deviceId}: not charging (status=${currentStatus})`); + return; + } + } + // Apply value transformer if one exists for this widget const transformer = VALUE_TRANSFORMERS[widgetName]; const publishValue = transformer ? transformer(rawValue) : rawValue;