pyasic

Base Miner

BaseMiner is the basis for all miner classes, they all subclass (usually indirectly) from this class.

You may not instantiate this class on its own, only subclass from it. Trying to instantiate an instance of this class will raise TypeError.

Bases: ABC

Source code in pyasic/miners/base.py
 30
 31
 32
 33
 34
 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
162
163
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
314
315
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
class BaseMiner(ABC):
    def __init__(self, ip: str, *args, **kwargs) -> None:
        # interfaces
        self.api = None
        self.web = None

        self.ssh_pwd = "root"

        # static data
        self.ip = ip
        self.api_type = None
        # type
        self.make = None
        self.model = None
        # physical attributes
        self.ideal_hashboards = 3
        self.nominal_chips = 0
        self.fan_count = 2
        # data gathering locations
        self.data_locations = None
        # autotuning/shutdown support
        self.supports_autotuning = False
        self.supports_shutdown = False

        # data storage
        self.api_ver = None
        self.fw_ver = None
        self.light = None
        self.config = None

    def __new__(cls, *args, **kwargs):
        if cls is BaseMiner:
            raise TypeError(f"Only children of '{cls.__name__}' may be instantiated")
        return object.__new__(cls)

    def __repr__(self):
        return f"{'' if not self.api_type else self.api_type}{'' if not self.model else ' ' + self.model}: {str(self.ip)}"

    def __lt__(self, other):
        return ipaddress.ip_address(self.ip) < ipaddress.ip_address(other.ip)

    def __gt__(self, other):
        return ipaddress.ip_address(self.ip) > ipaddress.ip_address(other.ip)

    def __eq__(self, other):
        return ipaddress.ip_address(self.ip) == ipaddress.ip_address(other.ip)

    @property
    def pwd(self):  # noqa - Skip PyCharm inspection
        data = []
        try:
            if self.web is not None:
                data.append(f"web={self.web.pwd}")
        except TypeError:
            pass
        try:
            if self.api is not None:
                data.append(f"api={self.api.pwd}")
        except TypeError:
            pass
        return ",".join(data)

    @pwd.setter
    def pwd(self, val):
        self.ssh_pwd = val
        try:
            if self.web is not None:
                self.web.pwd = val
        except TypeError:
            pass
        try:
            if self.api is not None:
                self.api.pwd = val
        except TypeError:
            pass

    @property
    def username(self):  # noqa - Skip PyCharm inspection
        data = []
        try:
            if self.web is not None:
                data.append(f"web={self.web.username}")
        except TypeError:
            pass
        return ",".join(data)

    @username.setter
    def username(self, val):
        try:
            if self.web is not None:
                self.web.username = val
        except TypeError:
            pass

    async def _get_ssh_connection(self) -> asyncssh.connect:
        """Create a new asyncssh connection"""
        try:
            conn = await asyncssh.connect(
                str(self.ip),
                known_hosts=None,
                username="root",
                password=self.ssh_pwd,
                server_host_key_algs=["ssh-rsa"],
            )
            return conn
        except asyncssh.misc.PermissionDenied:
            try:
                conn = await asyncssh.connect(
                    str(self.ip),
                    known_hosts=None,
                    username="root",
                    password="admin",
                    server_host_key_algs=["ssh-rsa"],
                )
                return conn
            except Exception as e:
                raise ConnectionError from e
        except OSError as e:
            logging.warning(f"Connection refused: {self}")
            raise ConnectionError from e
        except Exception as e:
            raise ConnectionError from e

    async def check_light(self) -> bool:
        return await self.get_fault_light()

    @abstractmethod
    async def fault_light_on(self) -> bool:
        """Turn the fault light of the miner on and return success as a boolean.

        Returns:
            A boolean value of the success of turning the light on.
        """
        pass

    @abstractmethod
    async def fault_light_off(self) -> bool:
        """Turn the fault light of the miner off and return success as a boolean.

        Returns:
            A boolean value of the success of turning the light off.
        """
        pass

    @abstractmethod
    async def get_config(self) -> MinerConfig:
        # Not a data gathering function, since this is used for configuration and not MinerData
        """Get the mining configuration of the miner and return it as a [`MinerConfig`][pyasic.config.MinerConfig].

        Returns:
            A [`MinerConfig`][pyasic.config.MinerConfig] containing the pool information and mining configuration.
        """
        pass

    @abstractmethod
    async def reboot(self) -> bool:
        """Reboot the miner and return success as a boolean.

        Returns:
            A boolean value of the success of rebooting the miner.
        """
        pass

    @abstractmethod
    async def restart_backend(self) -> bool:
        """Restart the mining process of the miner (bosminer, bmminer, cgminer, etc) and return success as a boolean.

        Returns:
            A boolean value of the success of restarting the mining process.
        """
        pass

    @abstractmethod
    async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
        """Set the mining configuration of the miner.

        Parameters:
            config: A [`MinerConfig`][pyasic.config.MinerConfig] containing the mining config you want to switch the miner to.
            user_suffix: A suffix to append to the username when sending to the miner.
        """
        return None

    @abstractmethod
    async def stop_mining(self) -> bool:
        """Stop the mining process of the miner.

        Returns:
            A boolean value of the success of stopping the mining process.
        """
        pass

    @abstractmethod
    async def resume_mining(self) -> bool:
        """Resume the mining process of the miner.

        Returns:
            A boolean value of the success of resuming the mining process.
        """
        pass

    @abstractmethod
    async def set_power_limit(self, wattage: int) -> bool:
        """Set the power limit to be used by the miner.

        Parameters:
            wattage: The power limit to set on the miner.

        Returns:
            A boolean value of the success of setting the power limit.
        """
        pass

    ##################################################
    ### DATA GATHERING FUNCTIONS (get_{some_data}) ###
    ##################################################

    @abstractmethod
    async def get_mac(self, *args, **kwargs) -> Optional[str]:
        """Get the MAC address of the miner and return it as a string.

        Returns:
            A string representing the MAC address of the miner.
        """
        pass

    async def get_model(self) -> Optional[str]:
        """Get the model of the miner and return it as a string.

        Returns:
            A string representing the model of the miner.
        """
        return self.model

    @abstractmethod
    async def get_api_ver(self, *args, **kwargs) -> Optional[str]:
        """Get the API version of the miner and is as a string.

        Returns:
            API version as a string.
        """
        pass

    @abstractmethod
    async def get_fw_ver(self, *args, **kwargs) -> Optional[str]:
        """Get the firmware version of the miner and is as a string.

        Returns:
            Firmware version as a string.
        """
        pass

    @abstractmethod
    async def get_version(self, *args, **kwargs) -> Tuple[Optional[str], Optional[str]]:
        """Get the API version and firmware version of the miner and return them as strings.

        Returns:
            A tuple of (API version, firmware version) as strings.
        """
        pass

    @abstractmethod
    async def get_hostname(self, *args, **kwargs) -> Optional[str]:
        """Get the hostname of the miner and return it as a string.

        Returns:
            A string representing the hostname of the miner.
        """
        pass

    @abstractmethod
    async def get_hashrate(self, *args, **kwargs) -> Optional[float]:
        """Get the hashrate of the miner and return it as a float in TH/s.

        Returns:
            Hashrate of the miner in TH/s as a float.
        """
        pass

    @abstractmethod
    async def get_hashboards(self, *args, **kwargs) -> List[HashBoard]:
        """Get hashboard data from the miner in the form of [`HashBoard`][pyasic.data.HashBoard].

        Returns:
            A [`HashBoard`][pyasic.data.HashBoard] instance containing hashboard data from the miner.
        """
        pass

    @abstractmethod
    async def get_env_temp(self, *args, **kwargs) -> Optional[float]:
        """Get environment temp from the miner as a float.

        Returns:
            Environment temp of the miner as a float.
        """
        pass

    @abstractmethod
    async def get_wattage(self, *args, **kwargs) -> Optional[int]:
        """Get wattage from the miner as an int.

        Returns:
            Wattage of the miner as an int.
        """
        pass

    @abstractmethod
    async def get_wattage_limit(self, *args, **kwargs) -> Optional[int]:
        """Get wattage limit from the miner as an int.

        Returns:
            Wattage limit of the miner as an int.
        """
        pass

    @abstractmethod
    async def get_fans(self, *args, **kwargs) -> List[Fan]:
        """Get fan data from the miner in the form [fan_1, fan_2, fan_3, fan_4].

        Returns:
            A list of fan data.
        """
        pass

    @abstractmethod
    async def get_fan_psu(self, *args, **kwargs) -> Optional[int]:
        """Get PSU fan speed from the miner.

        Returns:
            PSU fan speed.
        """
        pass

    @abstractmethod
    async def get_pools(self, *args, **kwargs) -> List[dict]:
        """Get pool information from the miner.

        Returns:
            Pool groups and quotas in a list of dicts.
        """
        pass

    @abstractmethod
    async def get_errors(self, *args, **kwargs) -> List[MinerErrorData]:
        """Get a list of the errors the miner is experiencing.

        Returns:
            A list of error classes representing different errors.
        """
        pass

    @abstractmethod
    async def get_fault_light(self, *args, **kwargs) -> bool:
        """Check the status of the fault light and return on or off as a boolean.

        Returns:
            A boolean value where `True` represents on and `False` represents off.
        """
        pass

    @abstractmethod
    async def get_nominal_hashrate(self, *args, **kwargs) -> Optional[float]:
        """Get the nominal hashrate from factory if available.

        Returns:
            A float value of nominal hashrate in TH/s.
        """
        pass

    @abstractmethod
    async def is_mining(self, *args, **kwargs) -> Optional[bool]:
        """Check whether the miner is mining.

        Returns:
            A boolean value representing if the miner is mining.
        """
        pass

    @abstractmethod
    async def get_uptime(self, *args, **kwargs) -> Optional[int]:
        """Get the uptime of the miner in seconds.

        Returns:
            The uptime of the miner in seconds.
        """
        pass

    async def _get_data(
        self, allow_warning: bool, include: list = None, exclude: list = None
    ) -> dict:
        if include is None:
            # everything
            include = list(self.data_locations.keys())

        if exclude is not None:
            for item in exclude:
                if item in include:
                    include.remove(item)

        api_multicommand = set()
        web_multicommand = []
        for data_name in include:
            try:
                fn_args = self.data_locations[data_name]["kwargs"]
                for arg_name in fn_args:
                    if fn_args[arg_name].get("api"):
                        api_multicommand.add(fn_args[arg_name]["api"])
                    if fn_args[arg_name].get("web"):
                        if not fn_args[arg_name]["web"] in web_multicommand:
                            web_multicommand.append(fn_args[arg_name]["web"])
            except KeyError as e:
                logger.error(e, data_name)
                continue

        if len(api_multicommand) > 0:
            api_command_task = asyncio.create_task(
                self.api.multicommand(*api_multicommand, allow_warning=allow_warning)
            )
        else:
            api_command_task = asyncio.sleep(0)
        if len(web_multicommand) > 0:
            web_command_task = asyncio.create_task(
                self.web.multicommand(*web_multicommand, allow_warning=allow_warning)
            )
        else:
            web_command_task = asyncio.sleep(0)

        web_command_data = await web_command_task
        if web_command_data is None:
            web_command_data = {}

        api_command_data = await api_command_task
        if api_command_data is None:
            api_command_data = {}

        miner_data = {}

        for data_name in include:
            try:
                fn_args = self.data_locations[data_name]["kwargs"]
                args_to_send = {k: None for k in fn_args}
                for arg_name in fn_args:
                    try:
                        if fn_args[arg_name].get("api"):
                            if api_command_data.get("multicommand"):
                                args_to_send[arg_name] = api_command_data[
                                    fn_args[arg_name]["api"]
                                ][0]
                            else:
                                args_to_send[arg_name] = api_command_data
                        if fn_args[arg_name].get("web"):
                            if web_command_data is not None:
                                if web_command_data.get("multicommand"):
                                    args_to_send[arg_name] = web_command_data[
                                        fn_args[arg_name]["web"]
                                    ]
                                else:
                                    if not web_command_data == {"multicommand": False}:
                                        args_to_send[arg_name] = web_command_data
                    except LookupError:
                        args_to_send[arg_name] = None
            except LookupError:
                continue

            function = getattr(self, self.data_locations[data_name]["cmd"])
            if not data_name == "pools":
                miner_data[data_name] = await function(**args_to_send)
            else:
                pools_data = await function(**args_to_send)
                if pools_data:
                    try:
                        miner_data["pool_1_url"] = pools_data[0]["pool_1_url"]
                        miner_data["pool_1_user"] = pools_data[0]["pool_1_user"]
                    except KeyError:
                        pass
                    if len(pools_data) > 1:
                        miner_data["pool_2_url"] = pools_data[1]["pool_1_url"]
                        miner_data["pool_2_user"] = pools_data[1]["pool_1_user"]
                        miner_data[
                            "pool_split"
                        ] = f"{pools_data[0]['quota']}/{pools_data[1]['quota']}"
                    else:
                        try:
                            miner_data["pool_2_url"] = pools_data[0]["pool_2_url"]
                            miner_data["pool_2_user"] = pools_data[0]["pool_2_user"]
                            miner_data["quota"] = "0"
                        except KeyError:
                            pass
        return miner_data

    async def get_data(
        self, allow_warning: bool = False, include: list = None, exclude: list = None
    ) -> MinerData:
        """Get data from the miner in the form of [`MinerData`][pyasic.data.MinerData].

        Parameters:
            allow_warning: Allow warning when an API command fails.
            include: Names of data items you want to gather. Defaults to all data.
            exclude: Names of data items to exclude.  Exclusion happens after considering included items.

        Returns:
            A [`MinerData`][pyasic.data.MinerData] instance containing data from the miner.
        """
        data = MinerData(
            ip=str(self.ip),
            make=self.make,
            ideal_chips=self.nominal_chips * self.ideal_hashboards,
            ideal_hashboards=self.ideal_hashboards,
            hashboards=[
                HashBoard(slot=i, expected_chips=self.nominal_chips)
                for i in range(self.ideal_hashboards)
            ],
        )

        gathered_data = await self._get_data(
            allow_warning, include=include, exclude=exclude
        )
        for item in gathered_data:
            if gathered_data[item] is not None:
                setattr(data, item, gathered_data[item])

        return data

fault_light_off() abstractmethod async

Turn the fault light of the miner off and return success as a boolean.

Returns:

Type Description
bool

A boolean value of the success of turning the light off.

Source code in pyasic/miners/base.py
165
166
167
168
169
170
171
172
@abstractmethod
async def fault_light_off(self) -> bool:
    """Turn the fault light of the miner off and return success as a boolean.

    Returns:
        A boolean value of the success of turning the light off.
    """
    pass

fault_light_on() abstractmethod async

Turn the fault light of the miner on and return success as a boolean.

Returns:

Type Description
bool

A boolean value of the success of turning the light on.

Source code in pyasic/miners/base.py
156
157
158
159
160
161
162
163
@abstractmethod
async def fault_light_on(self) -> bool:
    """Turn the fault light of the miner on and return success as a boolean.

    Returns:
        A boolean value of the success of turning the light on.
    """
    pass

get_api_ver(*args, **kwargs) abstractmethod async

Get the API version of the miner and is as a string.

Returns:

Type Description
Optional[str]

API version as a string.

Source code in pyasic/miners/base.py
263
264
265
266
267
268
269
270
@abstractmethod
async def get_api_ver(self, *args, **kwargs) -> Optional[str]:
    """Get the API version of the miner and is as a string.

    Returns:
        API version as a string.
    """
    pass

get_config() abstractmethod async

Get the mining configuration of the miner and return it as a MinerConfig.

Returns:

Type Description
MinerConfig

A MinerConfig containing the pool information and mining configuration.

Source code in pyasic/miners/base.py
174
175
176
177
178
179
180
181
182
@abstractmethod
async def get_config(self) -> MinerConfig:
    # Not a data gathering function, since this is used for configuration and not MinerData
    """Get the mining configuration of the miner and return it as a [`MinerConfig`][pyasic.config.MinerConfig].

    Returns:
        A [`MinerConfig`][pyasic.config.MinerConfig] containing the pool information and mining configuration.
    """
    pass

get_data(allow_warning=False, include=None, exclude=None) async

Get data from the miner in the form of MinerData.

Parameters:

Name Type Description Default
allow_warning bool

Allow warning when an API command fails.

False
include list

Names of data items you want to gather. Defaults to all data.

None
exclude list

Names of data items to exclude. Exclusion happens after considering included items.

None

Returns:

Type Description
MinerData

A MinerData instance containing data from the miner.

Source code in pyasic/miners/base.py
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
async def get_data(
    self, allow_warning: bool = False, include: list = None, exclude: list = None
) -> MinerData:
    """Get data from the miner in the form of [`MinerData`][pyasic.data.MinerData].

    Parameters:
        allow_warning: Allow warning when an API command fails.
        include: Names of data items you want to gather. Defaults to all data.
        exclude: Names of data items to exclude.  Exclusion happens after considering included items.

    Returns:
        A [`MinerData`][pyasic.data.MinerData] instance containing data from the miner.
    """
    data = MinerData(
        ip=str(self.ip),
        make=self.make,
        ideal_chips=self.nominal_chips * self.ideal_hashboards,
        ideal_hashboards=self.ideal_hashboards,
        hashboards=[
            HashBoard(slot=i, expected_chips=self.nominal_chips)
            for i in range(self.ideal_hashboards)
        ],
    )

    gathered_data = await self._get_data(
        allow_warning, include=include, exclude=exclude
    )
    for item in gathered_data:
        if gathered_data[item] is not None:
            setattr(data, item, gathered_data[item])

    return data

get_env_temp(*args, **kwargs) abstractmethod async

Get environment temp from the miner as a float.

Returns:

Type Description
Optional[float]

Environment temp of the miner as a float.

Source code in pyasic/miners/base.py
317
318
319
320
321
322
323
324
@abstractmethod
async def get_env_temp(self, *args, **kwargs) -> Optional[float]:
    """Get environment temp from the miner as a float.

    Returns:
        Environment temp of the miner as a float.
    """
    pass

get_errors(*args, **kwargs) abstractmethod async

Get a list of the errors the miner is experiencing.

Returns:

Type Description
List[MinerErrorData]

A list of error classes representing different errors.

Source code in pyasic/miners/base.py
371
372
373
374
375
376
377
378
@abstractmethod
async def get_errors(self, *args, **kwargs) -> List[MinerErrorData]:
    """Get a list of the errors the miner is experiencing.

    Returns:
        A list of error classes representing different errors.
    """
    pass

get_fan_psu(*args, **kwargs) abstractmethod async

Get PSU fan speed from the miner.

Returns:

Type Description
Optional[int]

PSU fan speed.

Source code in pyasic/miners/base.py
353
354
355
356
357
358
359
360
@abstractmethod
async def get_fan_psu(self, *args, **kwargs) -> Optional[int]:
    """Get PSU fan speed from the miner.

    Returns:
        PSU fan speed.
    """
    pass

get_fans(*args, **kwargs) abstractmethod async

Get fan data from the miner in the form [fan_1, fan_2, fan_3, fan_4].

Returns:

Type Description
List[Fan]

A list of fan data.

Source code in pyasic/miners/base.py
344
345
346
347
348
349
350
351
@abstractmethod
async def get_fans(self, *args, **kwargs) -> List[Fan]:
    """Get fan data from the miner in the form [fan_1, fan_2, fan_3, fan_4].

    Returns:
        A list of fan data.
    """
    pass

get_fault_light(*args, **kwargs) abstractmethod async

Check the status of the fault light and return on or off as a boolean.

Returns:

Type Description
bool

A boolean value where True represents on and False represents off.

Source code in pyasic/miners/base.py
380
381
382
383
384
385
386
387
@abstractmethod
async def get_fault_light(self, *args, **kwargs) -> bool:
    """Check the status of the fault light and return on or off as a boolean.

    Returns:
        A boolean value where `True` represents on and `False` represents off.
    """
    pass

get_fw_ver(*args, **kwargs) abstractmethod async

Get the firmware version of the miner and is as a string.

Returns:

Type Description
Optional[str]

Firmware version as a string.

Source code in pyasic/miners/base.py
272
273
274
275
276
277
278
279
@abstractmethod
async def get_fw_ver(self, *args, **kwargs) -> Optional[str]:
    """Get the firmware version of the miner and is as a string.

    Returns:
        Firmware version as a string.
    """
    pass

get_hashboards(*args, **kwargs) abstractmethod async

Get hashboard data from the miner in the form of HashBoard.

Returns:

Type Description
List[HashBoard]

A HashBoard instance containing hashboard data from the miner.

Source code in pyasic/miners/base.py
308
309
310
311
312
313
314
315
@abstractmethod
async def get_hashboards(self, *args, **kwargs) -> List[HashBoard]:
    """Get hashboard data from the miner in the form of [`HashBoard`][pyasic.data.HashBoard].

    Returns:
        A [`HashBoard`][pyasic.data.HashBoard] instance containing hashboard data from the miner.
    """
    pass

get_hashrate(*args, **kwargs) abstractmethod async

Get the hashrate of the miner and return it as a float in TH/s.

Returns:

Type Description
Optional[float]

Hashrate of the miner in TH/s as a float.

Source code in pyasic/miners/base.py
299
300
301
302
303
304
305
306
@abstractmethod
async def get_hashrate(self, *args, **kwargs) -> Optional[float]:
    """Get the hashrate of the miner and return it as a float in TH/s.

    Returns:
        Hashrate of the miner in TH/s as a float.
    """
    pass

get_hostname(*args, **kwargs) abstractmethod async

Get the hostname of the miner and return it as a string.

Returns:

Type Description
Optional[str]

A string representing the hostname of the miner.

Source code in pyasic/miners/base.py
290
291
292
293
294
295
296
297
@abstractmethod
async def get_hostname(self, *args, **kwargs) -> Optional[str]:
    """Get the hostname of the miner and return it as a string.

    Returns:
        A string representing the hostname of the miner.
    """
    pass

get_mac(*args, **kwargs) abstractmethod async

Get the MAC address of the miner and return it as a string.

Returns:

Type Description
Optional[str]

A string representing the MAC address of the miner.

Source code in pyasic/miners/base.py
246
247
248
249
250
251
252
253
@abstractmethod
async def get_mac(self, *args, **kwargs) -> Optional[str]:
    """Get the MAC address of the miner and return it as a string.

    Returns:
        A string representing the MAC address of the miner.
    """
    pass

get_model() async

Get the model of the miner and return it as a string.

Returns:

Type Description
Optional[str]

A string representing the model of the miner.

Source code in pyasic/miners/base.py
255
256
257
258
259
260
261
async def get_model(self) -> Optional[str]:
    """Get the model of the miner and return it as a string.

    Returns:
        A string representing the model of the miner.
    """
    return self.model

get_nominal_hashrate(*args, **kwargs) abstractmethod async

Get the nominal hashrate from factory if available.

Returns:

Type Description
Optional[float]

A float value of nominal hashrate in TH/s.

Source code in pyasic/miners/base.py
389
390
391
392
393
394
395
396
@abstractmethod
async def get_nominal_hashrate(self, *args, **kwargs) -> Optional[float]:
    """Get the nominal hashrate from factory if available.

    Returns:
        A float value of nominal hashrate in TH/s.
    """
    pass

get_pools(*args, **kwargs) abstractmethod async

Get pool information from the miner.

Returns:

Type Description
List[dict]

Pool groups and quotas in a list of dicts.

Source code in pyasic/miners/base.py
362
363
364
365
366
367
368
369
@abstractmethod
async def get_pools(self, *args, **kwargs) -> List[dict]:
    """Get pool information from the miner.

    Returns:
        Pool groups and quotas in a list of dicts.
    """
    pass

get_uptime(*args, **kwargs) abstractmethod async

Get the uptime of the miner in seconds.

Returns:

Type Description
Optional[int]

The uptime of the miner in seconds.

Source code in pyasic/miners/base.py
407
408
409
410
411
412
413
414
@abstractmethod
async def get_uptime(self, *args, **kwargs) -> Optional[int]:
    """Get the uptime of the miner in seconds.

    Returns:
        The uptime of the miner in seconds.
    """
    pass

get_version(*args, **kwargs) abstractmethod async

Get the API version and firmware version of the miner and return them as strings.

Returns:

Type Description
Tuple[Optional[str], Optional[str]]

A tuple of (API version, firmware version) as strings.

Source code in pyasic/miners/base.py
281
282
283
284
285
286
287
288
@abstractmethod
async def get_version(self, *args, **kwargs) -> Tuple[Optional[str], Optional[str]]:
    """Get the API version and firmware version of the miner and return them as strings.

    Returns:
        A tuple of (API version, firmware version) as strings.
    """
    pass

get_wattage(*args, **kwargs) abstractmethod async

Get wattage from the miner as an int.

Returns:

Type Description
Optional[int]

Wattage of the miner as an int.

Source code in pyasic/miners/base.py
326
327
328
329
330
331
332
333
@abstractmethod
async def get_wattage(self, *args, **kwargs) -> Optional[int]:
    """Get wattage from the miner as an int.

    Returns:
        Wattage of the miner as an int.
    """
    pass

get_wattage_limit(*args, **kwargs) abstractmethod async

Get wattage limit from the miner as an int.

Returns:

Type Description
Optional[int]

Wattage limit of the miner as an int.

Source code in pyasic/miners/base.py
335
336
337
338
339
340
341
342
@abstractmethod
async def get_wattage_limit(self, *args, **kwargs) -> Optional[int]:
    """Get wattage limit from the miner as an int.

    Returns:
        Wattage limit of the miner as an int.
    """
    pass

is_mining(*args, **kwargs) abstractmethod async

Check whether the miner is mining.

Returns:

Type Description
Optional[bool]

A boolean value representing if the miner is mining.

Source code in pyasic/miners/base.py
398
399
400
401
402
403
404
405
@abstractmethod
async def is_mining(self, *args, **kwargs) -> Optional[bool]:
    """Check whether the miner is mining.

    Returns:
        A boolean value representing if the miner is mining.
    """
    pass

reboot() abstractmethod async

Reboot the miner and return success as a boolean.

Returns:

Type Description
bool

A boolean value of the success of rebooting the miner.

Source code in pyasic/miners/base.py
184
185
186
187
188
189
190
191
@abstractmethod
async def reboot(self) -> bool:
    """Reboot the miner and return success as a boolean.

    Returns:
        A boolean value of the success of rebooting the miner.
    """
    pass

restart_backend() abstractmethod async

Restart the mining process of the miner (bosminer, bmminer, cgminer, etc) and return success as a boolean.

Returns:

Type Description
bool

A boolean value of the success of restarting the mining process.

Source code in pyasic/miners/base.py
193
194
195
196
197
198
199
200
@abstractmethod
async def restart_backend(self) -> bool:
    """Restart the mining process of the miner (bosminer, bmminer, cgminer, etc) and return success as a boolean.

    Returns:
        A boolean value of the success of restarting the mining process.
    """
    pass

resume_mining() abstractmethod async

Resume the mining process of the miner.

Returns:

Type Description
bool

A boolean value of the success of resuming the mining process.

Source code in pyasic/miners/base.py
221
222
223
224
225
226
227
228
@abstractmethod
async def resume_mining(self) -> bool:
    """Resume the mining process of the miner.

    Returns:
        A boolean value of the success of resuming the mining process.
    """
    pass

send_config(config, user_suffix=None) abstractmethod async

Set the mining configuration of the miner.

Parameters:

Name Type Description Default
config MinerConfig

A MinerConfig containing the mining config you want to switch the miner to.

required
user_suffix str

A suffix to append to the username when sending to the miner.

None
Source code in pyasic/miners/base.py
202
203
204
205
206
207
208
209
210
@abstractmethod
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
    """Set the mining configuration of the miner.

    Parameters:
        config: A [`MinerConfig`][pyasic.config.MinerConfig] containing the mining config you want to switch the miner to.
        user_suffix: A suffix to append to the username when sending to the miner.
    """
    return None

set_power_limit(wattage) abstractmethod async

Set the power limit to be used by the miner.

Parameters:

Name Type Description Default
wattage int

The power limit to set on the miner.

required

Returns:

Type Description
bool

A boolean value of the success of setting the power limit.

Source code in pyasic/miners/base.py
230
231
232
233
234
235
236
237
238
239
240
@abstractmethod
async def set_power_limit(self, wattage: int) -> bool:
    """Set the power limit to be used by the miner.

    Parameters:
        wattage: The power limit to set on the miner.

    Returns:
        A boolean value of the success of setting the power limit.
    """
    pass

stop_mining() abstractmethod async

Stop the mining process of the miner.

Returns:

Type Description
bool

A boolean value of the success of stopping the mining process.

Source code in pyasic/miners/base.py
212
213
214
215
216
217
218
219
@abstractmethod
async def stop_mining(self) -> bool:
    """Stop the mining process of the miner.

    Returns:
        A boolean value of the success of stopping the mining process.
    """
    pass