MySensors: Allow user to specify persistence file

This commit is contained in:
functionpointer
2021-01-23 14:32:36 +01:00
parent 16df6f7e78
commit 10e9aa16ad
3 changed files with 13 additions and 8 deletions

View File

@@ -88,7 +88,10 @@ def _get_schema_common() -> dict:
schema = { schema = {
vol.Required( vol.Required(
CONF_VERSION, default="", description={"suggested_value": DEFAULT_VERSION} CONF_VERSION, default="", description={"suggested_value": DEFAULT_VERSION}
): str ): str,
vol.Optional(
CONF_PERSISTENCE_FILE,
): str,
} }
return schema return schema

View File

@@ -96,9 +96,9 @@ async def _get_gateway(
raise ValueError( raise ValueError(
"no unique id! either give configEntry for auto-extraction or explicitly give one" "no unique id! either give configEntry for auto-extraction or explicitly give one"
) )
persistence_file = data.get( persistence_file = data.get(CONF_PERSISTENCE_FILE, f"mysensors_{unique_id}.pickle")
CONF_PERSISTENCE_FILE, hass.config.path(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) version = data.get(CONF_VERSION)
device = data.get(CONF_DEVICE) device = data.get(CONF_DEVICE)
baud_rate = data.get(CONF_BAUD_RATE) baud_rate = data.get(CONF_BAUD_RATE)

View File

@@ -21,7 +21,6 @@
"data": { "data": {
"optimistic": "optimistic", "optimistic": "optimistic",
"persistence": "persistence", "persistence": "persistence",
"persistence_file": "persistence file name",
"gateway_type_mqtt": "MQTT" "gateway_type_mqtt": "MQTT"
}, },
"description": "Choose connection method to the gateway" "description": "Choose connection method to the gateway"
@@ -31,7 +30,8 @@
"data": { "data": {
"device": "IP address of the gateway", "device": "IP address of the gateway",
"tcp_port": "port", "tcp_port": "port",
"version": "MySensors version" "version": "MySensors version",
"persistence_file": "persistence file (leave empty to auto-generate)"
} }
}, },
"gw_serial": { "gw_serial": {
@@ -39,7 +39,8 @@
"data": { "data": {
"device": "Serial port", "device": "Serial port",
"baud_rate": "baud rate", "baud_rate": "baud rate",
"version": "MySensors version" "version": "MySensors version",
"persistence_file": "persistence file (leave empty to auto-generate)"
} }
}, },
"gw_mqtt": { "gw_mqtt": {
@@ -48,7 +49,8 @@
"retain": "mqtt retain", "retain": "mqtt retain",
"topic_in_prefix": "prefix for input topics (topic_in_prefix)", "topic_in_prefix": "prefix for input topics (topic_in_prefix)",
"topic_out_prefix": "prefix for output topics (topic_out_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)"
} }
} }
} }