* Initial sketches of rflink component. * Add requirement. * Properly load configuration. * Bump rflink for graceful parse errors and protocol callback. * Cleanup, documentation and linting. * More documentation, first sensor implementation (temp & hum). * Add brightness/dim support for newkaku protocol. * Use separate class for dimmables. * Make sure non-dimmable newkaku devices are turned on. * Move some code around, add switches. Support loading from config. * Fix bug in ignoring devices. * Fix initial state assumption. * Improve reliability on invalid conditions. * Allow configuration of group for new devices. * Sensor icons. * Fix parsing negative numbers. * Correct icon. * Allow sending commands serial. * Pluralize. * Allow adding sensors from config. * Fix ignoring devices and bugs in previous commit. * Share know devices so devices from configuration don't get added as lights. * Lookup unit from value_key. * Remove debug. * Start implementing event protocol in place of packet protocol. - Added first test suite for sensors. - This currently breaks light and switch. * Refactor switch component to fit new rflink changes. Add test suite. * Fix style. * Refactor and test lights. Bring coverage to 100%. * Use non-broken and production tested rflink module. * Update requirements. * Bump for logging. * Improve readability. * Do not use global variable but keep known device state in intended place. * Improve docs. * Make icon support generic. * Disable overriding icons in config, as it belongs in customization. Only keep custom icon for entities that are able to detect a icon based on the thing they represent (sensors in this case). * Implement configuration schema, overall refactor of magic values. * Fix bug in config/test wait_for_ack. * Small refactors. * Move command logic into separate class. * Convert command sending logic to class based pattern instead of using the event bus. * Start not using bus for rflink event propagation to platforms. * Do not use event bus for all entity types. * Fire an event on the bus for every switch incoming rflink command. * Resolve lint errors, remove some old code. * Known devices no longer need to be registered separately. * Log bus events. * Event callback is a..... callback. * Use full entity id for events. * Move event sending to entity. * Log incoming events. * Make firing events optional inline with rfxtrx. * Add foundation for signal repetition. * Add signal repetition config and tests. * Make plain switchable type explicitly configurable. * Enable default entity settings for automatically added entities as well. * Prevent default configuration leaking accross entities. * Make sure device defaults don't get overwritten by defaults further down. * Don't let fast state switching and repetitions turn your house into a disco. * Make repetitions more responsive. * Disable on/off fallback on dimmables as it currently doesn't play nice with repetitions. * Use rflink that allows send_command_ack to be safely cancelled. * Reduce duplication and make repeat work for non-ack. * Implement reconnection logic. * Improve reconnection logic. * Also cancel repetitions when entity state is changed due to external command. * Update requirements. * Fix linting. * Fix spelling. * Don't lie. * Fix lint. * Support for automatically creating protocol translation (fixes spaces in device names). * Returned support for dimmable and on/off entity. * Duplicate code to fix linting issues with inheritance. * Allow overriding unit of measurement from config.
103 lines
2.7 KiB
Python
103 lines
2.7 KiB
Python
"""Test for RFlink sensor components.
|
|
|
|
Test setup of rflink sensor component/platform. Verify manual and
|
|
automatic sensor creation.
|
|
|
|
"""
|
|
|
|
import asyncio
|
|
|
|
from ..test_rflink import mock_rflink
|
|
|
|
DOMAIN = 'sensor'
|
|
|
|
CONFIG = {
|
|
'rflink': {
|
|
'port': '/dev/ttyABC0',
|
|
'ignore_devices': ['ignore_wildcard_*', 'ignore_sensor'],
|
|
},
|
|
DOMAIN: {
|
|
'platform': 'rflink',
|
|
'devices': {
|
|
'test': {
|
|
'name': 'test',
|
|
'sensor_type': 'temperature',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
@asyncio.coroutine
|
|
def test_default_setup(hass, monkeypatch):
|
|
"""Test all basic functionality of the rflink sensor component."""
|
|
# setup mocking rflink module
|
|
event_callback, create, _, _ = yield from mock_rflink(
|
|
hass, CONFIG, DOMAIN, monkeypatch)
|
|
|
|
# make sure arguments are passed
|
|
assert create.call_args_list[0][1]['ignore']
|
|
|
|
# test default state of sensor loaded from config
|
|
config_sensor = hass.states.get('sensor.test')
|
|
assert config_sensor
|
|
assert config_sensor.state == 'unknown'
|
|
assert config_sensor.attributes['unit_of_measurement'] == '°C'
|
|
|
|
# test event for config sensor
|
|
event_callback({
|
|
'id': 'test',
|
|
'sensor': 'temperature',
|
|
'value': 1,
|
|
'unit': '°C',
|
|
})
|
|
yield from hass.async_block_till_done()
|
|
|
|
assert hass.states.get('sensor.test').state == '1'
|
|
|
|
# test event for new unconfigured sensor
|
|
event_callback({
|
|
'id': 'test2',
|
|
'sensor': 'temperature',
|
|
'value': 0,
|
|
'unit': '°C',
|
|
})
|
|
yield from hass.async_block_till_done()
|
|
|
|
# test state of new sensor
|
|
new_sensor = hass.states.get('sensor.test2')
|
|
assert new_sensor
|
|
assert new_sensor.state == '0'
|
|
assert new_sensor.attributes['unit_of_measurement'] == '°C'
|
|
assert new_sensor.attributes['icon'] == 'mdi:thermometer'
|
|
|
|
|
|
@asyncio.coroutine
|
|
def test_new_sensors_group(hass, monkeypatch):
|
|
"""New devices should be added to configured group."""
|
|
config = {
|
|
'rflink': {
|
|
'port': '/dev/ttyABC0',
|
|
},
|
|
DOMAIN: {
|
|
'platform': 'rflink',
|
|
'new_devices_group': 'new_rflink_sensors',
|
|
},
|
|
}
|
|
|
|
# setup mocking rflink module
|
|
event_callback, _, _, _ = yield from mock_rflink(
|
|
hass, config, DOMAIN, monkeypatch)
|
|
|
|
# test event for new unconfigured sensor
|
|
event_callback({
|
|
'id': 'test',
|
|
'sensor': 'temperature',
|
|
'value': 0,
|
|
'unit': '°C',
|
|
})
|
|
yield from hass.async_block_till_done()
|
|
|
|
# make sure new device is added to correct group
|
|
group = hass.states.get('group.new_rflink_sensors')
|
|
assert group.attributes.get('entity_id') == ('sensor.test',)
|