1 """Config flow for OwnTracks."""
10 from .const
import DOMAIN
11 from .helper
import supports_encryption
13 CONF_SECRET =
"secret"
14 CONF_CLOUDHOOK =
"cloudhook"
18 """Set up OwnTracks."""
23 self, user_input: dict[str, Any] |
None =
None
24 ) -> ConfigFlowResult:
25 """Handle a user initiated set up flow to create OwnTracks webhook."""
26 if user_input
is None:
30 webhook_id, webhook_url, cloudhook = await self.
_get_webhook_id_get_webhook_id()
34 secret = secrets.token_hex(16)
38 f
"The encryption key is {secret} (on Android under Preferences >"
42 secret_desc =
"Encryption is not supported because nacl is not installed."
47 CONF_WEBHOOK_ID: webhook_id,
49 CONF_CLOUDHOOK: cloudhook,
51 description_placeholders={
52 "secret": secret_desc,
53 "webhook_url": webhook_url,
54 "android_url":
"https://play.google.com/store/apps/details?id=org.owntracks.android",
55 "ios_url":
"https://itunes.apple.com/us/app/owntracks/id692424691?mt=8",
56 "docs_url":
"https://www.home-assistant.io/integrations/owntracks/",
61 """Generate webhook ID."""
62 webhook_id = webhook.async_generate_id()
63 if cloud.async_active_subscription(self.hass):
64 webhook_url = await cloud.async_create_cloudhook(self.hass, webhook_id)
67 webhook_url = webhook.async_generate_url(self.hass, webhook_id)
70 return webhook_id, webhook_url, cloudhook
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
def _get_webhook_id(self)
ConfigFlowResult async_create_entry(self, *str title, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None, Mapping[str, Any]|None options=None)
ConfigFlowResult async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)
ConfigFlowResult async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)
_FlowResultT async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)
bool supports_encryption()