Hi, I’m the author of the Visonic Alarm Panel plugin and I’ve been having a go at writing a data entry flow as described here
I’m trying to ask the user to select either “ethernet” or “usb” and attempted to include this in the schema
import voluptuous as vol
.... more code here ....
CONFIG_SCHEMA_DEVICE = {
vol.Required(CONF_DEVICE_TYPE, default="ethernet") : vol.Any( "ethernet", "usb" )
}
..... and then create the schema like this ........
vol.Schema(CONFIG_SCHEMA_DEVICE)
But this produced the following in the log file
2020-04-13 10:48:39 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 125, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 131, in post
return await super().post(request)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 54, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 70, in post
result = self._prepare_result_json(result)
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 136, in _prepare_result_json
return super()._prepare_result_json(result)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 42, in _prepare_result_json
schema, custom_serializer=cv.custom_serializer
File "/usr/local/lib/python3.7/site-packages/voluptuous_serialize/__init__.py", line 38, in convert
pval = convert(value, custom_serializer=custom_serializer)
File "/usr/local/lib/python3.7/site-packages/voluptuous_serialize/__init__.py", line 108, in convert
raise ValueError('Unable to convert schema: {}'.format(schema))
ValueError: Unable to convert schema: Any('ethernet', 'usb', msg=None)
I can get strings, integers and booleans to work but nothing else. Is it currently limited to these basic types or should I be able to do what I’m trying to do?