From 66d77dbffe48c3a2b7097f5bb7c69f5b3efc3de4 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 5 Apr 2021 01:32:10 +0200 Subject: [PATCH 1/9] Fix link --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 1fb9c61..c0a2dfe 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,7 @@ The developers of `hass-cli` usually provide up-to-date `packages `_. +The community is providing support for macOS through `homebew `_. .. code:: bash From a50b9e06d4e8b0275f7ade6479fc911951561185 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 5 Apr 2021 01:57:03 +0200 Subject: [PATCH 2/9] master to dev (#360) * Update name * Fix README * Disable one test --- tests/test_defaults.py | 2 +- tests/test_raw.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_defaults.py b/tests/test_defaults.py index 4a2b91a..34d3750 100644 --- a/tests/test_defaults.py +++ b/tests/test_defaults.py @@ -8,7 +8,7 @@ import homeassistant_cli.cli as cli -HASSIO_SERVER_FALLBACK = "http://hassio/homeassistant" +HASSIO_SERVER_FALLBACK = "http://homeassistant:8123" HASS_SERVER = "http://localhost:8123" diff --git a/tests/test_raw.py b/tests/test_raw.py index 35c37ff..f75d70f 100644 --- a/tests/test_raw.py +++ b/tests/test_raw.py @@ -63,18 +63,18 @@ def test_apimethod_completion(default_services) -> None: assert "/api/discovery_info" in resultdict -def test_wsapimethod_completion(default_services) -> None: - """Test completion for raw ws API methods.""" - cfg = Configuration() +# def test_wsapimethod_completion(default_services) -> None: +# """Test completion for raw ws API methods.""" +# cfg = Configuration() - result = autocompletion.wsapi_methods( - cfg, ["raw", "get"], "config/device_registry/l" - ) - assert len(result) == 1 +# result = autocompletion.wsapi_methods( +# cfg, ["raw", "get"], "config/device_registry/l" +# ) +# assert len(result) == 1 - resultdict = dict(result) +# resultdict = dict(result) - assert "config/device_registry/list" in resultdict +# assert "config/device_registry/list" in resultdict def test_raw_ws() -> None: From 5e346afc57ae7cb92bdc2b6cb34169938d6d9c31 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 5 Apr 2021 01:59:50 +0200 Subject: [PATCH 3/9] Set to dev release --- homeassistant_cli/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant_cli/const.py b/homeassistant_cli/const.py index ff75f9f..17c408e 100644 --- a/homeassistant_cli/const.py +++ b/homeassistant_cli/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant CLI (hass-cli).""" PACKAGE_NAME = 'homeassistant_cli' -__version__ = '0.9.2' +__version__ = '0.10.0.dev0' AUTO_SERVER = 'auto' DEFAULT_SERVER = 'http://localhost:8123' From 7cd5694395993e9d6821b547ff06d9fd6f3f87ea Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 6 Apr 2021 00:04:49 +0200 Subject: [PATCH 4/9] Update warning (#361) --- homeassistant_cli/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant_cli/config.py b/homeassistant_cli/config.py index 747a7be..8aa5c9b 100644 --- a/homeassistant_cli/config.py +++ b/homeassistant_cli/config.py @@ -53,7 +53,7 @@ def _locate_ha() -> Optional[str]: if listener.services: if len(listener.services) > 1: _LOGGING.warning( - "Found multiple Home Assistants at %s", + "Found multiple Home Assistant instances at %s", ", ".join(listener.services), ) _LOGGING.warning("Use --server to explicitly specify one.") @@ -152,7 +152,7 @@ def __repr__(self) -> str: "verbose": self.verbose, } - return " str: """Return resolved server (after resolving if needed).""" From 272cbb05855c8a266f8e9363d125d974e907c3aa Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 6 Apr 2021 00:07:50 +0200 Subject: [PATCH 5/9] Use MDNS default (#362) * Use default MDNS setting * Update variable name --- homeassistant_cli/config.py | 2 +- homeassistant_cli/const.py | 2 +- tests/test_defaults.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant_cli/config.py b/homeassistant_cli/config.py index 8aa5c9b..d7e6306 100644 --- a/homeassistant_cli/config.py +++ b/homeassistant_cli/config.py @@ -85,7 +85,7 @@ def resolve_server(ctx: Any) -> str: # noqa: F821 if ctx.server == "auto": if "HASSIO_TOKEN" in os.environ and "HASS_TOKEN" not in os.environ: - ctx.resolved_server = const.DEFAULT_HASSIO_SERVER + ctx.resolved_server = const.DEFAULT_SERVER_MDNS else: if not ctx.resolved_server and "pytest" in sys.modules: ctx.resolved_server = const.DEFAULT_SERVER diff --git a/homeassistant_cli/const.py b/homeassistant_cli/const.py index 17c408e..0661e1e 100644 --- a/homeassistant_cli/const.py +++ b/homeassistant_cli/const.py @@ -5,7 +5,7 @@ AUTO_SERVER = 'auto' DEFAULT_SERVER = 'http://localhost:8123' -DEFAULT_HASSIO_SERVER = 'http://homeassistant:8123' +DEFAULT_SERVER_MDNS = 'http://homeassistant.local:8123' DEFAULT_TIMEOUT = 5 DEFAULT_OUTPUT = 'json' # TODO: Have default be human table relevant output diff --git a/tests/test_defaults.py b/tests/test_defaults.py index 34d3750..eeba6cc 100644 --- a/tests/test_defaults.py +++ b/tests/test_defaults.py @@ -8,7 +8,7 @@ import homeassistant_cli.cli as cli -HASSIO_SERVER_FALLBACK = "http://homeassistant:8123" +MDNS_SERVER_FALLBACK = "http://homeassistant.local:8123" HASS_SERVER = "http://localhost:8123" @@ -28,7 +28,7 @@ "If only HASSIO_TOKEN, use default hassio", {'HASSIO_TOKEN': 'supersecret'}, 'auto', - HASSIO_SERVER_FALLBACK, + MDNS_SERVER_FALLBACK, "supersecret", None, ), From 7c060485f9a9ed4f71885888986a05ba0f0645c1 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 6 Apr 2021 00:31:15 +0200 Subject: [PATCH 6/9] Re-add accidentally removed constants (#363) --- homeassistant_cli/hassconst.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/homeassistant_cli/hassconst.py b/homeassistant_cli/hassconst.py index da27de1..ef3fae9 100644 --- a/homeassistant_cli/hassconst.py +++ b/homeassistant_cli/hassconst.py @@ -3,6 +3,22 @@ Copy of recent homeassistant.const to make hass-cli run without installing Home Assistant itself. """ +# Home Assistant WS constants + +# Websocket API +WS_TYPE_DEVICE_REGISTRY_LIST = "config/device_registry/list" +WS_TYPE_AREA_REGISTRY_LIST = "config/area_registry/list" +WS_TYPE_AREA_REGISTRY_CREATE = "config/area_registry/create" +WS_TYPE_AREA_REGISTRY_DELETE = "config/area_registry/delete" +WS_TYPE_AREA_REGISTRY_UPDATE = "config/area_registry/update" +WS_TYPE_DEVICE_REGISTRY_UPDATE = "config/device_registry/update" +WS_TYPE_ENTITY_REGISTRY_LIST = "config/entity_registry/list" +WS_TYPE_ENTITY_REGISTRY_GET = "config/entity_registry/get" +WS_TYPE_ENTITY_REGISTRY_UPDATE = "config/entity_registry/update" +WS_TYPE_ENTITY_REGISTRY_REGISTRY = "config/entity_registry/remove" + +############################################################################### +# Home Assistant constants # Format for platform files PLATFORM_FORMAT = "{platform}.{domain}" From 6e5ae55fc0b01e1c13de569661d896585d362b25 Mon Sep 17 00:00:00 2001 From: David Radcliffe Date: Mon, 5 Apr 2021 18:33:50 -0400 Subject: [PATCH 7/9] show area name instead of id on device list (#346) * fix variable typo * show area name instead of id on device list --- homeassistant_cli/plugins/area.py | 6 +++--- homeassistant_cli/plugins/device.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/homeassistant_cli/plugins/area.py b/homeassistant_cli/plugins/area.py index 77ba5d2..881a5c9 100644 --- a/homeassistant_cli/plugins/area.py +++ b/homeassistant_cli/plugins/area.py @@ -37,9 +37,9 @@ def listcmd(ctx: Configuration, areafilter: str): else: areafilterre = re.compile(areafilter) # type: Pattern - for device in areas: - if areafilterre.search(device['name']): - result.append(device) + for area in areas: + if areafilterre.search(area['name']): + result.append(area) cols = [('ID', 'area_id'), ('NAME', 'name')] diff --git a/homeassistant_cli/plugins/device.py b/homeassistant_cli/plugins/device.py index 8291c54..cd5a2bd 100644 --- a/homeassistant_cli/plugins/device.py +++ b/homeassistant_cli/plugins/device.py @@ -28,6 +28,8 @@ def listcmd(ctx: Configuration, devicefilter: str): """List all devices from Home Assistant.""" ctx.auto_output("table") + areas = api.get_areas(ctx) + devices = api.get_devices(ctx) result = [] # type: List[Dict] @@ -40,12 +42,19 @@ def listcmd(ctx: Configuration, devicefilter: str): if devicefilterre.search(device['name']): result.append(device) + for device in devices: + area = next( + (a for a in areas if a['area_id'] == device['area_id']), None + ) + if area: + device['area_name'] = area['name'] + cols = [ ('ID', 'id'), ('NAME', 'name'), ('MODEL', 'model'), ('MANUFACTURER', 'manufacturer'), - ('AREA', 'area_id'), + ('AREA', 'area_name'), ] ctx.echo( From 31cf99bd130ef1ecec56dbeb04be1980a3dac465 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 6 Apr 2021 12:41:12 +0200 Subject: [PATCH 8/9] Update fixture for device (#364) * Enable test again * Make test size smaller and add area --- tests/fixtures/default_devices.json | 267 ++-------------------------- tests/test_device.py | 55 +++--- tests/test_raw.py | 18 +- 3 files changed, 58 insertions(+), 282 deletions(-) diff --git a/tests/fixtures/default_devices.json b/tests/fixtures/default_devices.json index 91ec968..031b1f7 100644 --- a/tests/fixtures/default_devices.json +++ b/tests/fixtures/default_devices.json @@ -10,7 +10,8 @@ "sw_version": null, "id": "fa56ea5934f44fa19161bbf2a3d33732", "hub_device_id": null, - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [], @@ -21,40 +22,20 @@ "sw_version": "5.105.0.21536", "id": "b6f1087b94c84bc8bbe2a01adbd014d8", "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [], - "connections": [], - "manufacturer": "Philips", - "model": "Hue color lamp", - "name": "Kitchen table right", - "sw_version": "5.105.0.21536", - "id": "921ac3ce2d7948e98ceabdecc295e742", - "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [], "connections": [], "manufacturer": "Philips", "model": "Hue color spot", - "name": "Kitchen left middle at window", - "sw_version": "5.105.0.21536", - "id": "1eaf5f51bf464a80b4c17a4f1fad1d8f", - "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [], - "connections": [], - "manufacturer": "Philips", - "model": "Hue color spot", - "name": "Kitchen front right at fridge", + "name": "Kitchen front right at table", "sw_version": "5.105.0.21536", "id": "c022c2a832194a9aadbc40d39e7d5ee7", "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [], @@ -65,7 +46,8 @@ "sw_version": "5.105.0.21536", "id": "cabab7fdfc97462f959aec7434989c82", "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [], @@ -76,7 +58,8 @@ "sw_version": "5.105.0.21536", "id": "a5ffc6e863b1478d8f91b414014138d9", "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [], @@ -87,7 +70,8 @@ "sw_version": "5.105.0.21536", "id": "63b899e6357d43879a7f356b31c233ae", "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [], @@ -98,7 +82,8 @@ "sw_version": "5.105.0.21536", "id": "43e5a30659cd4837b7ecaa5447d8be67", "hub_device_id": "3e2f3eaccc0a4dedbbc86c32275e6249", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [ @@ -116,7 +101,8 @@ "sw_version": "5.105.0.21536", "id": "f9cad07069c74d519fbe84811c91f1fb", "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" }, { "config_entries": [ @@ -134,222 +120,7 @@ "sw_version": "5.105.0.21536", "id": "d02ec64623ae4407a80b903cbc061511", "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:00:f0:b2:f1" - ] - ], - "manufacturer": "Philips", - "model": "LCT003", - "name": "Kitchen Light 1", - "sw_version": "5.105.0.21536", - "id": "820c9e511fce42ea92b228c18710aa56", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:00:f0:ac:69" - ] - ], - "manufacturer": "Philips", - "model": "LCT003", - "name": "Kitchen Light 5", - "sw_version": "5.105.0.21536", - "id": "417dd42c0c764765aa29580d77b8b7ad", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:10:4b:e9:a8" - ] - ], - "manufacturer": "Philips", - "model": "LCT007", - "name": "Kitchen Table Light 1", - "sw_version": "5.105.0.21536", - "id": "d379711d01fc47d6aef5b85bd81acba4", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:10:5d:b9:8f" - ] - ], - "manufacturer": "Philips", - "model": "LCT007", - "name": "Kitchen Table Light 2", - "sw_version": "5.105.0.21536", - "id": "a3229ac663734c2cb67c7b13c8a2ba0f", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:00:f0:aa:eb" - ] - ], - "manufacturer": "Philips", - "model": "LCT003", - "name": "Kitchen Light 6", - "sw_version": "5.105.0.21536", - "id": "e20132e0f90942298bdae2340e61c079", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:00:f0:ad:cf" - ] - ], - "manufacturer": "Philips", - "model": "LCT003", - "name": "Kitchen Light 4", - "sw_version": "5.105.0.21536", - "id": "9dd4074e35e546ed8d1a4e630fe07926", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:02:01:1c:f9" - ] - ], - "manufacturer": "Philips", - "model": "SML001", - "name": "Kitchen Motion", - "sw_version": "6.1.0.18912", - "id": "ae8b84e99dbf4a9e94072a1588f29298", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:10:3e:30:37" - ] - ], - "manufacturer": "Philips", - "model": "RWL021", - "name": "Kitchen Switch", - "sw_version": "5.45.1.16265", - "id": "ed7a661b309e4f0093f440b327fb0fd4", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:17:88:01:10:32:d3:74" - ] - ], - "manufacturer": "Philips", - "model": "RWL021", - "name": "Kitchen Cupboard Switch", - "sw_version": "5.45.1.16265", - "id": "2fa6cccbebab476d8e6899899df34b38", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:15:8d:00:02:75:0d:4b" - ] - ], - "manufacturer": "LUMI", - "model": "lumi.sensor_magnet.aq2", - "name": "Kitchen Terrace Door", - "sw_version": "20161128", - "id": "4110ac63ee4f4b9a804fe63f372bb601", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:0b:57:ff:fe:e8:89:2a" - ] - ], - "manufacturer": "IKEA of Sweden", - "model": "TRADFRI transformer 30W", - "name": "Kitchen Cupboard Light 2", - "sw_version": "1.2.245", - "id": "f231511fa73c4634b4236f4b46e2f547", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" - }, - { - "config_entries": [ - "1a64b7d520ad44fab8622bc4efb64e88" - ], - "connections": [ - [ - "zigbee", - "00:0b:57:ff:fe:e8:a5:da" - ] - ], - "manufacturer": "IKEA of Sweden", - "model": "TRADFRI transformer 30W", - "name": "Kitchen Cupboard Light 1", - "sw_version": "1.2.245", - "id": "4168666fad43443d807398d3e407a36b", - "hub_device_id": "ff7da1f735c14b2f865b33615e359474", - "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584" + "area_id": "e6ebd3e6f6e04b63a0e4a109b4748584", + "area_name": "Bedroom" } ] diff --git a/tests/test_device.py b/tests/test_device.py index c38e695..3cc63c2 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -8,42 +8,48 @@ import homeassistant_cli.cli as cli -def test_device_list(default_devices) -> None: +def test_device_list(default_devices, default_areas) -> None: """Test Device List.""" with mock.patch( 'homeassistant_cli.remote.get_devices', return_value=default_devices ): + with mock.patch( + 'homeassistant_cli.remote.get_areas', return_value=default_areas + ): - runner = CliRunner() - result = runner.invoke( - cli.cli, - ["--output=json", "device", "list"], - catch_exceptions=False, - ) - assert result.exit_code == 0 + runner = CliRunner() + result = runner.invoke( + cli.cli, + ["--output=json", "device", "list"], + catch_exceptions=False, + ) + assert result.exit_code == 0 - data = json.loads(result.output) - assert len(data) == 23 + data = json.loads(result.output) + assert len(data) == 9 -def test_device_list_filter(default_devices) -> None: +def test_device_list_filter(default_devices, default_areas) -> None: """Test Device List.""" with mock.patch( 'homeassistant_cli.remote.get_devices', return_value=default_devices ): + with mock.patch( + 'homeassistant_cli.remote.get_areas', return_value=default_areas + ): - runner = CliRunner() - result = runner.invoke( - cli.cli, - ["--output=json", "device", "list", "table"], - catch_exceptions=False, - ) - assert result.exit_code == 0 + runner = CliRunner() + result = runner.invoke( + cli.cli, + ["--output=json", "device", "list", "table"], + catch_exceptions=False, + ) + assert result.exit_code == 0 - data = json.loads(result.output) - assert len(data) == 2 - assert data[0]['name'] == "Kitchen table left" - assert data[1]['name'] == "Kitchen table right" + data = json.loads(result.output) + assert len(data) == 2 + assert data[0]['name'] == "Kitchen table left" + assert data[1]['name'] == "Kitchen front right at table" def test_device_assign(default_areas, default_devices) -> None: @@ -65,10 +71,9 @@ def test_device_assign(default_areas, default_devices) -> None: ["device", "assign", "Kitchen", "Kitchen table left"], catch_exceptions=False, ) - print(result.output) + # print(result.output) assert result.exit_code == 0 expected = ( - "Successfully assigned 'Kitchen'" - " to 'Kitchen table left'\n" + "Successfully assigned 'Kitchen' to 'Kitchen table left'\n" ) assert result.output == expected diff --git a/tests/test_raw.py b/tests/test_raw.py index f75d70f..35c37ff 100644 --- a/tests/test_raw.py +++ b/tests/test_raw.py @@ -63,18 +63,18 @@ def test_apimethod_completion(default_services) -> None: assert "/api/discovery_info" in resultdict -# def test_wsapimethod_completion(default_services) -> None: -# """Test completion for raw ws API methods.""" -# cfg = Configuration() +def test_wsapimethod_completion(default_services) -> None: + """Test completion for raw ws API methods.""" + cfg = Configuration() -# result = autocompletion.wsapi_methods( -# cfg, ["raw", "get"], "config/device_registry/l" -# ) -# assert len(result) == 1 + result = autocompletion.wsapi_methods( + cfg, ["raw", "get"], "config/device_registry/l" + ) + assert len(result) == 1 -# resultdict = dict(result) + resultdict = dict(result) -# assert "config/device_registry/list" in resultdict + assert "config/device_registry/list" in resultdict def test_raw_ws() -> None: From 95a0e6004b6922655724641395c792c09dbb98ef Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 6 Apr 2021 13:48:17 +0200 Subject: [PATCH 9/9] Prepare for 0.9.3 --- homeassistant_cli/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant_cli/const.py b/homeassistant_cli/const.py index 0661e1e..96cda55 100644 --- a/homeassistant_cli/const.py +++ b/homeassistant_cli/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant CLI (hass-cli).""" PACKAGE_NAME = 'homeassistant_cli' -__version__ = '0.10.0.dev0' +__version__ = '0.9.3' AUTO_SERVER = 'auto' DEFAULT_SERVER = 'http://localhost:8123'