From 659134a0ea5adfd69c90d61b9b16a91bb2015313 Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Fri, 28 Jan 2022 00:50:58 +0100 Subject: [PATCH] amiplus driver: added energy parameters for tariffs 1, 2, and 3 --- simulations/simulation_t1.txt | 8 +-- src/driver_amiplus.cc | 114 ++++++++++++++++++++++++++++++++-- tests/test_list_envs.sh | 48 ++++++++------ 3 files changed, 144 insertions(+), 26 deletions(-) diff --git a/simulations/simulation_t1.txt b/simulations/simulation_t1.txt index 1c3935b..bd1d19e 100644 --- a/simulations/simulation_t1.txt +++ b/simulations/simulation_t1.txt @@ -29,14 +29,14 @@ telegram=|1844AE4C4455223368077A55000000|041389E20100023B0000| # Test amiplus/apator electricity meter 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,"voltage_at_phase_2_v":0,"voltage_at_phase_3_v":0,"device_date_time":"2019-03-20 12:57","timestamp":"1111-11-11T11:11:11Z"} -|MyElectricity1;10101010;15694.050000;0.330000;7.480000;0.000000;236.000000;0.000000;0.000000;1111-11-11 11:11.11 +{"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,"voltage_at_phase_2_v":0,"voltage_at_phase_3_v":0,"device_date_time":"2019-03-20 12:57","total_energy_consumption_tariff_1_kwh":0,"total_energy_consumption_tariff_2_kwh":0,"total_energy_consumption_tariff_3_kwh":0,"total_energy_production_tariff_1_kwh":0,"total_energy_production_tariff_2_kwh":0,"total_energy_production_tariff_3_kwh":0,"timestamp":"1111-11-11T11:11:11Z"} +|MyElectricity1;10101010;15694.050000;0.330000;7.480000;0.000000;236.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;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","timestamp":"1111-11-11T11:11:11Z"} -|MyElectricity2;00254358;9652.220000;1.055000;0.000000;0.000000;235.000000;245.000000;239.000000;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,"device_date_time":"2021-10-12 08:07","total_energy_consumption_tariff_1_kwh":0,"total_energy_consumption_tariff_2_kwh":0,"total_energy_consumption_tariff_3_kwh":0,"total_energy_production_tariff_1_kwh":0,"total_energy_production_tariff_2_kwh":0,"total_energy_production_tariff_3_kwh":0,"timestamp":"1111-11-11T11:11:11Z"} +|MyElectricity2;00254358;9652.220000;1.055000;0.000000;0.000000;235.000000;245.000000;239.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;1111-11-11 11:11.11 # Test MKRadio3 T1 telegrams diff --git a/src/driver_amiplus.cc b/src/driver_amiplus.cc index 0830898..52a5254 100644 --- a/src/driver_amiplus.cc +++ b/src/driver_amiplus.cc @@ -31,6 +31,12 @@ private: double phase_2_v_ {}; double phase_3_v_ {}; string device_date_time_; + double total_energy_consumption_tariff_1_kwh_ {}; + double total_energy_consumption_tariff_2_kwh_ {}; + double total_energy_consumption_tariff_3_kwh_ {}; + double total_energy_production_tariff_1_kwh_ {}; + double total_energy_production_tariff_2_kwh_ {}; + double total_energy_production_tariff_3_kwh_ {}; }; static bool ok = registerDriver([](DriverInfo&di) @@ -165,16 +171,116 @@ MeterAmiplus::MeterAmiplus(MeterInfo &mi, DriverInfo &di) : MeterCommonImplement "Device date time.", SET_STRING_FUNC(device_date_time_), GET_STRING_FUNC(device_date_time_)); + + addFieldWithExtractor( + "total_energy_consumption_tariff_1", + Quantity::Energy, + DifVifKey("8E1003"), + VifScaling::Auto, + MeasurementType::Unknown, + ValueInformation::None, + StorageNr(0), + TariffNr(1), + IndexNr(1), + PrintProperty::JSON | PrintProperty::FIELD, + "The total energy consumption recorded by this meter on tariff 1.", + SET_FUNC(total_energy_consumption_tariff_1_kwh_, Unit::KWH), + GET_FUNC(total_energy_consumption_tariff_1_kwh_, Unit::KWH)); + + addFieldWithExtractor( + "total_energy_consumption_tariff_2", + Quantity::Energy, + DifVifKey("8E2003"), + VifScaling::Auto, + MeasurementType::Unknown, + ValueInformation::None, + StorageNr(0), + TariffNr(2), + IndexNr(1), + PrintProperty::JSON | PrintProperty::FIELD, + "The total energy consumption recorded by this meter on tariff 2.", + SET_FUNC(total_energy_consumption_tariff_2_kwh_, Unit::KWH), + GET_FUNC(total_energy_consumption_tariff_2_kwh_, Unit::KWH)); + + + addFieldWithExtractor( + "total_energy_consumption_tariff_3", + Quantity::Energy, + DifVifKey("8E3003"), + VifScaling::Auto, + MeasurementType::Unknown, + ValueInformation::None, + StorageNr(0), + TariffNr(3), + IndexNr(1), + PrintProperty::JSON | PrintProperty::FIELD, + "The total energy consumption recorded by this meter on tariff 3.", + SET_FUNC(total_energy_consumption_tariff_3_kwh_, Unit::KWH), + GET_FUNC(total_energy_consumption_tariff_3_kwh_, Unit::KWH)); + + addFieldWithExtractor( + "total_energy_production_tariff_1", + Quantity::Energy, + DifVifKey("8E10833C"), + VifScaling::Auto, + MeasurementType::Unknown, + ValueInformation::None, + StorageNr(0), + TariffNr(1), + IndexNr(1), + PrintProperty::JSON | PrintProperty::FIELD, + "The total energy production recorded by this meter on tariff 1.", + SET_FUNC(total_energy_production_tariff_1_kwh_, Unit::KWH), + GET_FUNC(total_energy_production_tariff_1_kwh_, Unit::KWH)); + + + addFieldWithExtractor( + "total_energy_production_tariff_2", + Quantity::Energy, + DifVifKey("8E20833C"), + VifScaling::Auto, + MeasurementType::Unknown, + ValueInformation::None, + StorageNr(0), + TariffNr(2), + IndexNr(1), + PrintProperty::JSON | PrintProperty::FIELD, + "The total energy production recorded by this meter on tariff 2.", + SET_FUNC(total_energy_production_tariff_2_kwh_, Unit::KWH), + GET_FUNC(total_energy_production_tariff_2_kwh_, Unit::KWH)); + + + addFieldWithExtractor( + "total_energy_production_tariff_3", + Quantity::Energy, + DifVifKey("8E30833C"), + VifScaling::Auto, + MeasurementType::Unknown, + ValueInformation::None, + StorageNr(0), + TariffNr(3), + IndexNr(1), + PrintProperty::JSON | PrintProperty::FIELD, + "The total energy production recorded by this meter on tariff 3.", + SET_FUNC(total_energy_production_tariff_3_kwh_, Unit::KWH), + GET_FUNC(total_energy_production_tariff_3_kwh_, Unit::KWH)); } // 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,"voltage_at_phase_2_v":0,"voltage_at_phase_3_v":0,"device_date_time":"2019-03-20 12:57","timestamp":"1111-11-11T11:11:11Z"} -// |MyElectricity1;10101010;15694.050000;0.330000;7.480000;0.000000;236.000000;0.000000;0.000000;1111-11-11 11:11.11 +// {"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,"voltage_at_phase_2_v":0,"voltage_at_phase_3_v":0,"device_date_time":"2019-03-20 12:57","total_energy_consumption_tariff_1_kwh":0,"total_energy_consumption_tariff_2_kwh":0,"total_energy_consumption_tariff_3_kwh":0,"total_energy_production_tariff_1_kwh":0,"total_energy_production_tariff_2_kwh":0,"total_energy_production_tariff_3_kwh":0,"timestamp":"1111-11-11T11:11:11Z"} +// |MyElectricity1;10101010;15694.050000;0.330000;7.480000;0.000000;236.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;1111-11-11 11:11.11 // Test: MyElectricity2 amiplus 00254358 NOKEY // 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","timestamp":"1111-11-11T11:11:11Z"} -// |MyElectricity2;00254358;9652.220000;1.055000;0.000000;0.000000;235.000000;245.000000;239.000000;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,"device_date_time":"2021-10-12 08:07","total_energy_consumption_tariff_1_kwh":0,"total_energy_consumption_tariff_2_kwh":0,"total_energy_consumption_tariff_3_kwh":0,"total_energy_production_tariff_1_kwh":0,"total_energy_production_tariff_2_kwh":0,"total_energy_production_tariff_3_kwh":0,"timestamp":"1111-11-11T11:11:11Z"} +// |MyElectricity2;00254358;9652.220000;1.055000;0.000000;0.000000;235.000000;245.000000;239.000000;0.000000;0.000000;0.000000;0.000000;0.000000;0.000000;1111-11-11 11:11.11 + +// Test: MyElectricity3 amiplus 86064864 NOKEY +// amiplus/apator electricity meter with three phase voltages and 2 tariffs + +// telegram=|804401066448068602027A000070052F2F|066D1E5C11DA21400C78644806868E10036110012500008E20038106531800008E10833C9949000000008E20833C8606000000001B2B5228020B2B3217000BAB3C0000000AFDC9FC0131020AFDC9FC0225020AFDC9FC0331020BABC8FC100000002F2F2F2F2F2F2F2F2F2F2F2F2FDE47| +// {"media":"electricity","meter":"amiplus","name":"MyElectricity3","id":"86064864","total_energy_consumption_kwh":0,"current_power_consumption_kw":1.732,"total_energy_production_kwh":0,"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","total_energy_consumption_tariff_1_kwh":25011.061,"total_energy_consumption_tariff_2_kwh":18530.681,"total_energy_consumption_tariff_3_kwh":0,"total_energy_production_tariff_1_kwh":4.999,"total_energy_production_tariff_2_kwh":0.686,"total_energy_production_tariff_3_kwh":0,"timestamp":"1111-11-11T11:11:11Z"} +// |MyElectricity3;86064864;0.000000;1.732000;0.000000;0.000000;231.000000;225.000000;231.000000;25011.061000;18530.681000;0.000000;4.999000;0.686000;0.000000;1111-11-11 11:11.11 diff --git a/tests/test_list_envs.sh b/tests/test_list_envs.sh index 15a0c36..d3ab6fa 100755 --- a/tests/test_list_envs.sh +++ b/tests/test_list_envs.sh @@ -30,6 +30,12 @@ METER_VOLTAGE_AT_PHASE_1_Volt METER_VOLTAGE_AT_PHASE_2_Volt METER_VOLTAGE_AT_PHASE_3_Volt METER_DEVICE_DATE_TIME +METER_TOTAL_ENERGY_CONSUMPTION_TARIFF_1_KWH +METER_TOTAL_ENERGY_CONSUMPTION_TARIFF_2_KWH +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 EOF if [ "$?" = "0" ] @@ -51,24 +57,30 @@ fi $PROG --listfields=amiplus > $TEST/test_output.txt 2>&1 cat < $TEST/test_expected.txt - id The meter id number. - name Your name for the meter. - media What does the meter measure? - meter Meter driver. - timestamp Timestamp when wmbusmeters received the telegram. Local time for hr/fields UTC for json. - timestamp_ut Unix timestamp when wmbusmeters received the telegram. - timestamp_lt Local time when wmbusmeters received the telegram. - timestamp_utc UTC time when wmbusmeters received the telegram. - device The wmbus device that received the telegram. - rssi_dbm The rssi for the received telegram as reported by the device. -total_energy_consumption_kwh The total energy consumption recorded by this meter. -current_power_consumption_kw Current power consumption. - total_energy_production_kwh The total energy production recorded by this meter. - current_power_production_kw Current power production. - voltage_at_phase_1_v Voltage at phase L1. - voltage_at_phase_2_v Voltage at phase L2. - voltage_at_phase_3_v Voltage at phase L3. - device_date_time_txt Device date time. + id The meter id number. + name Your name for the meter. + media What does the meter measure? + meter Meter driver. + timestamp Timestamp when wmbusmeters received the telegram. Local time for hr/fields UTC for json. + timestamp_ut Unix timestamp when wmbusmeters received the telegram. + timestamp_lt Local time when wmbusmeters received the telegram. + timestamp_utc UTC time when wmbusmeters received the telegram. + device The wmbus device that received the telegram. + rssi_dbm The rssi for the received telegram as reported by the device. + total_energy_consumption_kwh The total energy consumption recorded by this meter. + current_power_consumption_kw Current power consumption. + total_energy_production_kwh The total energy production recorded by this meter. + current_power_production_kw Current power production. + voltage_at_phase_1_v Voltage at phase L1. + voltage_at_phase_2_v Voltage at phase L2. + voltage_at_phase_3_v Voltage at phase L3. + device_date_time_txt Device date time. +total_energy_consumption_tariff_1_kwh The total energy consumption recorded by this meter on tariff 1. +total_energy_consumption_tariff_2_kwh The total energy consumption recorded by this meter on tariff 2. +total_energy_consumption_tariff_3_kwh The total energy consumption recorded by this meter on tariff 3. + 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. EOF if [ "$?" = "0" ]