From 6729d4695703029c1feee3739c57059f485ea018 Mon Sep 17 00:00:00 2001 From: DeDragonSlayer Date: Sun, 2 Apr 2023 13:45:58 +0200 Subject: [PATCH] amiplus - add maximum power consumption field. This is calculated as the maximum value of 15-minute consumption averages, reset on 1st of each month. If the calculated max power consumption exceeds the value on the contract with power company, the end user will pay penalty fees. --- simulations/simulation_t1.txt | 6 +++--- src/driver_amiplus.cc | 24 ++++++++++++++++++------ tests/test_list_envs.sh | 2 ++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/simulations/simulation_t1.txt b/simulations/simulation_t1.txt index 42bfc0b..d5f0d32 100644 --- a/simulations/simulation_t1.txt +++ b/simulations/simulation_t1.txt @@ -30,13 +30,13 @@ telegram=|1844AE4C4455223368077A55000000_041389E20100023B0000| telegram=|4E4401061010101002027A00004005_2F2F0E035040691500000B2B300300066D00790C7423400C78371204860BABC8FC100000000E833C8074000000000BAB3C0000000AFDC9FC0136022F2F2F2F2F| {"media":"electricity","meter":"amiplus","name":"MyElectricity1","id":"10101010","total_energy_consumption_kwh":15694.05,"current_power_consumption_kw":0.33,"total_energy_production_kwh":7.48,"current_power_production_kw":0,"voltage_at_phase_1_v":236,"device_date_time":"2019-03-20 12:57:00","timestamp":"1111-11-11T11:11:11Z"} -|MyElectricity1;10101010;15694.05;0.33;7.48;0;236;null;null;null;null;null;null;null;null;1111-11-11 11:11.11 +|MyElectricity1;10101010;15694.05;0.33;7.48;0;236;null;null;null;null;null;null;null;null;null;1111-11-11 11:11.11 # Test amiplus/apator electricity meter with three phase voltages telegram=|5E44B6105843250000027A2A005005_2F2F0C7835221400066D404708AC2A400E032022650900000E833C0000000000001B2B9647000B2B5510000BAB3C0000000AFDC9FC0135020AFDC9FC0245020AFDC9FC0339020BABC8FC100000002F2F| -{"media":"electricity","meter":"amiplus","name":"MyElectricity2","id":"00254358","total_energy_consumption_kwh":9652.22,"current_power_consumption_kw":1.055,"total_energy_production_kwh":0,"current_power_production_kw":0,"voltage_at_phase_1_v":235,"voltage_at_phase_2_v":245,"voltage_at_phase_3_v":239,"device_date_time":"2021-10-12 08:07:00","timestamp":"1111-11-11T11:11:11Z"} -|MyElectricity2;00254358;9652.22;1.055;0;0;235;245;239;null;null;null;null;null;null;1111-11-11 11:11.11 +{"media":"electricity","meter":"amiplus","name":"MyElectricity2","id":"00254358","total_energy_consumption_kwh":9652.22,"current_power_consumption_kw":1.055,"total_energy_production_kwh":0,"current_power_production_kw":0,"voltage_at_phase_1_v":235,"voltage_at_phase_2_v":245,"voltage_at_phase_3_v":239,"max_power_consumption_kw":4.796,"device_date_time":"2021-10-12 08:07:00","timestamp":"1111-11-11T11:11:11Z"} +|MyElectricity2;00254358;9652.22;1.055;0;0;235;245;239;null;null;null;null;null;null;4.796;1111-11-11 11:11.11 # Test MKRadio3 T1 telegrams diff --git a/src/driver_amiplus.cc b/src/driver_amiplus.cc index b2f305f..4067111 100644 --- a/src/driver_amiplus.cc +++ b/src/driver_amiplus.cc @@ -27,7 +27,7 @@ namespace static bool ok = registerDriver([](DriverInfo&di) { di.setName("amiplus"); - di.setDefaultFields("name,id,total_energy_consumption_kwh,current_power_consumption_kw,total_energy_production_kwh,current_power_production_kw,voltage_at_phase_1_v,voltage_at_phase_2_v,voltage_at_phase_3_v,total_energy_consumption_tariff_1_kwh,total_energy_consumption_tariff_2_kwh,total_energy_consumption_tariff_3_kwh,total_energy_production_tariff_1_kwh,total_energy_production_tariff_2_kwh,total_energy_production_tariff_3_kwh,timestamp"); + di.setDefaultFields("name,id,total_energy_consumption_kwh,current_power_consumption_kw,total_energy_production_kwh,current_power_production_kw,voltage_at_phase_1_v,voltage_at_phase_2_v,voltage_at_phase_3_v,total_energy_consumption_tariff_1_kwh,total_energy_consumption_tariff_2_kwh,total_energy_consumption_tariff_3_kwh,total_energy_production_tariff_1_kwh,total_energy_production_tariff_2_kwh,total_energy_production_tariff_3_kwh,max_power_consumption_kw,timestamp"); di.setMeterType(MeterType::ElectricityMeter); di.addLinkMode(LinkMode::T1); di.addDetection(MANUFACTURER_APA, 0x02, 0x02); @@ -184,22 +184,34 @@ namespace FieldMatcher::build() .set(DifVifKey("8E30833C")) ); + + addNumericFieldWithExtractor( + "max_power_consumption", + "The maximum demand indicator (maximum 15-min average power consumption recorded this month).", + DEFAULT_PRINT_PROPERTIES, + Quantity::Power, + VifScaling::Auto, + FieldMatcher::build() + .set(MeasurementType::Maximum) + .set(VIFRange::AnyPowerVIF) + ); + } } // Test: MyElectricity1 amiplus 10101010 NOKEY // telegram=|4E4401061010101002027A00004005_2F2F0E035040691500000B2B300300066D00790C7423400C78371204860BABC8FC100000000E833C8074000000000BAB3C0000000AFDC9FC0136022F2F2F2F2F| // {"media":"electricity","meter":"amiplus","name":"MyElectricity1","id":"10101010","total_energy_consumption_kwh":15694.05,"current_power_consumption_kw":0.33,"total_energy_production_kwh":7.48,"current_power_production_kw":0,"voltage_at_phase_1_v":236,"device_date_time":"2019-03-20 12:57:00","timestamp":"1111-11-11T11:11:11Z"} -// |MyElectricity1;10101010;15694.05;0.33;7.48;0;236;null;null;null;null;null;null;null;null;1111-11-11 11:11.11 +// |MyElectricity1;10101010;15694.05;0.33;7.48;0;236;null;null;null;null;null;null;null;null;null;1111-11-11 11:11.11 // Test: MyElectricity2 amiplus 00254358 NOKEY // Comment: amiplus/apator electricity meter with three phase voltages // telegram=|5E44B6105843250000027A2A005005_2F2F0C7835221400066D404708AC2A400E032022650900000E833C0000000000001B2B9647000B2B5510000BAB3C0000000AFDC9FC0135020AFDC9FC0245020AFDC9FC0339020BABC8FC100000002F2F| -// {"media":"electricity","meter":"amiplus","name":"MyElectricity2","id":"00254358","total_energy_consumption_kwh":9652.22,"current_power_consumption_kw":1.055,"total_energy_production_kwh":0,"current_power_production_kw":0,"voltage_at_phase_1_v":235,"voltage_at_phase_2_v":245,"voltage_at_phase_3_v":239,"device_date_time":"2021-10-12 08:07:00","timestamp":"1111-11-11T11:11:11Z"} -// |MyElectricity2;00254358;9652.22;1.055;0;0;235;245;239;null;null;null;null;null;null;1111-11-11 11:11.11 +// {"media":"electricity","meter":"amiplus","name":"MyElectricity2","id":"00254358","total_energy_consumption_kwh":9652.22,"current_power_consumption_kw":1.055,"total_energy_production_kwh":0,"current_power_production_kw":0,"voltage_at_phase_1_v":235,"voltage_at_phase_2_v":245,"voltage_at_phase_3_v":239,"max_power_consumption_kw":4.796,"device_date_time":"2021-10-12 08:07:00","timestamp":"1111-11-11T11:11:11Z"} +// |MyElectricity2;00254358;9652.22;1.055;0;0;235;245;239;null;null;null;null;null;null;4.796;1111-11-11 11:11.11 // Test: MyElectricity3 amiplus 86064864 NOKEY // Comment: amiplus/apator electricity meter with three phase voltages and 2 tariffs. // telegram=|804401066448068602027A000070052F2F_066D1E5C11DA21400C78644806868E10036110012500008E20038106531800008E10833C9949000000008E20833C8606000000001B2B5228020B2B3217000BAB3C0000000AFDC9FC0131020AFDC9FC0225020AFDC9FC0331020BABC8FC100000002F2F2F2F2F2F2F2F2F2F2F2F2FDE47| -// {"media":"electricity","meter":"amiplus","name":"MyElectricity3","id":"86064864","current_power_consumption_kw":1.732,"current_power_production_kw":0,"voltage_at_phase_1_v":231,"voltage_at_phase_2_v":225,"voltage_at_phase_3_v":231,"device_date_time":"2022-01-26 17:28:30","total_energy_consumption_tariff_1_kwh":25011.061,"total_energy_consumption_tariff_2_kwh":18530.681,"total_energy_production_tariff_1_kwh":4.999,"total_energy_production_tariff_2_kwh":0.686,"timestamp":"1111-11-11T11:11:11Z"} -// |MyElectricity3;86064864;null;1.732;null;0;231;225;231;25011.061;18530.681;null;4.999;0.686;null;1111-11-11 11:11.11 +// {"media":"electricity","meter":"amiplus","name":"MyElectricity3","id":"86064864","current_power_consumption_kw":1.732,"current_power_production_kw":0,"voltage_at_phase_1_v":231,"voltage_at_phase_2_v":225,"voltage_at_phase_3_v":231,"device_date_time":"2022-01-26 17:28:30","total_energy_consumption_tariff_1_kwh":25011.061,"total_energy_consumption_tariff_2_kwh":18530.681,"total_energy_production_tariff_1_kwh":4.999,"total_energy_production_tariff_2_kwh":0.686,"max_power_consumption_kw":22.852,"timestamp":"1111-11-11T11:11:11Z"} +// |MyElectricity3;86064864;null;1.732;null;0;231;225;231;25011.061;18530.681;null;4.999;0.686;null;22.852;1111-11-11 11:11.11 diff --git a/tests/test_list_envs.sh b/tests/test_list_envs.sh index 16a90be..bc3193e 100755 --- a/tests/test_list_envs.sh +++ b/tests/test_list_envs.sh @@ -36,6 +36,7 @@ METER_TOTAL_ENERGY_CONSUMPTION_TARIFF_3_KWH METER_TOTAL_ENERGY_PRODUCTION_TARIFF_1_KWH METER_TOTAL_ENERGY_PRODUCTION_TARIFF_2_KWH METER_TOTAL_ENERGY_PRODUCTION_TARIFF_3_KWH +METER_MAX_POWER_CONSUMPTION_KW EOF if [ "$?" = "0" ] @@ -86,6 +87,7 @@ total_energy_consumption_tariff_3_kwh The total energy consumption recorded by total_energy_production_tariff_1_kwh The total energy production recorded by this meter on tariff 1. total_energy_production_tariff_2_kwh The total energy production recorded by this meter on tariff 2. total_energy_production_tariff_3_kwh The total energy production recorded by this meter on tariff 3. + max_power_consumption_kw The maximum demand indicator (maximum 15-min average power consumption recorded this month). EOF if [ "$?" = "0" ]