def METHOD_NAME(cls, config):
    if isinstance(config, int):
        return cls.from_int(config)
    type_str = config["type"]
    pulse_time = config["pulse_time"] if "pulse_time" in config else None
    open_id = config["ports"]["open_port"]["id"]
    open_default = config["ports"]["open_port"]["default"]
    if "close_port" in config["ports"]:
        close_id = config["ports"]["close_port"]["id"]
        close_default = config["ports"]["close_port"]["default"]
        return cls(
            type_str,
            open_id,
            open_default,
            close_id,
            close_default,
            pulse_time,
        )
    return cls(type_str, open_id, open_default, -1, 0, pulse_time)