diff --git a/changes.md b/changes.md index c83b752e..7b18fb7c 100644 --- a/changes.md +++ b/changes.md @@ -1,12 +1,12 @@ # Changes and Feature List ## Version 1.4.2 Added EEPs A5-30-01 and A5-30-03 -* Added EEPs for digital input with is used in water sensor (FSM60B) +* Added EEPs (A5-30-01 preferred) for digital input which is used in water sensor (FSM60B) ## Version 1.4.1 Support for sending arbitrary messages * Added Service for sending arbitrary EnOcean (ESP2) messages. Intended to be used in conjunction with [Home Assistant Automations](https://www.home-assistant.io/getting-started/automation/). * 🐞 Fix for TargetTemperatureSensor (EEP: A5-10-06 and A5-10-12) -* 🐞 Fix for unknow cover positions and intermediate state + unit-tests added. +* 🐞 Fix for unknown cover positions and intermediate state + unit-tests added. * 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 humidity) * EEP A5-06-01 added for light sensor (currently twilight and daylight are combined in one illumination sensor/entity) @@ -20,7 +20,7 @@ * Added library for ESP3 (USB300 Support) => [esp2_gateway_adapter](https://github.com/grimmpp/esp2_gateway_adapter) * Better support for Teach-In Button -## Version 1.3.8 Fixes and Smaller Imrovements +## Version 1.3.8 Fixes and Smaller Improvements * Fixed window handle F6-10-00 in binary sensor * Added better tests for binary sensors * Fixed covers which behaved differently after introducing recovery state feature. @@ -36,7 +36,7 @@ * Trial to remove import warnings Reported Issue: https://github.com/grimmpp/home-assistant-eltako/issues/61 * 🐞 Removed entity_id bug from GatewayConnectionState 🐞 => Requires removing and adding gateway again ❗ -* Added state cache of device entities. When restarting HA entities like temperature sensors will show previouse state/value after restart. +* Added state cache of device entities. When restarting HA entities like temperature sensors will show previous state/value after restart. Reported Feature: https://github.com/grimmpp/home-assistant-eltako/issues/63 ## Version 1.3.6 Dependencies fixed for 1.3.5 diff --git a/custom_components/eltako/manifest.json b/custom_components/eltako/manifest.json index aca7540f..cc195908 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.49","enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.1"], + "requirements": ["eltako14bus==0.0.51","enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.1"], "version": "1.4.1" } diff --git a/docs/service-send-message/eep-params.md b/docs/service-send-message/eep-params.md index 7b747b11..9b42f6af 100644 --- a/docs/service-send-message/eep-params.md +++ b/docs/service-send-message/eep-params.md @@ -1,5 +1,5 @@ # Paramters for EEPs in Send Message Events -(This file was auto-generated by using [eltako14bus library](https://github.com/grimmpp/eltako14bus/blob/master/eltakobus/eep.py) in [version 0.0.49](https://pypi.org/project/eltako14bus/) from unit-test `TestSendMessageService` in file `./tests/test_send_message_service.py`). +(This file was auto-generated by using [eltako14bus library](https://github.com/grimmpp/eltako14bus/blob/master/eltakobus/eep.py) in [version 0.0.51](https://pypi.org/project/eltako14bus/) from unit-test `TestSendMessageService` in file `./tests/test_send_message_service.py`). ## Not Supported EEPs * `A5-09-0C` @@ -18,6 +18,8 @@ * `A5-12-02`: data_type, divisor, learn_button, measurement_channel, meter_reading * `A5-12-03`: data_type, divisor, learn_button, measurement_channel, meter_reading * `A5-13-01`: dawn_sensor, day_night, hemisphere, identifier, learn_button, rain_indication, sun_east, sun_south, sun_west, temperature, wind_speed +* `A5-30-01`: battery_status, contact_status, learn_button +* `A5-30-03`: digital_input_0, digital_input_1, digital_input_2, digital_input_3, learn_button, status_of_wake, temperature * `D5-00-01`: contact, learn_button * `F6-02-01`: energy_bow, rocker_first_action, rocker_second_action, second_action * `F6-02-02`: energy_bow, rocker_first_action, rocker_second_action, second_action diff --git a/tests/test_binary_sensor_A5_30_01.py b/tests/test_binary_sensor_A5_30_01.py new file mode 100644 index 00000000..1e0c0e66 --- /dev/null +++ b/tests/test_binary_sensor_A5_30_01.py @@ -0,0 +1,60 @@ +import unittest +from mocks import * +from unittest import mock +from homeassistant.helpers.entity import Entity +from homeassistant.const import Platform +from custom_components.eltako.binary_sensor import EltakoBinarySensor +from custom_components.eltako.config_helpers import * +from eltakobus import * +from eltakobus.eep import * + +from tests.test_binary_sensor_generic import TestBinarySensor + +# 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 TestBinarySensor_A5_30_01(unittest.TestCase): + + def test_digital_input(self): + bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\xFF\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) + + + def test_inverted_digital_input(self): + bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string) + bs.invert_signal = True + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\xFF\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) + + + def test_battery(self): + bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, description_key="low_battery") + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\FF\x92\xFF\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) \ No newline at end of file diff --git a/tests/test_binary_sensor_A5_30_03.py b/tests/test_binary_sensor_A5_30_03.py new file mode 100644 index 00000000..85c5b7f3 --- /dev/null +++ b/tests/test_binary_sensor_A5_30_03.py @@ -0,0 +1,79 @@ +import unittest +from mocks import * +from unittest import mock +from homeassistant.helpers.entity import Entity +from homeassistant.const import Platform +from custom_components.eltako.binary_sensor import EltakoBinarySensor +from custom_components.eltako.config_helpers import * +from eltakobus import * +from eltakobus.eep import * + +from tests.test_binary_sensor_generic import TestBinarySensor + +# 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 TestBinarySensor_A5_30_03(unittest.TestCase): + + def test_digital_input(self): + + for key in ["0", "1", "2", "3", "wake"]: + bs = TestBinarySensor().create_binary_sensor(A5_30_03.eep_string, description_key=key) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x00\x1F\x08') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x00\x00\x08') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) + + + def test_inverted_digital_input(self): + + for key in ["0", "1", "2", "3", "wake"]: + bs = TestBinarySensor().create_binary_sensor(A5_30_03.eep_string, description_key=key) + bs.invert_signal = True + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x00\x1F\x08') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x00\x00\x08') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) + + + def test_battery(self): + bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, description_key="low_battery") + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\FF\x92\xFF\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) + + + def test_inverted_battery(self): + bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, description_key="low_battery") + bs.invert_signal = True + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, True) + + msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\FF\x92\xFF\x0E') + bs.value_changed(msg) + + self.assertEqual(bs.is_on, False) \ No newline at end of file diff --git a/tests/test_binary_sensor_generic.py b/tests/test_binary_sensor_generic.py index dad4aa77..b87289ec 100644 --- a/tests/test_binary_sensor_generic.py +++ b/tests/test_binary_sensor_generic.py @@ -16,14 +16,14 @@ class TestBinarySensor(unittest.TestCase): - def create_binary_sensor(self, eep_string:str="F6-02-01", device_class = "none", invert_signal:bool=False) -> EltakoBinarySensor: + def create_binary_sensor(self, eep_string:str="F6-02-01", device_class = "none", invert_signal:bool=False, description_key:str=None) -> EltakoBinarySensor: gateway = GatewayMock(dev_id=123) dev_id = AddressExpression.parse("00-00-00-01") dev_name = "device name" dev_eep = EEP.find(eep_string) - bs = EltakoBinarySensor(Platform.BINARY_SENSOR, gateway, dev_id, dev_name, dev_eep, device_class, invert_signal) + bs = EltakoBinarySensor(Platform.BINARY_SENSOR, gateway, dev_id, dev_name, dev_eep, device_class, invert_signal, description_key) bs.hass = HassMock() self.assertEqual(bs._attr_is_on, None) diff --git a/tests/test_sensor_A5_04_03.py b/tests/test_sensor_A5_04_03.py index f3ee51d3..0abe03cd 100644 --- a/tests/test_sensor_A5_04_03.py +++ b/tests/test_sensor_A5_04_03.py @@ -15,7 +15,7 @@ class TestSensor_A5_04_02(unittest.TestCase): - msg1 = Regular4BSMessage (address=b'\xFF\xFF\x00\x80', data=b'\x99\x02\x12\x09', status=0x00) + msg1 = Regular4BSMessage(address=b'\xFF\xFF\x00\x80', data=b'\x99\x02\x12\x09', status=0x00) def create_temperature_sensor(self) -> EltakoTemperatureSensor: gateway = GatewayMock()