Allow enabling experimental devices from environment variable (#1194)

This commit is contained in:
Steven B.
2024-10-29 09:30:30 +00:00
committed by GitHub
parent d30d116f37
commit 4aec9d302f
6 changed files with 75 additions and 22 deletions

View File

@@ -16,6 +16,7 @@ if TYPE_CHECKING:
from kasa import Device
from kasa.deviceconfig import DeviceEncryptionType
from kasa.experimental import Experimental
from .common import (
SKIP_UPDATE_COMMANDS,
@@ -220,11 +221,11 @@ def _legacy_type_to_class(_type):
help="Hashed credentials used to authenticate to the device.",
)
@click.option(
"--experimental",
default=False,
"--experimental/--no-experimental",
default=None,
is_flag=True,
type=bool,
envvar="KASA_EXPERIMENTAL",
envvar=Experimental.ENV_VAR,
help="Enable experimental mode for devices not yet fully supported.",
)
@click.version_option(package_name="python-kasa")
@@ -260,10 +261,11 @@ async def cli(
if target != DEFAULT_TARGET and host:
error("--target is not a valid option for single host discovery")
if experimental:
from kasa.experimental.enabled import Enabled
if experimental is not None:
Experimental.set_enabled(experimental)
Enabled.set(True)
if Experimental.enabled():
echo("Experimental support is enabled")
logging_config: dict[str, Any] = {
"level": logging.DEBUG if debug > 0 else logging.INFO