diff --git a/src/components/nodes-table/HomeAssistant.vue b/src/components/nodes-table/HomeAssistant.vue
index 51cbad61eb9..5e1f76b344d 100644
--- a/src/components/nodes-table/HomeAssistant.vue
+++ b/src/components/nodes-table/HomeAssistant.vue
@@ -100,10 +100,23 @@
{{ item.object_id }}
- {{ item.persistent ? 'Yes' : 'No' }}
+
- {{ item.ignoreDiscovery ? 'Disabled' : 'Enabled' }}
+
+ {{ item.ignoreDiscovery ? 'Disabled' : 'Enabled' }}
+
@@ -115,7 +128,7 @@
color="blue darken-1"
:disabled="errorDevice"
text
- @click="addDevice"
+ @click="addDevice()"
>Add
@@ -129,7 +142,7 @@
color="blue darken-1"
:disabled="errorDevice"
text
- @click="updateDevice"
+ @click="updateDeviceJSON()"
>Update
@@ -373,7 +386,7 @@ export default {
)
}
},
- async updateDevice() {
+ async updateDeviceJSON() {
if (!this.errorDevice) {
const updated = JSON.parse(this.deviceJSON)
this.$set(
@@ -381,15 +394,33 @@ export default {
this.selectedDevice.id,
updated,
)
- const response = await this.sendAction({
- apiName: 'update',
- device: updated,
- nodeId: this.node.id,
- })
+ await this.updateDevice(updated)
+ }
+ },
+ async toggleField(device, field) {
+ device[field] = !device[field]
+ await this.updateDevice(device)
+ },
+ async updateDevice(device) {
+ const response = await this.sendAction({
+ apiName: 'update',
+ device,
+ nodeId: this.node.id,
+ })
- if (response.success) {
- this.showSnackbar(`Device ${updated.id} updated`, 'success')
+ if (response.success) {
+ this.node.hassDevices = {
+ ...this.node.hassDevices,
+ [device.id]: device,
+ }
+
+ if (
+ this.selectedDevice &&
+ this.selectedDevice.id === device.id
+ ) {
+ this.deviceJSON = JSON.stringify(device, null, 2)
}
+ this.showSnackbar(`Device ${device.id} updated`, 'success')
}
},
validJSONdevice() {