homebridge-evn-smartmeter 1.0.0

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.
@@ -0,0 +1,222 @@
1
+ # Homebridge EVN Smartmeter
2
+
3
+ [![npm version](https://badge.fury.io/js/homebridge-evn-smartmeter.svg)](https://badge.fury.io/js/homebridge-evn-smartmeter)
4
+
5
+ Homebridge plugin for integrating EVN Smartmeter (Kaifa) data into Apple HomeKit via MQTT.
6
+
7
+ ## Features
8
+
9
+ - **Real-time monitoring** of 12 smartmeter measurements
10
+ - **4 HomeKit accessories** grouped by function:
11
+ - Power Monitor (Total Power, Power Draw, Power Feed-in)
12
+ - Energy Meter (Energy Consumed, Energy Fed)
13
+ - Voltage Monitor (Voltage L1, L2, L3)
14
+ - Current Monitor (Current L1, L2, L3, Power Factor)
15
+ - **Auto-reconnect** for reliable MQTT connection
16
+ - **Easy configuration** via Homebridge Config UI
17
+ - **HomeKit Automations** support (e.g., trigger when power > threshold)
18
+
19
+ ## Requirements
20
+
21
+ - **Homebridge** v1.6.0 or later
22
+ - **Node.js** v18.0.0 or later
23
+ - **MQTT Broker** (e.g., Mosquitto)
24
+ - **EVN_Smartmeter daemon** running and publishing to MQTT
25
+
26
+ ## Installation
27
+
28
+ ### Via Homebridge Config UI X (Recommended)
29
+
30
+ 1. Search for "EVN Smartmeter" in the Plugins tab
31
+ 2. Click Install
32
+ 3. Configure the plugin via the UI
33
+ 4. Restart Homebridge
34
+
35
+ ### Via npm
36
+
37
+ ```bash
38
+ npm install -g homebridge-evn-smartmeter
39
+ ```
40
+
41
+ ## Configuration
42
+
43
+ Configure the plugin via Homebridge Config UI X or manually edit your `config.json`:
44
+
45
+ ```json
46
+ {
47
+ "platforms": [
48
+ {
49
+ "platform": "EVNSmartmeter",
50
+ "name": "EVN Smartmeter",
51
+ "mqtt": {
52
+ "broker": "172.16.0.140",
53
+ "port": 1883,
54
+ "username": "",
55
+ "password": "",
56
+ "topic_prefix": "Smartmeter"
57
+ },
58
+ "display": {
59
+ "showPowerMonitor": true,
60
+ "showEnergyMeter": true,
61
+ "showVoltageMonitor": true,
62
+ "showCurrentMonitor": true
63
+ }
64
+ }
65
+ ]
66
+ }
67
+ ```
68
+
69
+ ### Configuration Options
70
+
71
+ | Option | Required | Default | Description |
72
+ |--------|----------|---------|-------------|
73
+ | `platform` | Yes | `EVNSmartmeter` | Must be "EVNSmartmeter" |
74
+ | `name` | No | `EVN Smartmeter` | Platform name |
75
+ | `mqtt.broker` | Yes | - | MQTT broker IP address or hostname |
76
+ | `mqtt.port` | No | `1883` | MQTT broker port |
77
+ | `mqtt.username` | No | - | MQTT username (if authentication required) |
78
+ | `mqtt.password` | No | - | MQTT password (if authentication required) |
79
+ | `mqtt.topic_prefix` | No | `Smartmeter` | MQTT topic prefix |
80
+ | `display.showPowerMonitor` | No | `true` | Show Power Monitor accessory |
81
+ | `display.showEnergyMeter` | No | `true` | Show Energy Meter accessory |
82
+ | `display.showVoltageMonitor` | No | `true` | Show Voltage Monitor accessory |
83
+ | `display.showCurrentMonitor` | No | `true` | Show Current Monitor accessory |
84
+
85
+ ## HomeKit Service Mapping
86
+
87
+ Since HomeKit doesn't have native "Power" or "Energy" services, this plugin uses available service types with appropriate value mappings:
88
+
89
+ ### Power Monitor (Temperature Sensors)
90
+ | Measurement | MQTT Topic | Displays As | Unit | Range |
91
+ |-------------|------------|-------------|------|-------|
92
+ | Total Power | `Smartmeter/Momentanleistung` | Temperature (°C) | Watt | -10000 to +10000 W |
93
+ | Power Draw | `Smartmeter/MomentanleistungP` | Temperature (°C) | Watt | 0 to +10000 W |
94
+ | Power Feed-in | `Smartmeter/MomentanleistungN` | Temperature (°C) | Watt | 0 to +10000 W |
95
+
96
+ ### Energy Meter (Light Sensors)
97
+ | Measurement | MQTT Topic | Displays As | Unit | Range |
98
+ |-------------|------------|-------------|------|-------|
99
+ | Energy Consumed | `Smartmeter/WirkenergieP` | Light Level (Lux) | Wh | 0-100000 Wh |
100
+ | Energy Fed | `Smartmeter/WirkenergieN` | Light Level (Lux) | Wh | 0-100000 Wh |
101
+
102
+ ### Voltage Monitor (Temperature Sensors)
103
+ | Measurement | MQTT Topic | Displays As | Unit | Range |
104
+ |-------------|------------|-------------|------|-------|
105
+ | Voltage L1 | `Smartmeter/SpannungL1` | Temperature (°C) | Volt | 0-300 V |
106
+ | Voltage L2 | `Smartmeter/SpannungL2` | Temperature (°C) | Volt | 0-300 V |
107
+ | Voltage L3 | `Smartmeter/SpannungL3` | Temperature (°C) | Volt | 0-300 V |
108
+
109
+ ### Current Monitor (Humidity Sensors)
110
+ | Measurement | MQTT Topic | Displays As | Unit | Range |
111
+ |-------------|------------|-------------|------|-------|
112
+ | Current L1 | `Smartmeter/StromL1` | Humidity (%) | Ampere | 0-100 A |
113
+ | Current L2 | `Smartmeter/StromL2` | Humidity (%) | Ampere | 0-100 A |
114
+ | Current L3 | `Smartmeter/StromL3` | Humidity (%) | Ampere | 0-100 A |
115
+ | Power Factor | `Smartmeter/Leistungsfaktor` | Humidity (%) | Factor | 0-1 (as 0-100%) |
116
+
117
+ **Note:** While the values display as °C, Lux, or %, they represent Watts, Wh, Volts, and Amperes respectively. This mapping allows the plugin to work with HomeKit's native service types and enables use in automations.
118
+
119
+ ## Usage Examples
120
+
121
+ ### Reading Power Consumption
122
+ In the Home app, the "Total Power" sensor shows your current power consumption (or feed-in if negative/solar):
123
+ - **1500°C = 1500 Watt** consumption
124
+ - **-500°C = 500 Watt** feed-in (solar)
125
+
126
+ ### Creating Automations
127
+ 1. Open Home app → Automation
128
+ 2. Create automation: "When Total Power is above 3000°C"
129
+ 3. Add action: Send notification "High power consumption!"
130
+
131
+ ### Monitoring Energy Usage
132
+ The Energy Meter accessory shows cumulative values:
133
+ - **Energy Consumed**: Total kWh consumed (displayed as Lux)
134
+ - **Energy Fed**: Total kWh fed back to grid (displayed as Lux)
135
+
136
+ ## Troubleshooting
137
+
138
+ ### Plugin not connecting to MQTT
139
+
140
+ 1. Check MQTT broker is running:
141
+ ```bash
142
+ sudo systemctl status mosquitto
143
+ ```
144
+
145
+ 2. Test MQTT manually:
146
+ ```bash
147
+ mosquitto_sub -h 172.16.0.140 -t "Smartmeter/#" -v
148
+ ```
149
+
150
+ 3. Check Homebridge logs for connection errors:
151
+ ```bash
152
+ tail -f ~/.homebridge/homebridge.log
153
+ ```
154
+
155
+ 4. Verify broker IP and port in plugin configuration
156
+
157
+ ### Values not updating
158
+
159
+ 1. Ensure EVN_Smartmeter daemon is running and publishing
160
+ 2. Check topic prefix matches between daemon and plugin
161
+ 3. Test publishing manually:
162
+ ```bash
163
+ mosquitto_pub -h 172.16.0.140 -t "Smartmeter/Momentanleistung" -m "1500"
164
+ ```
165
+ 4. Check Homebridge logs for MQTT errors
166
+
167
+ ### Accessories show "No Response"
168
+
169
+ - MQTT connection is lost
170
+ - Plugin will automatically attempt to reconnect
171
+ - Check MQTT broker status
172
+ - Restart Homebridge if issue persists
173
+
174
+ ### Wrong values displayed
175
+
176
+ - Check topic prefix in configuration
177
+ - Verify EVN_Smartmeter is publishing numeric values (not JSON)
178
+ - Check Homebridge logs for parsing errors
179
+
180
+ ## Known Limitations
181
+
182
+ 1. **Service Type Mapping**: HomeKit displays Watts as °C, Wh as Lux, etc. This is a HomeKit limitation, not a bug.
183
+ 2. **Energy Counter Overflow**: Light sensors max out at 100,000. For very high cumulative values, readings may wrap or cap.
184
+ 3. **Negative Values**: Only Temperature sensors support negative values (important for solar feed-in).
185
+
186
+ ## Development
187
+
188
+ ### Building from Source
189
+
190
+ ```bash
191
+ git clone https://github.com/RaithChr/homebridge-evn-smartmeter.git
192
+ cd homebridge-evn-smartmeter
193
+ npm install
194
+ npm run build
195
+ ```
196
+
197
+ ### Local Testing
198
+
199
+ ```bash
200
+ npm link
201
+ ```
202
+
203
+ Then restart Homebridge to load the locally installed plugin.
204
+
205
+ ## Support
206
+
207
+ For issues, feature requests, or questions:
208
+ - **GitHub Issues**: https://github.com/RaithChr/homebridge-evn-smartmeter/issues
209
+ - **Homebridge Discord**: https://discord.gg/homebridge
210
+
211
+ ## Credits
212
+
213
+ - Based on [EVN_Smartmeter](https://github.com/yourusername/EVN_Smartmeter) Python daemon
214
+ - Compatible with EVN Kaifa smart meters
215
+
216
+ ## License
217
+
218
+ MIT License - see [LICENSE](LICENSE) file for details
219
+
220
+ ## Changelog
221
+
222
+ See [CHANGELOG.md](CHANGELOG.md) for version history and updates.
@@ -0,0 +1,118 @@
1
+ {
2
+ "pluginAlias": "EVNSmartmeter",
3
+ "pluginType": "platform",
4
+ "singular": true,
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "title": "Platform Name",
10
+ "type": "string",
11
+ "default": "EVN Smartmeter",
12
+ "required": false,
13
+ "description": "Name for this platform (optional)"
14
+ },
15
+ "mqtt": {
16
+ "title": "MQTT Configuration",
17
+ "type": "object",
18
+ "properties": {
19
+ "broker": {
20
+ "title": "MQTT Broker",
21
+ "type": "string",
22
+ "required": true,
23
+ "placeholder": "172.16.0.140",
24
+ "description": "IP address or hostname of your MQTT broker"
25
+ },
26
+ "port": {
27
+ "title": "MQTT Port",
28
+ "type": "integer",
29
+ "default": 1883,
30
+ "minimum": 1,
31
+ "maximum": 65535,
32
+ "description": "MQTT broker port (default: 1883)"
33
+ },
34
+ "username": {
35
+ "title": "Username",
36
+ "type": "string",
37
+ "required": false,
38
+ "description": "MQTT username (optional, leave empty if not required)"
39
+ },
40
+ "password": {
41
+ "title": "Password",
42
+ "type": "string",
43
+ "required": false,
44
+ "description": "MQTT password (optional, leave empty if not required)"
45
+ },
46
+ "topic_prefix": {
47
+ "title": "Topic Prefix",
48
+ "type": "string",
49
+ "default": "Smartmeter",
50
+ "required": false,
51
+ "placeholder": "Smartmeter",
52
+ "description": "MQTT topic prefix (e.g., 'Smartmeter' for topics like 'Smartmeter/Momentanleistung')"
53
+ }
54
+ },
55
+ "required": ["broker"]
56
+ },
57
+ "display": {
58
+ "title": "Display Options",
59
+ "type": "object",
60
+ "properties": {
61
+ "showPowerMonitor": {
62
+ "title": "Show Power Monitor",
63
+ "type": "boolean",
64
+ "default": true,
65
+ "description": "Show Power Monitor accessory (Total Power, Power Draw, Power Feed-in)"
66
+ },
67
+ "showEnergyMeter": {
68
+ "title": "Show Energy Meter",
69
+ "type": "boolean",
70
+ "default": true,
71
+ "description": "Show Energy Meter accessory (Energy Consumed, Energy Fed)"
72
+ },
73
+ "showVoltageMonitor": {
74
+ "title": "Show Voltage Monitor",
75
+ "type": "boolean",
76
+ "default": true,
77
+ "description": "Show Voltage Monitor accessory (Voltage L1, L2, L3)"
78
+ },
79
+ "showCurrentMonitor": {
80
+ "title": "Show Current Monitor",
81
+ "type": "boolean",
82
+ "default": true,
83
+ "description": "Show Current Monitor accessory (Current L1, L2, L3, Power Factor)"
84
+ }
85
+ }
86
+ }
87
+ },
88
+ "required": ["mqtt"]
89
+ },
90
+ "layout": [
91
+ {
92
+ "type": "fieldset",
93
+ "title": "MQTT Configuration",
94
+ "description": "Configure your MQTT broker connection settings",
95
+ "expandable": false,
96
+ "items": [
97
+ "mqtt.broker",
98
+ "mqtt.port",
99
+ "mqtt.username",
100
+ "mqtt.password",
101
+ "mqtt.topic_prefix"
102
+ ]
103
+ },
104
+ {
105
+ "type": "fieldset",
106
+ "title": "Display Options",
107
+ "description": "Choose which accessories to display in HomeKit",
108
+ "expandable": true,
109
+ "expanded": false,
110
+ "items": [
111
+ "display.showPowerMonitor",
112
+ "display.showEnergyMeter",
113
+ "display.showVoltageMonitor",
114
+ "display.showCurrentMonitor"
115
+ ]
116
+ }
117
+ ]
118
+ }