From 10e9aa16adcbad5ac771f25a68786432087f13da Mon Sep 17 00:00:00 2001 From: functionpointer Date: Sat, 23 Jan 2021 14:32:36 +0100 Subject: [PATCH] MySensors: Allow user to specify persistence file --- homeassistant/components/mysensors/config_flow.py | 5 ++++- homeassistant/components/mysensors/gateway.py | 6 +++--- .../components/mysensors/translations/en.json | 10 ++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/mysensors/config_flow.py b/homeassistant/components/mysensors/config_flow.py index 2cb0c2e56d0..0457d867f64 100644 --- a/homeassistant/components/mysensors/config_flow.py +++ b/homeassistant/components/mysensors/config_flow.py @@ -88,7 +88,10 @@ def _get_schema_common() -> dict: schema = { vol.Required( CONF_VERSION, default="", description={"suggested_value": DEFAULT_VERSION} - ): str + ): str, + vol.Optional( + CONF_PERSISTENCE_FILE, + ): str, } return schema diff --git a/homeassistant/components/mysensors/gateway.py b/homeassistant/components/mysensors/gateway.py index 189ff723d26..0ab67cc8b17 100644 --- a/homeassistant/components/mysensors/gateway.py +++ b/homeassistant/components/mysensors/gateway.py @@ -96,9 +96,9 @@ async def _get_gateway( raise ValueError( "no unique id! either give configEntry for auto-extraction or explicitly give one" ) - persistence_file = data.get( - CONF_PERSISTENCE_FILE, hass.config.path(f"mysensors_{unique_id}.pickle") - ) + persistence_file = data.get(CONF_PERSISTENCE_FILE, f"mysensors_{unique_id}.pickle") + # interpret relative paths to be in hass config folder. absolute paths will be left as they are + persistence_file = hass.config.path(persistence_file) version = data.get(CONF_VERSION) device = data.get(CONF_DEVICE) baud_rate = data.get(CONF_BAUD_RATE) diff --git a/homeassistant/components/mysensors/translations/en.json b/homeassistant/components/mysensors/translations/en.json index f2cd47b3833..0f1d9532459 100644 --- a/homeassistant/components/mysensors/translations/en.json +++ b/homeassistant/components/mysensors/translations/en.json @@ -21,7 +21,6 @@ "data": { "optimistic": "optimistic", "persistence": "persistence", - "persistence_file": "persistence file name", "gateway_type_mqtt": "MQTT" }, "description": "Choose connection method to the gateway" @@ -31,7 +30,8 @@ "data": { "device": "IP address of the gateway", "tcp_port": "port", - "version": "MySensors version" + "version": "MySensors version", + "persistence_file": "persistence file (leave empty to auto-generate)" } }, "gw_serial": { @@ -39,7 +39,8 @@ "data": { "device": "Serial port", "baud_rate": "baud rate", - "version": "MySensors version" + "version": "MySensors version", + "persistence_file": "persistence file (leave empty to auto-generate)" } }, "gw_mqtt": { @@ -48,7 +49,8 @@ "retain": "mqtt retain", "topic_in_prefix": "prefix for input topics (topic_in_prefix)", "topic_out_prefix": "prefix for output topics (topic_out_prefix)", - "version": "MySensors version" + "version": "MySensors version", + "persistence_file": "persistence file (leave empty to auto-generate)" } } }