One function

DateTimeSensor in kbialek/deye-inverter-mqtt

The author described this change as Fix for issue #266. It counts as a record because the check below fails on the code as it stood at 0c4efe43b and passes on 84e56362c, with nothing else changed between the two runs.

Fix saved2026-01-03
Sharing licenceApache-2.0 · LICENSE
Change size+6 1

What the code was meant to do, written into the code itself as a docstring

Sensor for system date&time stored in three Modbus registers.

The change

3636 else:
3737 return None
3838
39- return datetime(year, month, day, hour, minute, second).timestamp()
39+ try:
40+ retval = datetime(year, month, day, hour, minute, second).timestamp()
41+ except ValueError:
42+ retval = None
43+
44+ return retval
4045
4146 def write_value(self, value: datetime) -> dict[int, bytearray]:
4247

The check that tells the two apart

failpass·tests/deye_sensor_test.py::DeyeSensorTest::test_datetime_sensor_wrong_input

Check file tests/deye_sensor_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it0c4efe43beba3dd6db092075cb76a2e90a946070
Broken version dated2025-12-17
Moduledeye_sensor
Units changedDateTimeSensor
Fingerprintcedc9a9f5c5001d6
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.