-
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.
- Loading branch information
Showing
8 changed files
with
104 additions
and
6 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 |
---|---|---|
@@ -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) |
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,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) | ||
|
||
|
||
|