-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from grimmpp/feature-branch
Added EEPs A5-30-01 and A5-30-03
- Loading branch information
Showing
12 changed files
with
210 additions
and
17 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
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
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
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,6 +1,6 @@ | ||
aiocoap | ||
pyserial-asyncio | ||
eltako14bus==0.0.49 | ||
eltako14bus==0.0.52 | ||
enocean==0.60.1 | ||
homeassistant | ||
termcolor | ||
|
Empty file.
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,60 @@ | ||
import unittest | ||
from mocks import * | ||
from unittest import mock | ||
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 * | ||
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, EntityDescription(key="0", name="Digital Input") ) | ||
|
||
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, EntityDescription(key="0", name="Digital Input") ) | ||
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, EntityDescription(key="low_battery", name="Low Battery") ) | ||
|
||
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\x00\x0E') | ||
bs.value_changed(msg) | ||
|
||
self.assertEqual(bs.is_on, True) |
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,51 @@ | ||
import unittest | ||
from mocks import * | ||
from unittest import mock | ||
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 * | ||
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= EntityDescription(key=key, name=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= EntityDescription(key=key, name=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) | ||
|
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