#Hello

1 messages · Page 1 of 1 (latest)

broken prairie
#

here's the JSON:

{
    "config": {
        "abort": {
        },
        "error": {
        },
        "step": {
            "device_params": {
                "title": "Main Configuration",
                "description": "Description of config steps",
                "data": {
                    "friendly_name": "Friendly name",
                    "type": "Device type",
                    "switch": "Switch",
                    "button": "Button",
                    "light": "Light"
                }
            }
        }
    }
}

and manifest.json

{
    "domain": "virtual_devices",
    "name": "Virtual Devices",
    "version": "0.1.0",
    "integration_type": "device",
    "iot_class": "assumed_state",
    "config_flow": true
}
#

here's the Python code for async_step_device_params

    async def async_step_device_params(
        self,
        user_input: dict[str, Any] | None = None,
    ) -> FlowResult:
        if user_input:
            # ... (cut for brevity)

        return self.async_show_form(
            step_id="device_params",
            data_schema=vol.Schema(
                {
                    vol.Required(
                        CONF_FRIENDLY_NAME,
                        default="My New Virtual Device",
                    ): cv.string,
                    vol.Required(
                        CONF_MANUFACTURER,
                        default="Virtual Device",
                    ): cv.string,
                    vol.Optional(
                        CONF_MODEL,
                        default="",
                    ): cv.string,
                }
            ),
        )
#

and... I would post a screenshot with the result, but I can't post images here

#

basically it's a dialog box, titled by the name of the integration (not Main Configuration as one would expect)
and three unlabeled form inputs, only filled with the default= values

#

no description at all

#

I looked at how other integrations do that, and it seems that strings.json isn't actually referenced anywhere, so it should pull it automatically I guess

#

I have read the documentation and I'm running out of options here

fleet imp
#

Search #devs_core-archived for "translations". Gist: you need translations/en.json or so. In core these are generated from strings.json, for custom components not.

broken prairie
#

wow, thanks! that works. I totally missed that all integrations also have translations, apart from strings.json. The docs never mentioned it though

broken prairie
#

it doesn't really work with the options flow though.

#
{
    "config": {
        "step": {
            "user": {
                "title": "Virtual device configuration",
                "description": "Enter a friendly name for the new virtual device. You'll be able to add entities later.",
                "data": {
                    "friendly_name": "Friendly name",
                    "manufacturer": "Device manufacturer",
                    "model": "Device model"
                }
            }
        }
    },
    "options": {
        "step": {
            "init": {
                "title": "Entity configuration",
                "description": "",
                "data": {
                    "entity_add": "Add an entity",
                    "entity_edit": "Edit an entity",
                    "entity_remove": "Remove an entity"
                }
            }
        }
    }
}
#
DEVICE_OPTIONS_MENU = [
    "entity_add",
    "entity_edit",
    "entity_remove",
]

# ....

    async def async_step_init(
        self,
        user_input: dict[str, Any] | None = None,
    ) -> FlowResult:
        return self.async_show_menu(
            step_id="init",
            menu_options=DEVICE_OPTIONS_MENU,
        )