async def test_config_schema(hass): """Test that config schema is imported properly.""" config = { konnected.DOMAIN: { konnected.CONF_API_HOST: "http://1.1.1.1:8888", konnected.CONF_ACCESS_TOKEN: "abcdefgh", konnected.CONF_DEVICES: [{ konnected.CONF_ID: "aabbccddeeff" }], } } assert konnected.CONFIG_SCHEMA(config) == { "konnected": { "access_token": "abcdefgh", "api_host": "http://1.1.1.1:8888", "devices": [{ "default_options": { "blink": True, "api_host": "http://1.1.1.1:8888", "discovery": True, "io": { "1": "Disabled", "10": "Disabled", "11": "Disabled", "12": "Disabled", "2": "Disabled", "3": "Disabled", "4": "Disabled", "5": "Disabled", "6": "Disabled", "7": "Disabled", "8": "Disabled", "9": "Disabled", "alarm1": "Disabled", "alarm2_out2": "Disabled", "out": "Disabled", "out1": "Disabled", }, }, "id": "aabbccddeeff", }], } } # check with host info config = { konnected.DOMAIN: { konnected.CONF_ACCESS_TOKEN: "abcdefgh", konnected.CONF_DEVICES: [{ konnected.CONF_ID: "aabbccddeeff", "host": "192.168.1.1", "port": 1234 }], } } assert konnected.CONFIG_SCHEMA(config) == { "konnected": { "access_token": "abcdefgh", "devices": [{ "default_options": { "blink": True, "api_host": "", "discovery": True, "io": { "1": "Disabled", "10": "Disabled", "11": "Disabled", "12": "Disabled", "2": "Disabled", "3": "Disabled", "4": "Disabled", "5": "Disabled", "6": "Disabled", "7": "Disabled", "8": "Disabled", "9": "Disabled", "alarm1": "Disabled", "alarm2_out2": "Disabled", "out": "Disabled", "out1": "Disabled", }, }, "id": "aabbccddeeff", "host": "192.168.1.1", "port": 1234, }], } } # check pin to zone and multiple output config = { konnected.DOMAIN: { konnected.CONF_ACCESS_TOKEN: "abcdefgh", konnected.CONF_DEVICES: [{ konnected.CONF_ID: "aabbccddeeff", "binary_sensors": [ { "pin": 2, "type": "door" }, { "zone": 1, "type": "door" }, ], "switches": [ { "zone": 3, "name": "Beep Beep", "momentary": 65, "pause": 55, "repeat": 4, }, { "zone": 3, "name": "Warning", "momentary": 100, "pause": 100, "repeat": -1, }, ], }], } } assert konnected.CONFIG_SCHEMA(config) == { "konnected": { "access_token": "abcdefgh", "devices": [{ "default_options": { "blink": True, "api_host": "", "discovery": True, "io": { "1": "Binary Sensor", "10": "Disabled", "11": "Disabled", "12": "Disabled", "2": "Binary Sensor", "3": "Switchable Output", "4": "Disabled", "5": "Disabled", "6": "Disabled", "7": "Disabled", "8": "Disabled", "9": "Disabled", "alarm1": "Disabled", "alarm2_out2": "Disabled", "out": "Disabled", "out1": "Disabled", }, "binary_sensors": [ { "inverse": False, "type": "door", "zone": "2" }, { "inverse": False, "type": "door", "zone": "1" }, ], "switches": [ { "zone": "3", "activation": "high", "name": "Beep Beep", "momentary": 65, "pause": 55, "repeat": 4, }, { "zone": "3", "activation": "high", "name": "Warning", "momentary": 100, "pause": 100, "repeat": -1, }, ], }, "id": "aabbccddeeff", }], } }
async def test_config_schema(hass): """Test that config schema is imported properly.""" config = { konnected.DOMAIN: { konnected.CONF_ACCESS_TOKEN: "abcdefgh", konnected.CONF_DEVICES: [{ konnected.CONF_ID: "aabbccddeeff" }], } } assert konnected.CONFIG_SCHEMA(config) == { "konnected": { "access_token": "abcdefgh", "devices": [{ "default_options": { "blink": True, "discovery": True, "io": { "1": "Disabled", "10": "Disabled", "11": "Disabled", "12": "Disabled", "2": "Disabled", "3": "Disabled", "4": "Disabled", "5": "Disabled", "6": "Disabled", "7": "Disabled", "8": "Disabled", "9": "Disabled", "alarm1": "Disabled", "alarm2_out2": "Disabled", "out": "Disabled", "out1": "Disabled", }, }, "id": "aabbccddeeff", }], } } # check with host info config = { konnected.DOMAIN: { konnected.CONF_ACCESS_TOKEN: "abcdefgh", konnected.CONF_DEVICES: [{ konnected.CONF_ID: "aabbccddeeff", "host": "192.168.1.1", "port": 1234 }], } } assert konnected.CONFIG_SCHEMA(config) == { "konnected": { "access_token": "abcdefgh", "devices": [{ "default_options": { "blink": True, "discovery": True, "io": { "1": "Disabled", "10": "Disabled", "11": "Disabled", "12": "Disabled", "2": "Disabled", "3": "Disabled", "4": "Disabled", "5": "Disabled", "6": "Disabled", "7": "Disabled", "8": "Disabled", "9": "Disabled", "alarm1": "Disabled", "alarm2_out2": "Disabled", "out": "Disabled", "out1": "Disabled", }, }, "id": "aabbccddeeff", "host": "192.168.1.1", "port": 1234, }], } } # check pin to zone config = { konnected.DOMAIN: { konnected.CONF_ACCESS_TOKEN: "abcdefgh", konnected.CONF_DEVICES: [{ konnected.CONF_ID: "aabbccddeeff", "binary_sensors": [ { "pin": 2, "type": "door" }, { "zone": 1, "type": "door" }, ], }], } } assert konnected.CONFIG_SCHEMA(config) == { "konnected": { "access_token": "abcdefgh", "devices": [{ "default_options": { "blink": True, "discovery": True, "io": { "1": "Binary Sensor", "10": "Disabled", "11": "Disabled", "12": "Disabled", "2": "Binary Sensor", "3": "Disabled", "4": "Disabled", "5": "Disabled", "6": "Disabled", "7": "Disabled", "8": "Disabled", "9": "Disabled", "alarm1": "Disabled", "alarm2_out2": "Disabled", "out": "Disabled", "out1": "Disabled", }, "binary_sensors": [ { "inverse": False, "type": "door", "zone": "2" }, { "inverse": False, "type": "door", "zone": "1" }, ], }, "id": "aabbccddeeff", }], } }