From 07316b3891a1809130981e6286ce6fdc3b034aef Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Wed, 27 Mar 2024 11:20:45 +0100 Subject: [PATCH] EEP A5-06-01 and A5-04-03 added --- README.md | 3 +- changes.md | 2 ++ custom_components/eltako/manifest.json | 2 +- custom_components/eltako/schema.py | 2 ++ custom_components/eltako/sensor.py | 7 +++- tests/test_sensor_A5_04_02.py | 6 ++-- tests/test_sensor_A5_04_03.py | 46 ++++++++++++++++++++++++++ tests/test_sensor_A5_06_01.py | 42 +++++++++++++++++++++++ 8 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 tests/test_sensor_A5_04_03.py create mode 100644 tests/test_sensor_A5_06_01.py diff --git a/README.md b/README.md index 88811cea..fd846a92 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ Elatko devices are exemplarily mentioned. You can find [here](https://www.eltako * Sensor * A5-04-01 (Temperature and Humidity Sensor) * A5-04-02 (Temperature and Humidity Sensor e.g.: FLGTF, FLT58, FFT60) - * A5-04-03 **Coming soon!** (Temperature and Humidity Sensor e.g.: FFT60) + * A5-04-03 (Temperature and Humidity Sensor e.g.: FFT60) + * A5-06-01 (Light - Twilight and Illumination) * A5-07-01 (Occupancy sensor) * A5-08-01 (Light-, Temperature-, Occupancy Sensor e.g.: FABH65S, FBH65, FBH65S, FBH65TF) * A5-09-0C (Air Quality / VOC⁠ (Volatile Organic Compounds) e.g. [FLGTF](https://github.com/grimmpp/home-assistant-eltako/tree/main/docs/flgtf_temp_humidity_air_quality/readme.md)) diff --git a/changes.md b/changes.md index dd2977d7..ed795e25 100644 --- a/changes.md +++ b/changes.md @@ -5,6 +5,8 @@ * 🐞 Fix for TargetTemperatureSensor (EEP: A5-10-06 and A5-10-12) * 🐞 Fix for unknow cover positions. * Unit-Tests added and improved for EEP A5-04-01, A5-04-02, A5-10-06, A5-10-12, A5-13-01, and F6-10-00. +* EEP A5-04-03 added for Eltako FFT60 (temperature and humiditry) +* EEP A5-06-01 added for light sensor (currently twilight and daylight are combinded in one illumination sensor/entity) ## Version 1.4.0 ESP3 Support (USB300) * Docs about gateway usage added. diff --git a/custom_components/eltako/manifest.json b/custom_components/eltako/manifest.json index 94b2931b..c12fcc0b 100644 --- a/custom_components/eltako/manifest.json +++ b/custom_components/eltako/manifest.json @@ -9,6 +9,6 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/grimmpp/home-assistant-eltako/issues", "loggers": ["eltako"], - "requirements": ["eltako14bus==0.0.47","enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.1"], + "requirements": ["eltako14bus==0.0.48","enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.1"], "version": "1.3.9" } diff --git a/custom_components/eltako/schema.py b/custom_components/eltako/schema.py index 6eae9795..a41df48f 100644 --- a/custom_components/eltako/schema.py +++ b/custom_components/eltako/schema.py @@ -149,6 +149,8 @@ class SensorSchema(EltakoPlatformSchema): CONF_EEP_SUPPORTED = [A5_04_01.eep_string, A5_04_02.eep_string, + A5_04_03.eep_string, + A5_06_01.eep_string, A5_07_01.eep_string, A5_08_01.eep_string, A5_09_0C.eep_string, diff --git a/custom_components/eltako/sensor.py b/custom_components/eltako/sensor.py index dc4a6822..4a6abeeb 100644 --- a/custom_components/eltako/sensor.py +++ b/custom_components/eltako/sensor.py @@ -344,7 +344,7 @@ async def async_setup_entry( entities.append(EltakoMeterSensor(platform, gateway, dev_conf.id, dev_name, dev_conf.eep, SENSOR_DESC_WATER_CUMULATIVE, tariff=(tariff - 1))) entities.append(EltakoMeterSensor(platform, gateway, dev_conf.id, dev_name, dev_conf.eep, SENSOR_DESC_WATER_CURRENT, tariff=(tariff - 1))) - elif dev_conf.eep in [A5_04_02, A5_10_12, A5_04_01]: + elif dev_conf.eep in [A5_04_01, A5_04_02, A5_04_03, A5_10_12]: entities.append(EltakoTemperatureSensor(platform, gateway, dev_conf.id, dev_name, dev_conf.eep)) entities.append(EltakoHumiditySensor(platform, gateway, dev_conf.id, dev_name, dev_conf.eep)) @@ -371,6 +371,11 @@ async def async_setup_entry( entities.append(EltakoBatteryVoltageSensor(platform, gateway, dev_conf.id, dev_name, dev_conf.eep)) # _pir_status => as binary sensor + elif dev_conf.eep in [A5_06_01]: + entities.append(EltakoIlluminationSensor(platform, gateway, dev_conf.id, dev_name, dev_conf.eep)) + #TODO: add twilight + #TODO: add daylight + # both are currently combined in illumination except Exception as e: LOGGER.warning("[%s] Could not load configuration", platform) diff --git a/tests/test_sensor_A5_04_02.py b/tests/test_sensor_A5_04_02.py index 0cc15375..863f16da 100644 --- a/tests/test_sensor_A5_04_02.py +++ b/tests/test_sensor_A5_04_02.py @@ -15,7 +15,7 @@ class TestSensor_A5_04_02(unittest.TestCase): - msg1 = Regular4BSMessage (address=b'\xFF\xFF\x00\x80', data=b'\xaa\x00\x00\x0d', status=0x00) + msg1 = Regular4BSMessage (address=b'\xFF\xFF\x00\x80', data=b'\x00\x7C\x86\x0F', status=0x00) def create_temperature_sensor(self) -> EltakoTemperatureSensor: gateway = GatewayMock() @@ -37,10 +37,10 @@ def test_temperature_sensor_A5_04_02(self): s_temp = self.create_temperature_sensor() s_temp.value_changed(self.msg1) - self.assertEqual(s_temp.native_value, -20.0) + self.assertEqual(s_temp.native_value, 22.880000000000003) def test_humidity_sensor_A5_04_02(self): s_hum = self.create_humidity_sensor() s_hum.value_changed(self.msg1) - self.assertEqual(s_hum.native_value, 0.0) \ No newline at end of file + self.assertEqual(s_hum.native_value, 49.6) \ No newline at end of file diff --git a/tests/test_sensor_A5_04_03.py b/tests/test_sensor_A5_04_03.py new file mode 100644 index 00000000..f3ee51d3 --- /dev/null +++ b/tests/test_sensor_A5_04_03.py @@ -0,0 +1,46 @@ +import unittest +from custom_components.eltako.sensor import * +from mocks import HassMock +from unittest import mock +from mocks import * +from homeassistant.helpers.entity import Entity +from homeassistant.const import Platform +from custom_components.eltako.binary_sensor import EltakoBinarySensor +from eltakobus import * + +# mock update of Home Assistant +Entity.schedule_update_ha_state = mock.Mock(return_value=None) +# EltakoBinarySensor.hass.bus.fire is mocked by class HassMock + + +class TestSensor_A5_04_02(unittest.TestCase): + + msg1 = Regular4BSMessage (address=b'\xFF\xFF\x00\x80', data=b'\x99\x02\x12\x09', status=0x00) + + def create_temperature_sensor(self) -> EltakoTemperatureSensor: + gateway = GatewayMock() + dev_id = AddressExpression.parse("FF-FF-00-80") + dev_name = "device name" + dev_eep = EEP.find("A5-04-03") + s = EltakoTemperatureSensor(Platform.SENSOR, gateway, dev_id, dev_name, dev_eep) + return s + + def create_humidity_sensor(self) -> EltakoHumiditySensor: + gateway = GatewayMock() + dev_id = AddressExpression.parse("FF-FF-00-80") + dev_name = "device name" + dev_eep = EEP.find("A5-04-03") + s = EltakoHumiditySensor(Platform.SENSOR, gateway, dev_id, dev_name, dev_eep) + return s + + def test_temperature_sensor_A5_04_02(self): + s_temp = self.create_temperature_sensor() + + s_temp.value_changed(self.msg1) + self.assertEqual(s_temp.native_value, 22.8125) + + def test_humidity_sensor_A5_04_02(self): + s_hum = self.create_humidity_sensor() + + s_hum.value_changed(self.msg1) + self.assertEqual(s_hum.native_value, 60.0) \ No newline at end of file diff --git a/tests/test_sensor_A5_06_01.py b/tests/test_sensor_A5_06_01.py new file mode 100644 index 00000000..3a26e588 --- /dev/null +++ b/tests/test_sensor_A5_06_01.py @@ -0,0 +1,42 @@ +import unittest +from custom_components.eltako.sensor import * +from mocks import HassMock +from unittest import mock +from mocks import * +from homeassistant.helpers.entity import Entity +from homeassistant.const import Platform +from custom_components.eltako.binary_sensor import EltakoBinarySensor +from eltakobus import * + +# mock update of Home Assistant +Entity.schedule_update_ha_state = mock.Mock(return_value=None) +# EltakoBinarySensor.hass.bus.fire is mocked by class HassMock + + +class TestSensor_A5_06_01(unittest.TestCase): + + + + def create_illumination_sensor(self) -> EltakoIlluminationSensor: + gateway = GatewayMock() + dev_id = AddressExpression.parse("FF-FF-00-80") + dev_name = "device name" + dev_eep = EEP.find("A5-06-01") + s = EltakoIlluminationSensor(Platform.SENSOR, gateway, dev_id, dev_name, dev_eep) + return s + + def test_illumincation_sensor(self): + s_ill = self.create_illumination_sensor() + + # check daylight + msg = Regular4BSMessage (address=b'\xFF\xFF\x00\x80', data=b'\x60\xAA\x00\x0F', status=0x00) + s_ill.value_changed(msg) + self.assertEqual(s_ill.native_value, 20100.0) + + # check twilight + msg = Regular4BSMessage (address=b'\xFF\xFF\x00\x80', data=b'\x60\x00\x00\x0F', status=0x00) + s_ill.value_changed(msg) + self.assertEqual(s_ill.native_value, 96.0) + + + \ No newline at end of file