hass-core/tests/components/switchbee/__init__.py
jafar-atili 24266f1426
Add SwitchBee Integration ()
* Add SwitchBee Integration

* fixes

* improved API and more logs

* fixed test_config_flow code

* removed light and cover

* Fixed CR comments, updated pylib, improved response time and lowered the scan interval for lower latency

* CR fixes, added advanced setup form to let the
user choose the following:
    - scan interval in seconds: default 5
    - whether to expose scenarios and group switches from the CU or not

* used SCAN_INTERVAL_SEC instead of typing just the number

* Fixed PR comments, added unit tests

* fixes

* Improved the pypi and updated the code accordingly

* Add SwitchBee Integration

* fixes

* improved API and more logs

* fixed test_config_flow code

* removed light and cover

* Fixed CR comments, updated pylib, improved response time and lowered the scan interval for lower latency

* CR fixes, added advanced setup form to let the
user choose the following:
    - scan interval in seconds: default 5
    - whether to expose scenarios and group switches from the CU or not

* used SCAN_INTERVAL_SEC instead of typing just the number

* Fixed PR comments, added unit tests

* fixes

* Improved the pypi and updated the code accordingly

* fixes

* restored new line in .coveragerc

* test: increased config_flow test coverage

* removed two way type

* Updated CODEOWNERS

* fix: code review comments

* fixed review comments

* added device_info

* moved device info to attribute
2022-09-13 09:01:29 +02:00

141 lines
4.6 KiB
Python

"""Tests for the SwitchBee Smart Home integration."""
MOCK_GET_CONFIGURATION = {
"status": "OK",
"data": {
"mac": "A8-21-08-E7-67-B6",
"name": "Residence",
"version": "1.4.4(4)",
"lastConfChange": 1661856874511,
"zones": [
{
"name": "Sensor Setting",
"items": [
{
"id": 200000,
"name": "home",
"hw": "VIRTUAL",
"type": "ALARM_SYSTEM",
},
{
"id": 200010,
"name": "away",
"hw": "VIRTUAL",
"type": "ALARM_SYSTEM",
},
],
},
{
"name": "General",
"items": [
{
"operations": [113],
"id": 100080,
"name": "All Lights",
"hw": "VIRTUAL",
"type": "GROUP_SWITCH",
},
{
"operations": [
{"itemId": 21, "value": 100},
{"itemId": 333, "value": 100},
],
"id": 100160,
"name": "Sunrise",
"hw": "VIRTUAL",
"type": "SCENARIO",
},
],
},
{
"name": "Entrance",
"items": [
{
"id": 113,
"name": "Staircase Lights",
"hw": "DIMMABLE_SWITCH",
"type": "TIMED_SWITCH",
},
{
"id": 222,
"name": "Front Door",
"hw": "REGULAR_SWITCH",
"type": "TIMED_SWITCH",
},
],
},
{
"name": "Kitchen",
"items": [
{"id": 21, "name": "Shutter ", "hw": "SHUTTER", "type": "SHUTTER"},
{
"operations": [593, 581, 171],
"id": 481,
"name": "Leds",
"hw": "DIMMABLE_SWITCH",
"type": "GROUP_SWITCH",
},
{
"id": 12,
"name": "Walls",
"hw": "DIMMABLE_SWITCH",
"type": "DIMMER",
},
],
},
{
"name": "Two Way Zone",
"items": [
{
"operations": [113],
"id": 72,
"name": "Staircase Lights",
"hw": "DIMMABLE_SWITCH",
"type": "TWO_WAY",
}
],
},
{
"name": "Facilities ",
"items": [
{
"id": 321,
"name": "Boiler",
"hw": "TIMED_POWER_SWITCH",
"type": "TIMED_POWER",
},
{
"modes": ["COOL", "HEAT", "FAN"],
"temperatureUnits": "CELSIUS",
"id": 271,
"name": "HVAC",
"hw": "THERMOSTAT",
"type": "THERMOSTAT",
},
{
"id": 571,
"name": "Repeater",
"hw": "REPEATER",
"type": "REPEATER",
},
],
},
{
"name": "Alarm",
"items": [
{
"operations": [{"itemId": 113, "value": 100}],
"id": 81,
"name": "Open Home",
"hw": "STIKER_SWITCH",
"type": "SCENARIO",
}
],
},
],
},
}
MOCK_FAILED_TO_LOGIN_MSG = (
"Central Unit replied with failure: {'status': 'LOGIN_FAILED'}"
)
MOCK_INVALID_TOKEN_MGS = "Error fetching switchbee data: Error communicating with API: data Request failed due to INVALID_TOKEN, trying to re-login"