homebridge-evn-smartmeter 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { EVNSmartmeterPlatform } from '../platform';
3
3
  import { EVNMQTTClient } from '../mqtt/mqttClient';
4
4
  /**
5
5
  * Current Monitor Accessory
6
- * Displays current and power factor as humidity sensors (% = Ampere or Power Factor)
6
+ * Displays current and power factor as temperature sensors (°C = Ampere or Power Factor)
7
7
  */
8
8
  export declare class CurrentMonitorAccessory {
9
9
  private platform;
@@ -13,7 +13,7 @@ export declare class CurrentMonitorAccessory {
13
13
  private cachedValues;
14
14
  constructor(platform: EVNSmartmeterPlatform, accessory: PlatformAccessory, mqttClient: EVNMQTTClient);
15
15
  /**
16
- * Create a humidity sensor for a current/power factor measurement
16
+ * Create a temperature sensor for a current/power factor measurement
17
17
  */
18
18
  private createSensor;
19
19
  /**
@@ -5,7 +5,7 @@ const topicParser_1 = require("../mqtt/topicParser");
5
5
  const types_1 = require("../config/types");
6
6
  /**
7
7
  * Current Monitor Accessory
8
- * Displays current and power factor as humidity sensors (% = Ampere or Power Factor)
8
+ * Displays current and power factor as temperature sensors (°C = Ampere or Power Factor)
9
9
  */
10
10
  class CurrentMonitorAccessory {
11
11
  constructor(platform, accessory, mqttClient) {
@@ -20,7 +20,7 @@ class CurrentMonitorAccessory {
20
20
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'EVN')
21
21
  .setCharacteristic(this.platform.Characteristic.Model, 'Kaifa Smartmeter - Current Monitor')
22
22
  .setCharacteristic(this.platform.Characteristic.SerialNumber, 'CUR-001');
23
- // Create humidity sensors for current and power factor measurements
23
+ // Create temperature sensors for current and power factor measurements
24
24
  this.createSensor('Current L1 (A)', types_1.MeasurementType.StromL1);
25
25
  this.createSensor('Current L2 (A)', types_1.MeasurementType.StromL2);
26
26
  this.createSensor('Current L3 (A)', types_1.MeasurementType.StromL3);
@@ -29,13 +29,13 @@ class CurrentMonitorAccessory {
29
29
  this.mqttClient.on('measurement', this.handleMeasurement.bind(this));
30
30
  }
31
31
  /**
32
- * Create a humidity sensor for a current/power factor measurement
32
+ * Create a temperature sensor for a current/power factor measurement
33
33
  */
34
34
  createSensor(name, type) {
35
35
  const service = this.accessory.getService(name) ||
36
- this.accessory.addService(this.platform.Service.HumiditySensor, name, type);
36
+ this.accessory.addService(this.platform.Service.TemperatureSensor, name, type);
37
37
  service
38
- .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
38
+ .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
39
39
  .setProps({
40
40
  minValue: 0,
41
41
  maxValue: 100,
@@ -81,7 +81,7 @@ class CurrentMonitorAccessory {
81
81
  const service = this.services.find((s) => s.subtype === measurementType);
82
82
  if (service) {
83
83
  const displayValue = this.getValue(measurementType);
84
- service.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).updateValue(displayValue);
84
+ service.getCharacteristic(this.platform.Characteristic.CurrentTemperature).updateValue(displayValue);
85
85
  }
86
86
  }
87
87
  }
@@ -3,7 +3,7 @@ import { EVNSmartmeterPlatform } from '../platform';
3
3
  import { EVNMQTTClient } from '../mqtt/mqttClient';
4
4
  /**
5
5
  * Energy Meter Accessory
6
- * Displays cumulative energy values as light sensors (Lux = Wh)
6
+ * Displays cumulative energy values as light sensors (Lux = kWh)
7
7
  */
8
8
  export declare class EnergyMeterAccessory {
9
9
  private platform;
@@ -18,6 +18,7 @@ export declare class EnergyMeterAccessory {
18
18
  private createSensor;
19
19
  /**
20
20
  * Get the current value for a measurement type
21
+ * Converts Wh to kWh by dividing by 1000 and rounds to whole number for 5-digit display
21
22
  */
22
23
  private getValue;
23
24
  /**
@@ -5,7 +5,7 @@ const topicParser_1 = require("../mqtt/topicParser");
5
5
  const types_1 = require("../config/types");
6
6
  /**
7
7
  * Energy Meter Accessory
8
- * Displays cumulative energy values as light sensors (Lux = Wh)
8
+ * Displays cumulative energy values as light sensors (Lux = kWh)
9
9
  */
10
10
  class EnergyMeterAccessory {
11
11
  constructor(platform, accessory, mqttClient) {
@@ -21,8 +21,8 @@ class EnergyMeterAccessory {
21
21
  .setCharacteristic(this.platform.Characteristic.Model, 'Kaifa Smartmeter - Energy Meter')
22
22
  .setCharacteristic(this.platform.Characteristic.SerialNumber, 'ENR-001');
23
23
  // Create light sensors for energy measurements
24
- this.createSensor('Energy Consumed (Wh)', types_1.MeasurementType.WirkenergieP);
25
- this.createSensor('Energy Fed (Wh)', types_1.MeasurementType.WirkenergieN);
24
+ this.createSensor('Energy Consumed (kWh)', types_1.MeasurementType.WirkenergieP);
25
+ this.createSensor('Energy Fed (kWh)', types_1.MeasurementType.WirkenergieN);
26
26
  // Subscribe to MQTT measurements
27
27
  this.mqttClient.on('measurement', this.handleMeasurement.bind(this));
28
28
  }
@@ -44,11 +44,15 @@ class EnergyMeterAccessory {
44
44
  }
45
45
  /**
46
46
  * Get the current value for a measurement type
47
+ * Converts Wh to kWh by dividing by 1000 and rounds to whole number for 5-digit display
47
48
  */
48
49
  getValue(type) {
49
- const value = this.cachedValues.get(type) ?? 0.0001;
50
+ const whValue = this.cachedValues.get(type) ?? 0.0001;
51
+ // Convert Wh to kWh (divide by 1000) and round to whole number
52
+ // Example: 20885211 Wh → 20885.211 kWh → 20885
53
+ const kWhValue = Math.round(whValue / 1000);
50
54
  // LightSensor requires value > 0, use 0.0001 as minimum
51
- return Math.max(0.0001, value);
55
+ return Math.max(0.0001, kWhValue);
52
56
  }
53
57
  /**
54
58
  * Handle incoming MQTT measurement
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "EVN Smartmeter",
3
3
  "name": "homebridge-evn-smartmeter",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "Homebridge plugin for EVN Smartmeter MQTT data integration",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {