Fix Home Assistant catalog QML compatibility
This commit is contained in:
@@ -42,7 +42,11 @@ Singleton {
|
||||
}
|
||||
|
||||
if (result.ok === true) {
|
||||
root.entities = Array.isArray(result.entities) ? result.entities : [];
|
||||
root.entities = Array.isArray(result.entities)
|
||||
? result.entities.map(entity => Object.assign({}, entity, {
|
||||
name: entity.sourceName, domain: "light"
|
||||
}))
|
||||
: [];
|
||||
root.phase = "ready";
|
||||
root.stale = false;
|
||||
root.lastError = "";
|
||||
|
||||
@@ -255,6 +255,12 @@ class HomeAssistantBridgeTest(unittest.TestCase):
|
||||
def test_qml_refreshes_through_the_catalog_command(self) -> None:
|
||||
self.assertIn('command: [root.helperPath, "catalog"]', QML_SERVICE.read_text())
|
||||
|
||||
def test_qml_adapts_catalog_entities_for_legacy_consumers(self) -> None:
|
||||
source = QML_SERVICE.read_text()
|
||||
|
||||
self.assertIn("result.entities.map(entity => Object.assign({}, entity, {", source)
|
||||
self.assertIn('name: entity.sourceName, domain: "light"', source)
|
||||
|
||||
def test_authentication_error_is_redacted(self) -> None:
|
||||
self.assertEqual(
|
||||
bridge.public_http_error(401, "sensitive response"),
|
||||
|
||||
Reference in New Issue
Block a user