From 19259d5cad8ecb4f026cb6d8e3a4548c1816ba91 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Fri, 23 May 2025 08:58:45 -0700 Subject: [PATCH] Add read_only selectors to Statistics Options Flow (#145522) --- homeassistant/components/statistics/config_flow.py | 13 +++++++++++++ homeassistant/components/statistics/strings.json | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/homeassistant/components/statistics/config_flow.py b/homeassistant/components/statistics/config_flow.py index 4c78afbde9c..fb8c09868d5 100644 --- a/homeassistant/components/statistics/config_flow.py +++ b/homeassistant/components/statistics/config_flow.py @@ -106,6 +106,19 @@ DATA_SCHEMA_SETUP = vol.Schema( ) DATA_SCHEMA_OPTIONS = vol.Schema( { + vol.Optional(CONF_ENTITY_ID): EntitySelector( + EntitySelectorConfig(read_only=True) + ), + vol.Optional(CONF_STATE_CHARACTERISTIC): SelectSelector( + SelectSelectorConfig( + options=list( + set(list(STATS_BINARY_SUPPORT) + list(STATS_NUMERIC_SUPPORT)) + ), + translation_key=CONF_STATE_CHARACTERISTIC, + mode=SelectSelectorMode.DROPDOWN, + read_only=True, + ) + ), vol.Optional(CONF_SAMPLES_MAX_BUFFER_SIZE): NumberSelector( NumberSelectorConfig(min=0, step=1, mode=NumberSelectorMode.BOX) ), diff --git a/homeassistant/components/statistics/strings.json b/homeassistant/components/statistics/strings.json index e1085a016ce..e0093fd08c8 100644 --- a/homeassistant/components/statistics/strings.json +++ b/homeassistant/components/statistics/strings.json @@ -32,6 +32,8 @@ "options": { "description": "Read the documentation for further details on how to configure the statistics sensor using these options.", "data": { + "entity_id": "[%key:component::statistics::config::step::user::data::entity_id%]", + "state_characteristic": "[%key:component::statistics::config::step::state_characteristic::data::state_characteristic%]", "sampling_size": "Sampling size", "max_age": "Max age", "keep_last_sample": "Keep last sample", @@ -39,6 +41,8 @@ "precision": "Precision" }, "data_description": { + "entity_id": "[%key:component::statistics::config::step::user::data_description::entity_id%]", + "state_characteristic": "[%key:component::statistics::config::step::state_characteristic::data_description::state_characteristic%]", "sampling_size": "Maximum number of source sensor measurements stored.", "max_age": "Maximum age of source sensor measurements stored.", "keep_last_sample": "Defines whether the most recent sampled value should be preserved regardless of the 'Max age' setting.", @@ -60,6 +64,8 @@ "init": { "description": "[%key:component::statistics::config::step::options::description%]", "data": { + "entity_id": "[%key:component::statistics::config::step::user::data::entity_id%]", + "state_characteristic": "[%key:component::statistics::config::step::state_characteristic::data::state_characteristic%]", "sampling_size": "[%key:component::statistics::config::step::options::data::sampling_size%]", "max_age": "[%key:component::statistics::config::step::options::data::max_age%]", "keep_last_sample": "[%key:component::statistics::config::step::options::data::keep_last_sample%]", @@ -67,6 +73,8 @@ "precision": "[%key:component::statistics::config::step::options::data::precision%]" }, "data_description": { + "entity_id": "[%key:component::statistics::config::step::user::data_description::entity_id%]", + "state_characteristic": "[%key:component::statistics::config::step::state_characteristic::data_description::state_characteristic%]", "sampling_size": "[%key:component::statistics::config::step::options::data_description::sampling_size%]", "max_age": "[%key:component::statistics::config::step::options::data_description::max_age%]", "keep_last_sample": "[%key:component::statistics::config::step::options::data_description::keep_last_sample%]",