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 = {
vol.Required(
CONF_VERSION, default="", description={"suggested_value": DEFAULT_VERSION}
): str
): str,
vol.Optional(
CONF_PERSISTENCE_FILE,
): str,
}
return schema

View File

@@ -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)

View File

@@ -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)"
}
}
}