diff --git a/src/data/zwave_js.ts b/src/data/zwave_js.ts index d6db70bd218f..b34338a1508b 100644 --- a/src/data/zwave_js.ts +++ b/src/data/zwave_js.ts @@ -56,6 +56,11 @@ export interface ZWaveJSSetConfigParamData { value: string | number; } +export interface ZWaveJSDataCollectionStatus { + enabled: boolean; + opted_in: boolean; +} + export enum NodeStatus { Unknown, Asleep, @@ -75,6 +80,26 @@ export const fetchNetworkStatus = ( entry_id, }); +export const fetchDataCollectionStatus = ( + hass: HomeAssistant, + entry_id: string +): Promise => + hass.callWS({ + type: "zwave_js/data_collection_status", + entry_id, + }); + +export const setDataCollectionPreference = ( + hass: HomeAssistant, + entry_id: string, + opted_in: boolean +): Promise => + hass.callWS({ + type: "zwave_js/update_data_collection_preference", + entry_id, + opted_in, + }); + export const fetchNodeStatus = ( hass: HomeAssistant, entry_id: string, diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts index bc219081a498..eb53eeafba53 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-config-dashboard.ts @@ -17,9 +17,11 @@ import "../../../../../components/ha-svg-icon"; import "../../../../../components/ha-icon-next"; import { getSignedPath } from "../../../../../data/auth"; import { + fetchDataCollectionStatus, fetchNetworkStatus, fetchNodeStatus, NodeStatus, + setDataCollectionPreference, ZWaveJSNetwork, ZWaveJSNode, } from "../../../../../data/zwave_js"; @@ -55,6 +57,8 @@ class ZWaveJSConfigDashboard extends LitElement { @internalProperty() private _icon = mdiCircle; + @internalProperty() private _dataCollectionOptIn?: boolean; + protected firstUpdated() { if (this.hass) { this._fetchData(); @@ -167,6 +171,39 @@ class ZWaveJSConfigDashboard extends LitElement { + +
+

Third-Party Data Reporting

+ ${this._dataCollectionOptIn !== undefined + ? html` + + ` + : html` + + `} +
+
+

+ Enable the reporting of anonymized telemetry and + statistics to the Z-Wave JS organization. This + data will be used to focus development efforts and improve + the user experience. Information about the data that is + collected and how it is used, including an example of the + data collected, can be found in the + Z-Wave JS data collection documentation. +

+
+
` : ``}