Пример #1
0
def shorthand_analog_pin(value):
    value = analog_pin(value)
    return GPIO_FULL_INPUT_PIN_SCHEMA({CONF_NUMBER: value})


def validate_has_interrupt(value):
    if CORE.is_esp8266:
        if value[CONF_NUMBER] >= 16:
            raise cv.Invalid(
                "Pins GPIO16 and GPIO17 do not support interrupts and cannot be used "
                "here, got {}".format(value[CONF_NUMBER]))
    return value


PIN_SCHEMA_REGISTRY = SimpleRegistry()


def internal_gpio_output_pin_schema(value):
    if isinstance(value, dict):
        return GPIO_FULL_OUTPUT_PIN_SCHEMA(value)
    return shorthand_output_pin(value)


def gpio_output_pin_schema(value):
    if isinstance(value, dict):
        for key, entry in PIN_SCHEMA_REGISTRY.items():
            if key in value:
                return entry[1][0](value)
    return internal_gpio_output_pin_schema(value)
Пример #2
0
    binary_sensor_ = ns.class_(f"{name}BinarySensor",
                               RemoteReceiverBinarySensorBase)
    trigger = ns.class_(f"{name}Trigger", RemoteReceiverTrigger)
    action = ns.class_(f"{name}Action", RemoteTransmitterActionBase)
    dumper = ns.class_(f"{name}Dumper", RemoteTransmitterDumper)
    return data, binary_sensor_, trigger, action, dumper


BINARY_SENSOR_REGISTRY = Registry(
    binary_sensor.BINARY_SENSOR_SCHEMA.extend({
        cv.GenerateID(CONF_RECEIVER_ID):
        cv.use_id(RemoteReceiverBase),
    }))
validate_binary_sensor = cv.validate_registry_entry("remote receiver",
                                                    BINARY_SENSOR_REGISTRY)
TRIGGER_REGISTRY = SimpleRegistry()
DUMPER_REGISTRY = Registry({
    cv.Optional(CONF_RECEIVER_ID):
    cv.invalid(
        "This has been removed in ESPHome 1.20.0 and the dumper attaches directly to the parent receiver."
    ),
})


def validate_dumpers(value):
    if isinstance(value, str) and value.lower() == "all":
        return validate_dumpers(list(DUMPER_REGISTRY.keys()))
    return cv.validate_registry("dumper", DUMPER_REGISTRY)(value)


def validate_triggers(base_schema):