-
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 #89 from grimmpp/feature-branch
added test + bug fixes
- Loading branch information
Showing
11 changed files
with
167 additions
and
23 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,28 @@ | ||
# Paramters for EEPs in Send Message Events | ||
## Not Supported EEPs | ||
* A5-09-0C | ||
* A5-38-08 | ||
|
||
## Parameters for events: | ||
* A5-04-01: humidity, learn_button, temp_availability, temperature | ||
* A5-04-02: humidity, learn_button, temperature | ||
* A5-04-03: humidity, learn_button, telegram_type, temperature | ||
* A5-06-01: day_light, illumination, twilight | ||
* A5-07-01: learn_button, pir_status, pir_status_on, support_volrage_availability, support_voltage | ||
* A5-08-01: illumination, learn_button, occupancy_button, pir_status, supply_voltage, temperature | ||
* A5-10-06: current_temp, mode, stand_by, target_temp | ||
* A5-10-12: current_temperature, humidity, target_temperature | ||
* A5-12-01: data_type, divisor, learn_button, measurement_channel, meter_reading | ||
* 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 | ||
* 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 | ||
* F6-10-00: handle_position, movement | ||
* G5-3F-7F: direction, state, time | ||
* H5-3F-7F: command, learn_button, time | ||
* M5-38-08: state | ||
|
||
## References: | ||
Implementation of EEPs can be found [eltako14bus library](https://github.com/grimmpp/eltako14bus/blob/master/eltakobus/eep.py). |
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,77 @@ | ||
import unittest | ||
from mocks import * | ||
from unittest import mock | ||
from homeassistant.helpers import dispatcher | ||
import inspect | ||
|
||
dispatcher.dispatcher_send = mock.Mock(return_value=None) | ||
|
||
class TestSendMessageService(unittest.IsolatedAsyncioTestCase): | ||
|
||
def create_gateway(self): | ||
gateway = GatewayMock(dev_id=123) | ||
|
||
return gateway | ||
|
||
def get_all_eep_names(self): | ||
subclasses = set() | ||
work = [EEP] | ||
while work: | ||
parent = work.pop() | ||
for child in parent.__subclasses__(): | ||
if child not in subclasses: | ||
subclasses.add(child) | ||
work.append(child) | ||
return sorted(set([s.__name__.upper().replace('_','-') for s in subclasses if len(s.__name__) == 8 and s.__name__.count('_') == 2])) | ||
|
||
NOT_SUPPORTED_EEPS = ['A5-09-0C', 'A5-38-08'] | ||
|
||
async def test_send_message(self): | ||
g = self.create_gateway() | ||
# Mock send_message | ||
g.send_message = lambda *args: None | ||
|
||
for eep_name in self.get_all_eep_names(): | ||
|
||
if eep_name in self.NOT_SUPPORTED_EEPS: | ||
continue | ||
|
||
event = EventMock('service_name', { | ||
'id': 'FF-DD-CC-BB', | ||
'eep': eep_name, | ||
'command': 1, | ||
'identifier': 1 | ||
}) | ||
|
||
await g.async_service_send_message(event, True) | ||
|
||
|
||
async def test_write_eep_params_to_docs_file(self): | ||
text = '# Paramters for EEPs in Send Message Events' | ||
text += '\n' | ||
|
||
text += "## Not Supported EEPs \n" | ||
for eep_name in self.NOT_SUPPORTED_EEPS: | ||
text += f"* {eep_name}\n" | ||
text += '\n' | ||
|
||
text += '## Parameters for events: \n' | ||
|
||
for eep_name in self.get_all_eep_names(): | ||
|
||
if eep_name in self.NOT_SUPPORTED_EEPS: | ||
continue | ||
|
||
sig = inspect.signature(EEP.find(eep_name).__init__) | ||
eep_init_args = sorted([param.name for param in sig.parameters.values() if param.kind == param.POSITIONAL_OR_KEYWORD and param.name != 'self']) | ||
text += f"* {eep_name}: {', '.join(eep_init_args)}\n" | ||
|
||
text += '\n' | ||
text += '## References:\n' | ||
text += 'Implementation of EEPs can be found [eltako14bus library](https://github.com/grimmpp/eltako14bus/blob/master/eltakobus/eep.py).\n' | ||
|
||
file='./docs/service-send-message/eep-params.md' | ||
with open(file, 'w') as filetowrite: | ||
filetowrite.write(text) | ||
|
||
|