Skip to content

Commit

Permalink
Added EEPs A5-30-01 and A5-30-03
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed Apr 11, 2024
1 parent f877061 commit 2bbc824
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/service-send-message/eep-params.md
Original file line number Diff line number Diff line change
@@ -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.51](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.52](https://pypi.org/project/eltako14bus/) from unit-test `TestSendMessageService` in file `./tests/test_send_message_service.py`).

## Not Supported EEPs
* `A5-09-0C`
Expand Down
Empty file added tests/__init__.py
Empty file.
12 changes: 6 additions & 6 deletions tests/test_binary_sensor_A5_30_01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from mocks import *
from unittest import mock
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.const import Platform
from custom_components.eltako.binary_sensor import EltakoBinarySensor
from custom_components.eltako.config_helpers import *
Expand All @@ -18,7 +18,7 @@
class TestBinarySensor_A5_30_01(unittest.TestCase):

def test_digital_input(self):
bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string)
bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, EntityDescription(key="0", name="Digital Input") )

msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E')
bs.value_changed(msg)
Expand All @@ -32,7 +32,7 @@ def test_digital_input(self):


def test_inverted_digital_input(self):
bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string)
bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, EntityDescription(key="0", name="Digital Input") )
bs.invert_signal = True

msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E')
Expand All @@ -47,14 +47,14 @@ def test_inverted_digital_input(self):


def test_battery(self):
bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, description_key="low_battery")
bs = TestBinarySensor().create_binary_sensor(A5_30_01.eep_string, EntityDescription(key="low_battery", name="Low Battery") )

msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\x00\x0E')
msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x92\xFF\x0E')
bs.value_changed(msg)

self.assertEqual(bs.is_on, False)

msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\FF\x92\xFF\x0E')
msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\FF\x92\x00\x0E')
bs.value_changed(msg)

self.assertEqual(bs.is_on, True)
36 changes: 4 additions & 32 deletions tests/test_binary_sensor_A5_30_03.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from mocks import *
from unittest import mock
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.const import Platform
from custom_components.eltako.binary_sensor import EltakoBinarySensor
from custom_components.eltako.config_helpers import *
Expand All @@ -20,7 +20,7 @@ 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)
bs = TestBinarySensor().create_binary_sensor(A5_30_03.eep_string, description= EntityDescription(key=key, name=key))

msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x00\x1F\x08')
bs.value_changed(msg)
Expand All @@ -36,7 +36,7 @@ def test_digital_input(self):
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 = TestBinarySensor().create_binary_sensor(A5_30_03.eep_string, description= EntityDescription(key=key, name=key))
bs.invert_signal = True

msg = Regular4BSMessage(b'\00\x00\x00\x01', 0x20, b'\00\x00\x1F\x08')
Expand All @@ -48,32 +48,4 @@ def test_inverted_digital_input(self):
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)

6 changes: 3 additions & 3 deletions tests/test_binary_sensor_generic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from mocks import *
from unittest import mock
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.const import Platform
from custom_components.eltako.binary_sensor import EltakoBinarySensor
from custom_components.eltako.config_helpers import *
Expand All @@ -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, description_key:str=None) -> EltakoBinarySensor:
def create_binary_sensor(self, eep_string:str="F6-02-01", device_class = "none", invert_signal:bool=False, description:EntityDescription=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, description_key)
bs = EltakoBinarySensor(Platform.BINARY_SENSOR, gateway, dev_id, dev_name, dev_eep, device_class, invert_signal, description)
bs.hass = HassMock()
self.assertEqual(bs._attr_is_on, None)

Expand Down

0 comments on commit 2bbc824

Please sign in to comment.