pyasic

Miner Config

A dataclass for miner configuration information.

Attributes:

Name Type Description
pool_groups List[_PoolGroup]

A list of pool groups in this config.

temp_mode Literal['auto', 'manual', 'disabled']

The temperature control mode.

temp_target float

The target temp.

temp_hot float

The hot temp (100% fans).

temp_dangerous float

The dangerous temp (shutdown).

minimum_fans int

The minimum numbers of fans to run the miner.

fan_speed Literal[tuple(range(101))]

Manual fan speed to run the fan at (only if temp_mode == "manual").

asicboost bool

Whether or not to enable asicboost.

autotuning_enabled bool

Whether or not to enable autotuning.

autotuning_mode Literal['power', 'hashrate']

Autotuning mode, either "wattage" or "hashrate".

autotuning_wattage int

The wattage to use when autotuning.

autotuning_hashrate int

The hashrate to use when autotuning.

dps_enabled bool

Whether or not to enable dynamic power scaling.

dps_power_step int

The amount of power to reduce autotuning by when the miner reaches dangerous temp.

dps_min_power int

The minimum power to reduce autotuning to.

dps_shutdown_enabled bool

Whether or not to shutdown the miner when dps_min_power is reached.

dps_shutdown_duration float

The amount of time to shutdown for (in hours).

Source code in pyasic/config/__init__.py
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
@dataclass
class MinerConfig:
    """A dataclass for miner configuration information.

    Attributes:
        pool_groups: A list of pool groups in this config.
        temp_mode: The temperature control mode.
        temp_target: The target temp.
        temp_hot: The hot temp (100% fans).
        temp_dangerous: The dangerous temp (shutdown).
        minimum_fans: The minimum numbers of fans to run the miner.
        fan_speed: Manual fan speed to run the fan at (only if temp_mode == "manual").
        asicboost: Whether or not to enable asicboost.
        autotuning_enabled: Whether or not to enable autotuning.
        autotuning_mode: Autotuning mode, either "wattage" or "hashrate".
        autotuning_wattage: The wattage to use when autotuning.
        autotuning_hashrate: The hashrate to use when autotuning.
        dps_enabled: Whether or not to enable dynamic power scaling.
        dps_power_step: The amount of power to reduce autotuning by when the miner reaches dangerous temp.
        dps_min_power: The minimum power to reduce autotuning to.
        dps_shutdown_enabled: Whether or not to shutdown the miner when `dps_min_power` is reached.
        dps_shutdown_duration: The amount of time to shutdown for (in hours).
    """

    pool_groups: List[_PoolGroup] = None

    temp_mode: Literal["auto", "manual", "disabled"] = "auto"
    temp_target: float = 70.0
    temp_hot: float = 80.0
    temp_dangerous: float = 100.0

    minimum_fans: int = None
    fan_speed: Literal[tuple(range(101))] = None  # noqa - Ignore weird Literal usage

    asicboost: bool = None

    miner_mode: IntEnum = X19PowerMode.Normal
    autotuning_enabled: bool = True
    autotuning_mode: Literal["power", "hashrate"] = None
    autotuning_wattage: int = None
    autotuning_hashrate: int = None

    dps_enabled: bool = None
    dps_power_step: int = None
    dps_min_power: int = None
    dps_shutdown_enabled: bool = None
    dps_shutdown_duration: float = None

    @classmethod
    def fields(cls):
        return fields(cls)

    def as_dict(self) -> dict:
        """Convert the data in this class to a dict."""
        logging.debug(f"MinerConfig - (To Dict) - Dumping Dict config")
        data_dict = asdict(self)
        for key in asdict(self).keys():
            if isinstance(data_dict[key], IntEnum):
                data_dict[key] = data_dict[key].value
            if data_dict[key] is None:
                del data_dict[key]
        return data_dict

    def as_toml(self) -> str:
        """Convert the data in this class to toml."""
        logging.debug(f"MinerConfig - (To TOML) - Dumping TOML config")
        return toml.dumps(self.as_dict())

    def as_yaml(self) -> str:
        """Convert the data in this class to yaml."""
        logging.debug(f"MinerConfig - (To YAML) - Dumping YAML config")
        return yaml.dump(self.as_dict(), sort_keys=False)

    def from_raw(self, data: dict):
        """Convert raw config data as a dict to usable data and save it to this class.
        This should be able to handle any raw config file from any miner supported by pyasic.

        Parameters:
             data: The raw config data to convert.
        """
        logging.debug(f"MinerConfig - (From Raw) - Loading raw config")
        pool_groups = []
        if isinstance(data, list):
            # goldshell config list
            data = {"pools": data}
        for key in data.keys():
            if key == "pools":
                pool_groups.append(_PoolGroup().from_dict({"pools": data[key]}))
            elif key == "group":
                for group in data[key]:
                    pool_groups.append(_PoolGroup().from_dict(group))

            if key == "bitmain-fan-ctrl":
                if data[key]:
                    self.temp_mode = "manual"
                    if data.get("bitmain-fan-pwm"):
                        self.fan_speed = int(data["bitmain-fan-pwm"])
            elif key == "bitmain-work-mode":
                if data[key]:
                    self.miner_mode = X19PowerMode(int(data[key]))
            elif key == "fan_control":
                for _key in data[key]:
                    if _key == "min_fans":
                        self.minimum_fans = data[key][_key]
                    elif _key == "speed":
                        self.fan_speed = data[key][_key]
            elif key == "temp_control":
                for _key in data[key]:
                    if _key == "mode":
                        self.temp_mode = data[key][_key]
                    elif _key == "target_temp":
                        self.temp_target = data[key][_key]
                    elif _key == "hot_temp":
                        self.temp_hot = data[key][_key]
                    elif _key == "dangerous_temp":
                        self.temp_dangerous = data[key][_key]

            if key == "hash_chain_global":
                if data[key].get("asic_boost"):
                    self.asicboost = data[key]["asic_boost"]

            if key == "autotuning":
                for _key in data[key]:
                    if _key == "enabled":
                        self.autotuning_enabled = data[key][_key]
                    elif _key == "psu_power_limit":
                        self.autotuning_wattage = data[key][_key]
                    elif _key == "power_target":
                        self.autotuning_wattage = data[key][_key]
                    elif _key == "hashrate_target":
                        self.autotuning_hashrate = data[key][_key]
                    elif _key == "mode":
                        self.autotuning_mode = data[key][_key].replace("_target", "")

            if key in ["power_scaling", "performance_scaling"]:
                for _key in data[key]:
                    if _key == "enabled":
                        self.dps_enabled = data[key][_key]
                    elif _key == "power_step":
                        self.dps_power_step = data[key][_key]
                    elif _key in ["min_psu_power_limit", "min_power_target"]:
                        self.dps_min_power = data[key][_key]
                    elif _key == "shutdown_enabled":
                        self.dps_shutdown_enabled = data[key][_key]
                    elif _key == "shutdown_duration":
                        self.dps_shutdown_duration = data[key][_key]

        self.pool_groups = pool_groups
        return self

    def from_api(self, pools: list):
        """Convert list output from the `AnyMiner.api.pools()` command into a usable data and save it to this class.

        Parameters:
            pools: The list of pool data to convert.
        """
        logging.debug(f"MinerConfig - (From API) - Loading API config")
        _pools = []
        for pool in pools:
            url = pool.get("URL")
            user = pool.get("User")
            _pools.append({"url": url, "user": user, "pass": "123"})
        self.pool_groups = [_PoolGroup().from_dict({"pools": _pools})]
        return self

    def from_dict(self, data: dict):
        """Convert an output dict of this class back into usable data and save it to this class.

        Parameters:
            data: The dict config data to convert.
        """
        logging.debug(f"MinerConfig - (From Dict) - Loading Dict config")
        pool_groups = []
        for group in data["pool_groups"]:
            pool_groups.append(_PoolGroup().from_dict(group))
        for key in data:
            if (
                hasattr(self, key)
                and not key == "pool_groups"
                and not key == "miner_mode"
            ):
                setattr(self, key, data[key])
            if key == "miner_mode":
                self.miner_mode = X19PowerMode(data[key])
        self.pool_groups = pool_groups
        return self

    def from_toml(self, data: str):
        """Convert output toml of this class back into usable data and save it to this class.

        Parameters:
            data: The toml config data to convert.
        """
        logging.debug(f"MinerConfig - (From TOML) - Loading TOML config")
        return self.from_dict(toml.loads(data))

    def from_yaml(self, data: str):
        """Convert output yaml of this class back into usable data and save it to this class.

        Parameters:
            data: The yaml config data to convert.
        """
        logging.debug(f"MinerConfig - (From YAML) - Loading YAML config")
        return self.from_dict(yaml.load(data, Loader=yaml.SafeLoader))

    def as_wm(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a config usable by a Whatsminer device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        logging.debug(f"MinerConfig - (As Whatsminer) - Generating Whatsminer config")
        return {
            "pools": self.pool_groups[0].as_wm(user_suffix=user_suffix),
            "wattage": self.autotuning_wattage,
        }

    def as_inno(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a config usable by an Innosilicon device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        logging.debug(f"MinerConfig - (As Inno) - Generating Innosilicon config")
        return self.pool_groups[0].as_inno(user_suffix=user_suffix)

    def as_x19(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a config usable by an X19 device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        logging.debug(f"MinerConfig - (As X19) - Generating X19 config")
        cfg = {
            "bitmain-fan-ctrl": False,
            "bitmain-fan-pwn": "100",
            "freq-level": "100",
            "miner-mode": str(self.miner_mode.value),
            "pools": self.pool_groups[0].as_x19(user_suffix=user_suffix),
        }

        if not self.temp_mode == "auto":
            cfg["bitmain-fan-ctrl"] = True

        if self.fan_speed:
            cfg["bitmain-fan-pwn"] = str(self.fan_speed)

        return cfg

    def as_x17(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a config usable by an X5 device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        cfg = self.pool_groups[0].as_x17(user_suffix=user_suffix)

        return cfg

    def as_goldshell(self, user_suffix: str = None) -> list:
        """Convert the data in this class to a config usable by a goldshell device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        cfg = self.pool_groups[0].as_goldshell(user_suffix=user_suffix)

        return cfg

    def as_avalon(self, user_suffix: str = None) -> str:
        """Convert the data in this class to a config usable by an Avalonminer device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        logging.debug(f"MinerConfig - (As Avalon) - Generating AvalonMiner config")
        cfg = self.pool_groups[0].as_avalon(user_suffix=user_suffix)
        return cfg

    def as_bos(self, model: str = "S9", user_suffix: str = None) -> str:
        """Convert the data in this class to a config usable by an BOSMiner device.

        Parameters:
            model: The model of the miner to be used in the format portion of the config.
            user_suffix: The suffix to append to username.
        """
        logging.debug(f"MinerConfig - (As BOS) - Generating BOSMiner config")
        cfg = {
            "format": {
                "version": "1.2+",
                "model": f"Antminer {model.replace('j', 'J')}",
                "generator": "pyasic",
                "timestamp": int(time.time()),
            },
            "group": [
                group.as_bos(user_suffix=user_suffix) for group in self.pool_groups
            ],
            "temp_control": {
                "mode": self.temp_mode,
                "target_temp": self.temp_target,
                "hot_temp": self.temp_hot,
                "dangerous_temp": self.temp_dangerous,
            },
        }

        if self.autotuning_enabled or self.autotuning_wattage:
            cfg["autotuning"] = {}
            if self.autotuning_enabled:
                cfg["autotuning"]["enabled"] = True
            else:
                cfg["autotuning"]["enabled"] = False
            if self.autotuning_mode:
                cfg["format"]["version"] = "2.0"
                cfg["autotuning"]["mode"] = self.autotuning_mode + "_target"
                if self.autotuning_wattage:
                    cfg["autotuning"]["power_target"] = self.autotuning_wattage
                elif self.autotuning_hashrate:
                    cfg["autotuning"]["hashrate_target"] = self.autotuning_hashrate
            else:
                if self.autotuning_wattage:
                    cfg["autotuning"]["psu_power_limit"] = self.autotuning_wattage

        if self.asicboost:
            cfg["hash_chain_global"] = {}
            cfg["hash_chain_global"]["asic_boost"] = self.asicboost

        if self.minimum_fans is not None or self.fan_speed is not None:
            cfg["fan_control"] = {}
            if self.minimum_fans is not None:
                cfg["fan_control"]["min_fans"] = self.minimum_fans
            if self.fan_speed is not None:
                cfg["fan_control"]["speed"] = self.fan_speed

        if any(
            [
                getattr(self, item)
                for item in [
                    "dps_enabled",
                    "dps_power_step",
                    "dps_min_power",
                    "dps_shutdown_enabled",
                    "dps_shutdown_duration",
                ]
            ]
        ):
            cfg["power_scaling"] = {}
            if self.dps_enabled:
                cfg["power_scaling"]["enabled"] = self.dps_enabled
            if self.dps_power_step:
                cfg["power_scaling"]["power_step"] = self.dps_power_step
            if self.dps_min_power:
                if cfg["format"]["version"] == "2.0":
                    cfg["power_scaling"]["min_power_target"] = self.dps_min_power
                else:
                    cfg["power_scaling"]["min_psu_power_limit"] = self.dps_min_power
            if self.dps_shutdown_enabled:
                cfg["power_scaling"]["shutdown_enabled"] = self.dps_shutdown_enabled
            if self.dps_shutdown_duration:
                cfg["power_scaling"]["shutdown_duration"] = self.dps_shutdown_duration

        return toml.dumps(cfg)

as_avalon(user_suffix=None)

Convert the data in this class to a config usable by an Avalonminer device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
585
586
587
588
589
590
591
592
593
def as_avalon(self, user_suffix: str = None) -> str:
    """Convert the data in this class to a config usable by an Avalonminer device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    logging.debug(f"MinerConfig - (As Avalon) - Generating AvalonMiner config")
    cfg = self.pool_groups[0].as_avalon(user_suffix=user_suffix)
    return cfg

as_bos(model='S9', user_suffix=None)

Convert the data in this class to a config usable by an BOSMiner device.

Parameters:

Name Type Description Default
model str

The model of the miner to be used in the format portion of the config.

'S9'
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
def as_bos(self, model: str = "S9", user_suffix: str = None) -> str:
    """Convert the data in this class to a config usable by an BOSMiner device.

    Parameters:
        model: The model of the miner to be used in the format portion of the config.
        user_suffix: The suffix to append to username.
    """
    logging.debug(f"MinerConfig - (As BOS) - Generating BOSMiner config")
    cfg = {
        "format": {
            "version": "1.2+",
            "model": f"Antminer {model.replace('j', 'J')}",
            "generator": "pyasic",
            "timestamp": int(time.time()),
        },
        "group": [
            group.as_bos(user_suffix=user_suffix) for group in self.pool_groups
        ],
        "temp_control": {
            "mode": self.temp_mode,
            "target_temp": self.temp_target,
            "hot_temp": self.temp_hot,
            "dangerous_temp": self.temp_dangerous,
        },
    }

    if self.autotuning_enabled or self.autotuning_wattage:
        cfg["autotuning"] = {}
        if self.autotuning_enabled:
            cfg["autotuning"]["enabled"] = True
        else:
            cfg["autotuning"]["enabled"] = False
        if self.autotuning_mode:
            cfg["format"]["version"] = "2.0"
            cfg["autotuning"]["mode"] = self.autotuning_mode + "_target"
            if self.autotuning_wattage:
                cfg["autotuning"]["power_target"] = self.autotuning_wattage
            elif self.autotuning_hashrate:
                cfg["autotuning"]["hashrate_target"] = self.autotuning_hashrate
        else:
            if self.autotuning_wattage:
                cfg["autotuning"]["psu_power_limit"] = self.autotuning_wattage

    if self.asicboost:
        cfg["hash_chain_global"] = {}
        cfg["hash_chain_global"]["asic_boost"] = self.asicboost

    if self.minimum_fans is not None or self.fan_speed is not None:
        cfg["fan_control"] = {}
        if self.minimum_fans is not None:
            cfg["fan_control"]["min_fans"] = self.minimum_fans
        if self.fan_speed is not None:
            cfg["fan_control"]["speed"] = self.fan_speed

    if any(
        [
            getattr(self, item)
            for item in [
                "dps_enabled",
                "dps_power_step",
                "dps_min_power",
                "dps_shutdown_enabled",
                "dps_shutdown_duration",
            ]
        ]
    ):
        cfg["power_scaling"] = {}
        if self.dps_enabled:
            cfg["power_scaling"]["enabled"] = self.dps_enabled
        if self.dps_power_step:
            cfg["power_scaling"]["power_step"] = self.dps_power_step
        if self.dps_min_power:
            if cfg["format"]["version"] == "2.0":
                cfg["power_scaling"]["min_power_target"] = self.dps_min_power
            else:
                cfg["power_scaling"]["min_psu_power_limit"] = self.dps_min_power
        if self.dps_shutdown_enabled:
            cfg["power_scaling"]["shutdown_enabled"] = self.dps_shutdown_enabled
        if self.dps_shutdown_duration:
            cfg["power_scaling"]["shutdown_duration"] = self.dps_shutdown_duration

    return toml.dumps(cfg)

as_dict()

Convert the data in this class to a dict.

Source code in pyasic/config/__init__.py
368
369
370
371
372
373
374
375
376
377
def as_dict(self) -> dict:
    """Convert the data in this class to a dict."""
    logging.debug(f"MinerConfig - (To Dict) - Dumping Dict config")
    data_dict = asdict(self)
    for key in asdict(self).keys():
        if isinstance(data_dict[key], IntEnum):
            data_dict[key] = data_dict[key].value
        if data_dict[key] is None:
            del data_dict[key]
    return data_dict

as_goldshell(user_suffix=None)

Convert the data in this class to a config usable by a goldshell device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
575
576
577
578
579
580
581
582
583
def as_goldshell(self, user_suffix: str = None) -> list:
    """Convert the data in this class to a config usable by a goldshell device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    cfg = self.pool_groups[0].as_goldshell(user_suffix=user_suffix)

    return cfg

as_inno(user_suffix=None)

Convert the data in this class to a config usable by an Innosilicon device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
533
534
535
536
537
538
539
540
def as_inno(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a config usable by an Innosilicon device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    logging.debug(f"MinerConfig - (As Inno) - Generating Innosilicon config")
    return self.pool_groups[0].as_inno(user_suffix=user_suffix)

as_toml()

Convert the data in this class to toml.

Source code in pyasic/config/__init__.py
379
380
381
382
def as_toml(self) -> str:
    """Convert the data in this class to toml."""
    logging.debug(f"MinerConfig - (To TOML) - Dumping TOML config")
    return toml.dumps(self.as_dict())

as_wm(user_suffix=None)

Convert the data in this class to a config usable by a Whatsminer device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
521
522
523
524
525
526
527
528
529
530
531
def as_wm(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a config usable by a Whatsminer device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    logging.debug(f"MinerConfig - (As Whatsminer) - Generating Whatsminer config")
    return {
        "pools": self.pool_groups[0].as_wm(user_suffix=user_suffix),
        "wattage": self.autotuning_wattage,
    }

as_x17(user_suffix=None)

Convert the data in this class to a config usable by an X5 device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
565
566
567
568
569
570
571
572
573
def as_x17(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a config usable by an X5 device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    cfg = self.pool_groups[0].as_x17(user_suffix=user_suffix)

    return cfg

as_x19(user_suffix=None)

Convert the data in this class to a config usable by an X19 device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
def as_x19(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a config usable by an X19 device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    logging.debug(f"MinerConfig - (As X19) - Generating X19 config")
    cfg = {
        "bitmain-fan-ctrl": False,
        "bitmain-fan-pwn": "100",
        "freq-level": "100",
        "miner-mode": str(self.miner_mode.value),
        "pools": self.pool_groups[0].as_x19(user_suffix=user_suffix),
    }

    if not self.temp_mode == "auto":
        cfg["bitmain-fan-ctrl"] = True

    if self.fan_speed:
        cfg["bitmain-fan-pwn"] = str(self.fan_speed)

    return cfg

as_yaml()

Convert the data in this class to yaml.

Source code in pyasic/config/__init__.py
384
385
386
387
def as_yaml(self) -> str:
    """Convert the data in this class to yaml."""
    logging.debug(f"MinerConfig - (To YAML) - Dumping YAML config")
    return yaml.dump(self.as_dict(), sort_keys=False)

from_api(pools)

Convert list output from the AnyMiner.api.pools() command into a usable data and save it to this class.

Parameters:

Name Type Description Default
pools list

The list of pool data to convert.

required
Source code in pyasic/config/__init__.py
466
467
468
469
470
471
472
473
474
475
476
477
478
479
def from_api(self, pools: list):
    """Convert list output from the `AnyMiner.api.pools()` command into a usable data and save it to this class.

    Parameters:
        pools: The list of pool data to convert.
    """
    logging.debug(f"MinerConfig - (From API) - Loading API config")
    _pools = []
    for pool in pools:
        url = pool.get("URL")
        user = pool.get("User")
        _pools.append({"url": url, "user": user, "pass": "123"})
    self.pool_groups = [_PoolGroup().from_dict({"pools": _pools})]
    return self

from_dict(data)

Convert an output dict of this class back into usable data and save it to this class.

Parameters:

Name Type Description Default
data dict

The dict config data to convert.

required
Source code in pyasic/config/__init__.py
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
def from_dict(self, data: dict):
    """Convert an output dict of this class back into usable data and save it to this class.

    Parameters:
        data: The dict config data to convert.
    """
    logging.debug(f"MinerConfig - (From Dict) - Loading Dict config")
    pool_groups = []
    for group in data["pool_groups"]:
        pool_groups.append(_PoolGroup().from_dict(group))
    for key in data:
        if (
            hasattr(self, key)
            and not key == "pool_groups"
            and not key == "miner_mode"
        ):
            setattr(self, key, data[key])
        if key == "miner_mode":
            self.miner_mode = X19PowerMode(data[key])
    self.pool_groups = pool_groups
    return self

from_raw(data)

Convert raw config data as a dict to usable data and save it to this class. This should be able to handle any raw config file from any miner supported by pyasic.

Parameters:

Name Type Description Default
data dict

The raw config data to convert.

required
Source code in pyasic/config/__init__.py
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
def from_raw(self, data: dict):
    """Convert raw config data as a dict to usable data and save it to this class.
    This should be able to handle any raw config file from any miner supported by pyasic.

    Parameters:
         data: The raw config data to convert.
    """
    logging.debug(f"MinerConfig - (From Raw) - Loading raw config")
    pool_groups = []
    if isinstance(data, list):
        # goldshell config list
        data = {"pools": data}
    for key in data.keys():
        if key == "pools":
            pool_groups.append(_PoolGroup().from_dict({"pools": data[key]}))
        elif key == "group":
            for group in data[key]:
                pool_groups.append(_PoolGroup().from_dict(group))

        if key == "bitmain-fan-ctrl":
            if data[key]:
                self.temp_mode = "manual"
                if data.get("bitmain-fan-pwm"):
                    self.fan_speed = int(data["bitmain-fan-pwm"])
        elif key == "bitmain-work-mode":
            if data[key]:
                self.miner_mode = X19PowerMode(int(data[key]))
        elif key == "fan_control":
            for _key in data[key]:
                if _key == "min_fans":
                    self.minimum_fans = data[key][_key]
                elif _key == "speed":
                    self.fan_speed = data[key][_key]
        elif key == "temp_control":
            for _key in data[key]:
                if _key == "mode":
                    self.temp_mode = data[key][_key]
                elif _key == "target_temp":
                    self.temp_target = data[key][_key]
                elif _key == "hot_temp":
                    self.temp_hot = data[key][_key]
                elif _key == "dangerous_temp":
                    self.temp_dangerous = data[key][_key]

        if key == "hash_chain_global":
            if data[key].get("asic_boost"):
                self.asicboost = data[key]["asic_boost"]

        if key == "autotuning":
            for _key in data[key]:
                if _key == "enabled":
                    self.autotuning_enabled = data[key][_key]
                elif _key == "psu_power_limit":
                    self.autotuning_wattage = data[key][_key]
                elif _key == "power_target":
                    self.autotuning_wattage = data[key][_key]
                elif _key == "hashrate_target":
                    self.autotuning_hashrate = data[key][_key]
                elif _key == "mode":
                    self.autotuning_mode = data[key][_key].replace("_target", "")

        if key in ["power_scaling", "performance_scaling"]:
            for _key in data[key]:
                if _key == "enabled":
                    self.dps_enabled = data[key][_key]
                elif _key == "power_step":
                    self.dps_power_step = data[key][_key]
                elif _key in ["min_psu_power_limit", "min_power_target"]:
                    self.dps_min_power = data[key][_key]
                elif _key == "shutdown_enabled":
                    self.dps_shutdown_enabled = data[key][_key]
                elif _key == "shutdown_duration":
                    self.dps_shutdown_duration = data[key][_key]

    self.pool_groups = pool_groups
    return self

from_toml(data)

Convert output toml of this class back into usable data and save it to this class.

Parameters:

Name Type Description Default
data str

The toml config data to convert.

required
Source code in pyasic/config/__init__.py
503
504
505
506
507
508
509
510
def from_toml(self, data: str):
    """Convert output toml of this class back into usable data and save it to this class.

    Parameters:
        data: The toml config data to convert.
    """
    logging.debug(f"MinerConfig - (From TOML) - Loading TOML config")
    return self.from_dict(toml.loads(data))

from_yaml(data)

Convert output yaml of this class back into usable data and save it to this class.

Parameters:

Name Type Description Default
data str

The yaml config data to convert.

required
Source code in pyasic/config/__init__.py
512
513
514
515
516
517
518
519
def from_yaml(self, data: str):
    """Convert output yaml of this class back into usable data and save it to this class.

    Parameters:
        data: The yaml config data to convert.
    """
    logging.debug(f"MinerConfig - (From YAML) - Loading YAML config")
    return self.from_dict(yaml.load(data, Loader=yaml.SafeLoader))

Pool Groups

A dataclass for pool group information.

Attributes:

Name Type Description
quota int

The group quota.

group_name str

The name of the pool group.

pools List[_Pool]

A list of pools in this group.

Source code in pyasic/config/__init__.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
@dataclass
class _PoolGroup:
    """A dataclass for pool group information.

    Attributes:
        quota: The group quota.
        group_name: The name of the pool group.
        pools: A list of pools in this group.
    """

    quota: int = 1
    group_name: str = None
    pools: List[_Pool] = None

    @classmethod
    def fields(cls):
        return fields(cls)

    def __post_init__(self):
        if not self.group_name:
            self.group_name = "".join(
                random.choice(string.ascii_uppercase + string.digits) for _ in range(6)
            )  # generate random pool group name in case it isn't set

    def from_dict(self, data: dict):
        """Convert raw pool group data as a dict to usable data and save it to this class.

        Parameters:
             data: The raw config data to convert.
        """
        pools = []
        for key in data.keys():
            if key in ["name", "group_name"]:
                self.group_name = data[key]
            if key == "quota":
                self.quota = data[key]
            if key in ["pools", "pool"]:
                for pool in data[key]:
                    pools.append(_Pool().from_dict(pool))
        self.pools = pools
        return self

    def as_x19(self, user_suffix: str = None) -> List[dict]:
        """Convert the data in this class to a list usable by an X19 device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        pools = []
        for pool in self.pools[:3]:
            pools.append(pool.as_x19(user_suffix=user_suffix))
        return pools

    def as_x17(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a list usable by an X17 device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        pools = {
            "_ant_pool1url": "",
            "_ant_pool1user": "",
            "_ant_pool1pw": "",
            "_ant_pool2url": "",
            "_ant_pool2user": "",
            "_ant_pool2pw": "",
            "_ant_pool3url": "",
            "_ant_pool3user": "",
            "_ant_pool3pw": "",
        }
        for idx, pool in enumerate(self.pools[:3]):
            pools[f"_ant_pool{idx+1}url"] = pool.as_x17(user_suffix=user_suffix)["url"]
            pools[f"_ant_pool{idx+1}user"] = pool.as_x17(user_suffix=user_suffix)[
                "user"
            ]
            pools[f"_ant_pool{idx+1}pw"] = pool.as_x17(user_suffix=user_suffix)["pass"]

        return pools

    def as_goldshell(self, user_suffix: str = None) -> list:
        """Convert the data in this class to a list usable by a goldshell device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        return [pool.as_goldshell(user_suffix=user_suffix) for pool in self.pools[:3]]

    def as_inno(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a list usable by an Innosilicon device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        pools = {
            "Pool1": None,
            "UserName1": None,
            "Password1": None,
            "Pool2": None,
            "UserName2": None,
            "Password2": None,
            "Pool3": None,
            "UserName3": None,
            "Password3": None,
        }
        for idx, pool in enumerate(self.pools[:3]):
            pool_data = pool.as_inno(user_suffix=user_suffix)
            for key in pool_data:
                pools[f"{key}{idx+1}"] = pool_data[key]
        return pools

    def as_wm(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a list usable by a Whatsminer device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        pools = {}
        for i in range(1, 4):
            if i <= len(self.pools):
                pool_wm = self.pools[i - 1].as_wm(user_suffix)
                pools[f"pool_{i}"] = pool_wm["url"]
                pools[f"worker_{i}"] = pool_wm["user"]
                pools[f"passwd_{i}"] = pool_wm["pass"]
            else:
                pools[f"pool_{i}"] = ""
                pools[f"worker_{i}"] = ""
                pools[f"passwd_{i}"] = ""
        return pools

    def as_avalon(self, user_suffix: str = None) -> str:
        """Convert the data in this class to a dict usable by an Avalonminer device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        pool = self.pools[0].as_avalon(user_suffix=user_suffix)
        return pool

    def as_bos(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by an BOSMiner device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        group = {
            "name": self.group_name,
            "quota": self.quota,
            "pool": [pool.as_bos(user_suffix=user_suffix) for pool in self.pools],
        }
        return group

as_avalon(user_suffix=None)

Convert the data in this class to a dict usable by an Avalonminer device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
293
294
295
296
297
298
299
300
def as_avalon(self, user_suffix: str = None) -> str:
    """Convert the data in this class to a dict usable by an Avalonminer device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    pool = self.pools[0].as_avalon(user_suffix=user_suffix)
    return pool

as_bos(user_suffix=None)

Convert the data in this class to a dict usable by an BOSMiner device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
302
303
304
305
306
307
308
309
310
311
312
313
def as_bos(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by an BOSMiner device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    group = {
        "name": self.group_name,
        "quota": self.quota,
        "pool": [pool.as_bos(user_suffix=user_suffix) for pool in self.pools],
    }
    return group

as_goldshell(user_suffix=None)

Convert the data in this class to a list usable by a goldshell device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
243
244
245
246
247
248
249
def as_goldshell(self, user_suffix: str = None) -> list:
    """Convert the data in this class to a list usable by a goldshell device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    return [pool.as_goldshell(user_suffix=user_suffix) for pool in self.pools[:3]]

as_inno(user_suffix=None)

Convert the data in this class to a list usable by an Innosilicon device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
def as_inno(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a list usable by an Innosilicon device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    pools = {
        "Pool1": None,
        "UserName1": None,
        "Password1": None,
        "Pool2": None,
        "UserName2": None,
        "Password2": None,
        "Pool3": None,
        "UserName3": None,
        "Password3": None,
    }
    for idx, pool in enumerate(self.pools[:3]):
        pool_data = pool.as_inno(user_suffix=user_suffix)
        for key in pool_data:
            pools[f"{key}{idx+1}"] = pool_data[key]
    return pools

as_wm(user_suffix=None)

Convert the data in this class to a list usable by a Whatsminer device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def as_wm(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a list usable by a Whatsminer device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    pools = {}
    for i in range(1, 4):
        if i <= len(self.pools):
            pool_wm = self.pools[i - 1].as_wm(user_suffix)
            pools[f"pool_{i}"] = pool_wm["url"]
            pools[f"worker_{i}"] = pool_wm["user"]
            pools[f"passwd_{i}"] = pool_wm["pass"]
        else:
            pools[f"pool_{i}"] = ""
            pools[f"worker_{i}"] = ""
            pools[f"passwd_{i}"] = ""
    return pools

as_x17(user_suffix=None)

Convert the data in this class to a list usable by an X17 device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def as_x17(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a list usable by an X17 device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    pools = {
        "_ant_pool1url": "",
        "_ant_pool1user": "",
        "_ant_pool1pw": "",
        "_ant_pool2url": "",
        "_ant_pool2user": "",
        "_ant_pool2pw": "",
        "_ant_pool3url": "",
        "_ant_pool3user": "",
        "_ant_pool3pw": "",
    }
    for idx, pool in enumerate(self.pools[:3]):
        pools[f"_ant_pool{idx+1}url"] = pool.as_x17(user_suffix=user_suffix)["url"]
        pools[f"_ant_pool{idx+1}user"] = pool.as_x17(user_suffix=user_suffix)[
            "user"
        ]
        pools[f"_ant_pool{idx+1}pw"] = pool.as_x17(user_suffix=user_suffix)["pass"]

    return pools

as_x19(user_suffix=None)

Convert the data in this class to a list usable by an X19 device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
206
207
208
209
210
211
212
213
214
215
def as_x19(self, user_suffix: str = None) -> List[dict]:
    """Convert the data in this class to a list usable by an X19 device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    pools = []
    for pool in self.pools[:3]:
        pools.append(pool.as_x19(user_suffix=user_suffix))
    return pools

from_dict(data)

Convert raw pool group data as a dict to usable data and save it to this class.

Parameters:

Name Type Description Default
data dict

The raw config data to convert.

required
Source code in pyasic/config/__init__.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
def from_dict(self, data: dict):
    """Convert raw pool group data as a dict to usable data and save it to this class.

    Parameters:
         data: The raw config data to convert.
    """
    pools = []
    for key in data.keys():
        if key in ["name", "group_name"]:
            self.group_name = data[key]
        if key == "quota":
            self.quota = data[key]
        if key in ["pools", "pool"]:
            for pool in data[key]:
                pools.append(_Pool().from_dict(pool))
    self.pools = pools
    return self

Pools

A dataclass for pool information.

Attributes:

Name Type Description
url str

URL of the pool.

username str

Username on the pool.

password str

Worker password on the pool.

Source code in pyasic/config/__init__.py
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
@dataclass
class _Pool:
    """A dataclass for pool information.

    Attributes:
        url: URL of the pool.
        username: Username on the pool.
        password: Worker password on the pool.
    """

    url: str = ""
    username: str = ""
    password: str = ""

    @classmethod
    def fields(cls):
        return fields(cls)

    def from_dict(self, data: dict):
        """Convert raw pool data as a dict to usable data and save it to this class.

        Parameters:
             data: The raw config data to convert.
        """
        for key in data.keys():
            if key == "url":
                self.url = data[key]
            if key in ["user", "username"]:
                self.username = data[key]
            if key in ["pass", "password"]:
                self.password = data[key]
        return self

    def as_wm(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by an Whatsminer device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = {"url": self.url, "user": username, "pass": self.password}
        return pool

    def as_x19(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by an X19 device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = {"url": self.url, "user": username, "pass": self.password}
        return pool

    def as_x17(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by an X5 device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = {"url": self.url, "user": username, "pass": self.password}
        return pool

    def as_goldshell(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by a goldshell device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = {"url": self.url, "user": username, "pass": self.password}
        return pool

    def as_inno(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by an Innosilicon device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = {
            f"Pool": self.url,
            f"UserName": username,
            f"Password": self.password,
        }
        return pool

    def as_avalon(self, user_suffix: str = None) -> str:
        """Convert the data in this class to a string usable by an Avalonminer device.

        Parameters:
             user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = ",".join([self.url, username, self.password])
        return pool

    def as_bos(self, user_suffix: str = None) -> dict:
        """Convert the data in this class to a dict usable by an BOSMiner device.

        Parameters:
            user_suffix: The suffix to append to username.
        """
        username = self.username
        if user_suffix:
            username = f"{username}{user_suffix}"

        pool = {"url": self.url, "user": username, "password": self.password}
        return pool

as_avalon(user_suffix=None)

Convert the data in this class to a string usable by an Avalonminer device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
137
138
139
140
141
142
143
144
145
146
147
148
def as_avalon(self, user_suffix: str = None) -> str:
    """Convert the data in this class to a string usable by an Avalonminer device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = ",".join([self.url, username, self.password])
    return pool

as_bos(user_suffix=None)

Convert the data in this class to a dict usable by an BOSMiner device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
150
151
152
153
154
155
156
157
158
159
160
161
def as_bos(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by an BOSMiner device.

    Parameters:
        user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = {"url": self.url, "user": username, "password": self.password}
    return pool

as_goldshell(user_suffix=None)

Convert the data in this class to a dict usable by a goldshell device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
107
108
109
110
111
112
113
114
115
116
117
118
def as_goldshell(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by a goldshell device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = {"url": self.url, "user": username, "pass": self.password}
    return pool

as_inno(user_suffix=None)

Convert the data in this class to a dict usable by an Innosilicon device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def as_inno(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by an Innosilicon device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = {
        f"Pool": self.url,
        f"UserName": username,
        f"Password": self.password,
    }
    return pool

as_wm(user_suffix=None)

Convert the data in this class to a dict usable by an Whatsminer device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
68
69
70
71
72
73
74
75
76
77
78
79
def as_wm(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by an Whatsminer device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = {"url": self.url, "user": username, "pass": self.password}
    return pool

as_x17(user_suffix=None)

Convert the data in this class to a dict usable by an X5 device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def as_x17(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by an X5 device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = {"url": self.url, "user": username, "pass": self.password}
    return pool

as_x19(user_suffix=None)

Convert the data in this class to a dict usable by an X19 device.

Parameters:

Name Type Description Default
user_suffix str

The suffix to append to username.

None
Source code in pyasic/config/__init__.py
81
82
83
84
85
86
87
88
89
90
91
92
def as_x19(self, user_suffix: str = None) -> dict:
    """Convert the data in this class to a dict usable by an X19 device.

    Parameters:
         user_suffix: The suffix to append to username.
    """
    username = self.username
    if user_suffix:
        username = f"{username}{user_suffix}"

    pool = {"url": self.url, "user": username, "pass": self.password}
    return pool

from_dict(data)

Convert raw pool data as a dict to usable data and save it to this class.

Parameters:

Name Type Description Default
data dict

The raw config data to convert.

required
Source code in pyasic/config/__init__.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def from_dict(self, data: dict):
    """Convert raw pool data as a dict to usable data and save it to this class.

    Parameters:
         data: The raw config data to convert.
    """
    for key in data.keys():
        if key == "url":
            self.url = data[key]
        if key in ["user", "username"]:
            self.username = data[key]
        if key in ["pass", "password"]:
            self.password = data[key]
    return self