I have been trying to use the python library voluptuous for a few hours but I cannot make what I want.
Here is what is working right now :
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ENTITY_ID): cv.entity_id,
vol.Required(CONF_STATE): cv.slug,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_START, default=None): cv.template,
vol.Optional(CONF_END, default=None): cv.template,
vol.Optional(CONF_DURATION, default=None): cv.template,
})
But I would like to add another constraint : I want exactly 2 of [CONF_START, CONF_END, CONF_DURATION]
to be provided. Not more, not less than 2.
I have been told to use Exclusive
and Inclusive
, but I'm really confused about how voluptuous works.
How can I make it work like I want ?