<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ls(types, as_json):
 # pylint: disable=invalid-name """List all available sensors"""

    sensors = W1ThermSensor.get_available_sensors(types)

    if as_json:
        data = [
            {"id": i, "hwid": s.id, "type": s.type_name}
            for i, s in enumerate(sensors, 1)
        ]
        click.echo(json.dumps(data, indent=4, sort_keys=True))
    else:
        click.echo(
            "Found {0} sensors:".format(click.style(str(len(sensors)), bold=True))
        )
        for i, sensor in enumerate(sensors, 1):
            click.echo(
                "  {0}. HWID: {1} Type: {2}".format(
                    click.style(str(i), bold=True),
                    click.style(sensor.id, bold=True),
                    click.style(sensor.type_name, bold=True),
                )
            )