-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ugfix in favor of
v5.10
DSMR-parser update (only affected Fluvius) …
- Loading branch information
1 parent
0d1a971
commit d88cbe8
Showing
5 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
dsmr_datalogger/tests/datalogger/test_fluvius_with_peak_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
from unittest import mock | ||
from datetime import datetime | ||
from decimal import Decimal | ||
|
||
from django.test import TestCase | ||
from django.utils import timezone | ||
import pytz | ||
|
||
from dsmr_backend.tests.mixins import InterceptCommandStdoutMixin | ||
from dsmr_datalogger.models.reading import DsmrReading | ||
from dsmr_datalogger.models.statistics import MeterStatistics | ||
from dsmr_datalogger.models.settings import DataloggerSettings | ||
from dsmr_datalogger.tests.datalogger.mixins import FakeDsmrReadingMixin | ||
|
||
|
||
class TestDatalogger(FakeDsmrReadingMixin, InterceptCommandStdoutMixin, TestCase): | ||
"""Belgium Fluvius meter with the late 2022 peak data field.""" | ||
|
||
def setUp(self): | ||
DataloggerSettings.get_solo() | ||
DataloggerSettings.objects.all().update( | ||
dsmr_version=DataloggerSettings.DSMR_BELGIUM_FLUVIUS | ||
) | ||
|
||
def _dsmr_dummy_data(self): | ||
return [ | ||
"/FLU5\253769484_A\r\n", | ||
"\r\n", | ||
"0-0:96.1.4(50217)\r\n", | ||
"0-0:96.1.1(12345678901234567890123456789012)\r\n", | ||
"0-0:1.0.0(230201155056W)\r\n", | ||
"1-0:1.8.1(000143.608*kWh)\r\n", | ||
"1-0:1.8.2(000170.853*kWh)\r\n", | ||
"1-0:2.8.1(000002.963*kWh)\r\n", | ||
"1-0:2.8.2(000000.427*kWh)\r\n", | ||
"0-0:96.14.0(0001)\r\n", | ||
"1-0:1.4.0(00.078*kW)\r\n", | ||
"1-0:1.6.0(230201020000W)(01.566*kW)\r\n", | ||
"0-0:98.1.0(1)(1-0:1.6.0)(1-0:1.6.0)(230201000000W)(230114124500W)(03.332*kW)\r\n", | ||
"1-0:1.7.0(00.182*kW)\r\n", | ||
"1-0:2.7.0(00.000*kW)\r\n", | ||
"1-0:21.7.0(00.230*kW)\r\n", | ||
"1-0:41.7.0(00.000*kW)\r\n", | ||
"1-0:61.7.0(00.000*kW)\r\n", | ||
"1-0:22.7.0(00.000*kW)\r\n", | ||
"1-0:42.7.0(00.000*kW)\r\n", | ||
"1-0:62.7.0(00.048*kW)\r\n", | ||
"1-0:32.7.0(227.8*V)\r\n", | ||
"1-0:52.7.0(000.0*V)\r\n", | ||
"1-0:72.7.0(231.5*V)\r\n", | ||
"1-0:31.7.0(001.60*A)\r\n", | ||
"1-0:51.7.0(001.66*A)\r\n", | ||
"1-0:71.7.0(001.41*A)\r\n", | ||
"0-0:96.3.10(1)\r\n", | ||
"0-0:17.0.0(999.9*kW)\r\n", | ||
"1-0:31.4.0(999*A)\r\n", | ||
"0-0:96.13.0()\r\n", | ||
"!59A5", | ||
] | ||
|
||
def test_reading_creation(self): | ||
"""Test whether dsmr_datalogger can insert a reading.""" | ||
self.assertFalse(DsmrReading.objects.exists()) | ||
self._fake_dsmr_reading() | ||
self.assertTrue(DsmrReading.objects.exists()) | ||
|
||
@mock.patch("django.utils.timezone.now") | ||
def test_reading_values(self, now_mock): | ||
"""Test whether dsmr_datalogger reads the correct values.""" | ||
now_mock.return_value = timezone.make_aware(timezone.datetime(2023, 2, 1)) | ||
self._fake_dsmr_reading() | ||
self.assertTrue(DsmrReading.objects.exists()) | ||
reading = DsmrReading.objects.get() | ||
self.assertEqual( | ||
reading.timestamp, datetime(2023, 2, 1, 14, 50, 56, tzinfo=pytz.UTC) | ||
) | ||
self.assertEqual(reading.electricity_delivered_1, Decimal("143.608")) | ||
self.assertEqual(reading.electricity_returned_1, Decimal("2.963")) | ||
self.assertEqual(reading.electricity_delivered_2, Decimal("170.853")) | ||
self.assertEqual(reading.electricity_returned_2, Decimal("0.427")) | ||
self.assertEqual(reading.electricity_currently_delivered, Decimal("0.182")) | ||
self.assertEqual(reading.electricity_currently_returned, Decimal("0")) | ||
self.assertEqual(reading.extra_device_timestamp, None) # Error handled. | ||
self.assertEqual( | ||
reading.extra_device_delivered, None | ||
) # Should be NONE too due to timestamp. | ||
self.assertEqual(reading.phase_voltage_l1, Decimal("227.8")) | ||
self.assertEqual(reading.phase_voltage_l2, Decimal("0")) | ||
self.assertEqual(reading.phase_voltage_l3, Decimal("231.5")) | ||
self.assertEqual(reading.phase_power_current_l1, 1) | ||
self.assertEqual(reading.phase_power_current_l2, 1) | ||
self.assertEqual(reading.phase_power_current_l3, 1) | ||
|
||
meter_statistics = MeterStatistics.get_solo() | ||
self.assertIsNone(meter_statistics.dsmr_version) | ||
self.assertEqual(meter_statistics.electricity_tariff, 1) | ||
self.assertEqual(meter_statistics.power_failure_count, None) | ||
self.assertEqual(meter_statistics.long_power_failure_count, None) | ||
self.assertEqual(meter_statistics.voltage_sag_count_l1, None) | ||
self.assertEqual(meter_statistics.voltage_sag_count_l2, None) | ||
self.assertEqual(meter_statistics.voltage_sag_count_l3, None) | ||
self.assertEqual(meter_statistics.voltage_swell_count_l1, None) | ||
self.assertEqual(meter_statistics.voltage_swell_count_l2, None) | ||
self.assertEqual(meter_statistics.voltage_swell_count_l3, None) | ||
|
||
@mock.patch("django.utils.timezone.now") | ||
def test_telegram_override_timestamp(self, now_mock): | ||
"""Tests whether this user setting overrides as expectedly.""" | ||
reading = self._reading_with_override_telegram_timestamp_active(now_mock) | ||
|
||
self.assertEqual( | ||
reading.extra_device_delivered, None | ||
) # Should be NONE too due to timestamp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from django.utils.version import get_version | ||
|
||
VERSION = (5, 11, 0, "final", 0) | ||
VERSION = (5, 10, 3, "final", 0) | ||
|
||
__version__ = get_version(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Dump for DSMR-reader v5.10.3 | ||
./manage.py migrate dsmr_api 0003_create_api_user | ||
./manage.py migrate dsmr_backend 0015_backend_restart_required | ||
./manage.py migrate dsmr_backup 0017_backup_interval_in_days | ||
./manage.py migrate dsmr_consumption 0021_schedule_quarter_hour_peaks_calculation | ||
./manage.py migrate dsmr_datalogger 0032_dsmr_extra_device_channel | ||
./manage.py migrate dsmr_dropbox 0001_schedule_dropbox | ||
./manage.py migrate dsmr_frontend 0049_alter_notification_options | ||
./manage.py migrate dsmr_influxdb 0006_influxdb_settings_field_size | ||
./manage.py migrate dsmr_mindergas 0005_schedule_mindergas_export | ||
./manage.py migrate dsmr_mqtt 0021_quarter_hour_peak_mqtt | ||
./manage.py migrate dsmr_notification 0008_dummy_notification_provider | ||
./manage.py migrate dsmr_pvoutput 0004_pvoutput_setting_refactoring | ||
./manage.py migrate dsmr_stats 0020_day_statistics_fix_total_gas_consumption_retroactive | ||
./manage.py migrate dsmr_weather 0006_schedule_weather_update |