ebaauw / homebridge-p1

Homebridge plugin for DSMR end-consumer (P1) interface
Apache License 2.0
53 stars 11 forks source link

Feature request: making the `Electricity Capacity` accessory more useful #72

Closed wimleers closed 1 year ago

wimleers commented 1 year ago

https://github.com/ebaauw/homebridge-p1/commit/ff35d99663a7d343db05dc4ca789985d657a16f4 implemented capacity tariff support. As promised in https://github.com/ebaauw/homebridge-p1/pull/69#issuecomment-1427784275, I've been testing and am now reporting back 😊

  1. The most important information is not yet exposed via Electricity Capacity: 1.4.0 (current window's average consumption), 1.6.0 (current month's consumption peak) and 98.1.0 (previous months' consumption peaks). I posted a detailed analysis + proposal at https://github.com/ebaauw/homebridge-p1/pull/69#issuecomment-1425648028 previously.
  2. No detailed logging for Electricity Capacity as already exists for Electricity? That'd be super valuable while refining this functionality! (Especially combined with #71.) If I'd be able to observe 1.4.0 in real-time in the log, that'd be very powerful.
  3. The Eve History support for Electricity Capacity is either wrong or misleading? 😅 ~Should I multiply the values by 6?~ I should, you wrote that previously at https://github.com/ebaauw/homebridge-p1/pull/69#issuecomment-1427035635! I agree that showing a line would be more helpful, perhaps as Air Pressure. I can confirm that the current result is useless: IMG_CEB6092DAA24-1
ebaauw commented 1 year ago
  1. 1.4.0 is exposed as Current Consumption on the Electricity Capacity accessory. 1.6.0 and 98.1.0 are parsed, but not yet exposed. If you set Log Level to 2, you should see debug messages for the parsed telegrams, where they are combined under avg_power_peaks.
  2. You should see messages in the log for this characteristic, when Log Level >= 1.
  3. Eve history for Total Consumption is very confusing; it took me several iterations to understand it and get the code right. The entries, as reported by the accessory, actually contain (average) Current Consumption since the previous entry. Current Consumption isn't consumption (in Wh) at all, but rather power (in W). The bar chart does show consumption, which is computed by the Eve app. In the hourly view, the graph shows a bar per 10 minutes. With an average power of 1000W, the consumption over 10 minutes = 166.67 Wh. So yes, if you want the (average) power, you need to multiply that value by 6. In the daily view, the graphs shows a bar per hour. Which an average power of 1000W, the consumption over an hour = 1000Wh. You can use the value directly, but you no longer have the capacity per 15 minutes.
    Hence my suggestion to expose 1.4.0 as Air Pressure, whose history would show as a line chart, without any power to consumption conversions. It would also eliminate the need for an extra accessory, as I can combine the Current Consumption and Air Pressure history in one accessory.

Note that there's a similar conversion for Gas and Water. The Total Consumption value is in m3 (but Eve displays kWh). The history entry values are "power" (in litres per hour), and the bar graphs shows consumption in litres (as Wh) or m3 (as kWh). I don't expose Current Consumption as the P1 only reports gas or water consumption every 5 minutes. I don't think seeing the average "power" (in litres per hour) over 5 minutes would bring any value, and it would add to the confusion.

ebaauw commented 1 year ago

Could you try beta v1.3.4-0?

This version no longer exposes a separate ElectricityCapacity accessory, but adds Air Pressure to the Electricity accessories, incl. history. The value is the peak capacity (from 1.4.0) in W, as reflected in the log, but, obviously not in Eve. Also includes the following changes:

wimleers commented 1 year ago

The value is the peak capacity (from 1.4.0) in W, as reflected in the log, but, obviously not in Eve.

Would it be possible to expose this as an additional characteristic?

Could you try beta v1.3.4-0?

Given a7bb3de's change to Eve history support … is it safe for me to update? What will the consequences be for the Eve app? Any special steps I need to take?

ebaauw commented 1 year ago

Would it be possible to expose this as an additional characteristic?

With exactly the same value?

is it safe for me to update? What will the consequences be for the Eve app? Any special steps I need to take?

Yes, each history entry includes info on which values it contains. The graph for Air Pressure will simply show no values for the entries created under a previous version, without a value for Air Pressure.

Only if you un-expose and re-expose an accessory, you might need to delete the history already downloaded by Eve. I still don't know how Eve accessories tell the Eve app that history has been re-initialised on factory reset.

wimleers commented 1 year ago

Did that. The reboot in action:

[2/26/2023, 1:32:45 PM] Registering platform 'homebridge-p1.P1'
[2/26/2023, 1:32:45 PM] [P1] Loaded homebridge-p1 v1.3.4-0 child bridge successfully
[2/26/2023, 1:32:45 PM] Loaded 4 cached accessories from cachedAccessories.0E981C41ADC8.
[2/26/2023, 1:32:45 PM] [P1] homebridge-p1 v1.3.4-0, node v18.14.0, homebridge v1.6.0, homebridge-lib v6.3.9-0
[2/26/2023, 1:32:45 PM] Homebridge v1.6.0 (HAP v0.11.0) (P1) is running on port 54199.
[2/26/2023, 1:32:45 PM] [P1] hardware: Mac mini (M1, 2020)
[2/26/2023, 1:32:45 PM] [P1] os: macOS Monterey 12.3.1 (21E258)
[2/26/2023, 1:32:45 PM] [P1] restored 4 accessories from cache
[2/26/2023, 1:32:47 PM] [P1] connected to 192.168.0.219:23
[2/26/2023, 1:32:47 PM] [P1] warning: latest version: homebridge-p1 v1.3.3
[2/26/2023, 1:32:47 PM] [P1] warning: ignoring invalid telegram
[2/26/2023, 1:32:48 PM] [P1] FLU5\253770234_A v5.0
[2/26/2023, 1:32:48 PM] [P1] Electricity: Name: set to "Electricity"
[2/26/2023, 1:32:48 PM] [P1] Electricity: Configured Name: set to "Electricity"
[2/26/2023, 1:32:48 PM] [P1] Electricity: On: set to false
[2/26/2023, 1:32:48 PM] [P1] Electricity: Air Pressure: set to 0 W
[2/26/2023, 1:32:48 PM] [P1] Electricity: Log Level: set to 2
[2/26/2023, 1:32:48 PM] [P1] Electricity: Total Consumption: set to 764.283 kWh
[2/26/2023, 1:32:48 PM] [P1] Electricity: Total Consumption Normal: set to 372.378 kWh
[2/26/2023, 1:32:48 PM] [P1] Electricity: Total Consumption Low: set to 391.905 kWh
[2/26/2023, 1:32:48 PM] [P1] Electricity: Tariff: set to "low"
[2/26/2023, 1:32:48 PM] [P1] Electricity: Current Consumption: set to 0 W
[2/26/2023, 1:32:48 PM] [P1] Electricity: Electric Current: set to 1.79 A
[2/26/2023, 1:32:48 PM] [P1] Electricity: Voltage: set to 242.3 V
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Name: set to "Electricity Delivered"
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Configured Name: set to "Electricity Delivered"
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: On: set to false
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Total Consumption: set to 380.298 kWh
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Total Consumption Normal: set to 275.588 kWh
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Total Consumption Low: set to 104.71 kWh
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Tariff: set to "low"
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: Current Consumption: set to 148 W
[2/26/2023, 1:32:48 PM] [P1] Gas: Name: set to "Gas"
[2/26/2023, 1:32:48 PM] [P1] Gas: Configured Name: set to "Gas"
[2/26/2023, 1:32:48 PM] [P1] Gas: On: set to false
[2/26/2023, 1:32:48 PM] [P1] Gas: Total Consumption: set to 570.752 m³
[2/26/2023, 1:32:48 PM] [P1] Electricity Capacity: remove stale ElectricityCapacity v1.3.3-0 accessory 1SAG1105302451C
[2/26/2023, 1:32:48 PM] [P1] Electricity: warning: remove stale service 00000011-0000-1000-8000-656261617577. (Service)
[2/26/2023, 1:32:48 PM] [P1] Electricity: warning: remove stale service 00000089-0000-1000-8000-0026BB765291 (StatelessProgrammableSwitch)
[2/26/2023, 1:32:48 PM] [P1] Electricity: warning: remove stale context 00000011-0000-1000-8000-656261617577.
[2/26/2023, 1:32:48 PM] [P1] Electricity: warning: remove stale context 00000089-0000-1000-8000-0026BB765291
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: warning: remove stale service 00000011-0000-1000-8000-656261617577. (Service)
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: warning: remove stale service 00000089-0000-1000-8000-0026BB765291 (StatelessProgrammableSwitch)
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: warning: remove stale context 00000011-0000-1000-8000-656261617577.
[2/26/2023, 1:32:48 PM] [P1] Electricity Delivered: warning: remove stale context 00000089-0000-1000-8000-0026BB765291
[2/26/2023, 1:32:48 PM] [P1] Gas: warning: remove stale service 00000011-0000-1000-8000-656261617577. (Service)
[2/26/2023, 1:32:48 PM] [P1] Gas: warning: remove stale service 00000089-0000-1000-8000-0026BB765291 (StatelessProgrammableSwitch)
[2/26/2023, 1:32:48 PM] [P1] Gas: warning: remove stale context 00000011-0000-1000-8000-656261617577.
[2/26/2023, 1:32:48 PM] [P1] Gas: warning: remove stale context 00000089-0000-1000-8000-0026BB765291
[2/26/2023, 1:32:49 PM] [P1] Electricity: Electric Current: set to 1.78 A (from 1.79 A)
[2/26/2023, 1:32:49 PM] [P1] Electricity Delivered: Current Consumption: set to 173 W (from 148 W)

I see an Air Pressure service on the Electricity accessory. It currently reads 0 hPa, because solar power provides all electricity, so 0W is imported 👍 I will monitor and report back!

P.S.: I updated beyond 1.3.4-0 — I'm running https://github.com/ebaauw/homebridge-p1/commit/155ac8c54d5d1761865afa953d466d3e398905a9 already (I'm comfortable with git and npm link, so as far as I'm concerned, you don't need to tag pre-release versions — I'm happy to test a specific commit you ask me to test!).

P.P.S.: the [2/26/2023, 1:32:47 PM] [P1] warning: ignoring invalid telegram [2/26/2023, 1:32:48 PM] [P1] FLU5\253770234_A v5.0 in there is pretty curious … is that logged somewhere?

ebaauw commented 1 year ago

[2/26/2023, 1:32:47 PM] [P1] warning: ignoring invalid telegram

That's Homebridge P1 connecting to the P1 port while it's sending a telegram, causing it to receive only a part of the telegram. Pretty common for DSMR 5, which sends a telegram every second.

[2/26/2023, 1:32:48 PM] [P1] FLU5\253770234_A v5.0

That's a seconds later, after the first telegram has been received in full.

you don't need to tag pre-release versions

Beware that there might also be changes to homebridge-lib.

wimleers commented 1 year ago

That's Homebridge P1 connecting to the P1 port while it's sending a telegram, causing it to receive only a part of the telegram. Pretty common for DSMR 5, which sends a telegram every second.

Very interesting, and confirmed just now:

[2/27/2023, 7:28:35 AM] [P1] connected to 192.168.0.219:23
[2/27/2023, 7:28:35 AM] [P1] warning: latest version: homebridge-p1 v1.3.3
…
[2/27/2023, 7:28:36 AM] [P1] warning: ignoring invalid telegram

👍

Beware that there might also be changes to homebridge-lib.

Yep! Checking those too 😊

wimleers commented 1 year ago

I've now been running this for a while. So I started looking at the data, to check if it makes sense. And it does not … at least not at first sight — I'm hoping you can help me understand 😊

Screenshot 2023-03-14 at 19 07 39

☝️ This is last night, in the middle of the night. It sometimes goes down to 14 hPa … which AFAIK means "14 Watt used on average for the past 10 minutes" (since you're aligning to Eve's 10-min resolution, not to Fluvius' 15-min resolution).

But … I only wish my idle power consumption in the middle of the night would drop to 14 hPa 😅 That's never actually the case!

So perhaps it should be multiplied by 6? 6*14 = 84 W. That is possible.

However, if that is accurate, then something else does not make sense:

Screenshot 2023-03-14 at 19 11 38

The highest peak in the last week is 1489 hPa. Multiplied by 6 yields 8934W. It's absolutely impossible for me to reach that level of consumption. I'd need to run a hairdryer, washer, dryer, oven, stove, microwave, toaster, coffee machine all at the same time and then I'd maybe get there. (That scenario definitely didn't happen 😅)

So … any idea what's going on here? How should I interpret the numbers reported by homebridge-p1?

ebaauw commented 1 year ago

which AFAIK means "14 Watt used on average for the past 10 minutes"

No. The history is just the value reported by the meter as average power, in W. So it means over the past 15 minutes, the (running) average power was 14W. So that amounts to a consumption of 14W15m60s/m = 12,600 Ws, or 3.5 Wh during the last 15 minutes.

10 minutes later, the running average power was 72W, resulting in a consumption of 18Wh for the last 15 minutes. Note that 5 minutes of this period overlap with the previous period, so you cannot add up these numbers to know the consumption of the last 30 minutes (or even 20 minutes).

But … I only wish my idle power consumption in the middle of the night would drop to 14 hPa 😅 That's never actually the case!

Did you check the Homebridge log? With log level 1 or higher, it lists the average consumption value as it’s being updated.