I am working on Samsung SmartTag plugin. (Native, i.e. without Android App)
I have a config_flow.py (attached) to configure. It has an options flow.
In the options I plan to add a device and various entities when the SmartTag button is pressed.
I just use a timer task to simulare waiting for the bluetooth results.
I get an an error Dialog when completed, without any error messages in the logs.
Second question, I am currently developing in a config/custom_components directory (in order to test bluetooth on my development platform which is an odroid, supervised.
Are the strings.json and traslations supposed to work here ?
Images: Integration, Options Progress, Breakpoint in code, Options after breakpoint.
config_flow.py Code:
"""Config flow for Samssung SmartTag integration."""
from __future__ import annotations
import asyncio
from typing import Any
from homeassistant import config_entries
from homeassistant.core import callback
from .const import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Samsung SmartTag."""
VERSION = 1
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_PUSH
async def async_step_user(self, user_input=None):
"""Handle the initial step."""
return self.async_create_entry(title="Samsung SmartTag", data={})
@staticmethod
@callback
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> OptionsFlowHandler:
"""Return the options flow."""
return OptionsFlowHandler(config_entry)
class OptionsFlowHandler(config_entries.OptionsFlow):
"""Handle an options flow for Samsung SmartTag."""
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Set up the options flow."""
super().__init__()
self.config_entry = config_entry
async def _async_do_task(self, work):
await work # A task that takes some time to complete.
self.hass.async_create_task(
self.hass.config_entries.options.async_configure(flow_id=self.flow_id)
)
async def async_step_init(self, user_input=None):
"""Handle the initial step."""
# Simulate a task to wait for SmartTag button press
task = asyncio.sleep(10)
self.hass.async_create_task(self._async_do_task(task))
return self.async_show_progress(step_id="user", progress_action="wait")
async def async_step_user(self, user_input=None):
"""Flow Next Step"""
return self.async_show_progress_done(next_step_id="finish")
async def async_step_finish(self, user_input=None):
"""Flow Finish Step"""
# If new devices, then Create Device and Entities for device_tracker, sensors, and button
return self.async_create_entry(title="Samsung SmartTag Options", data={})
...