Skip to content

Standard Functionality

Control functionality

All control functionality is outlined by the MinerProtocol class.

Miner Protocol

Bases: Protocol

Source code in pyasic/miners/base.py
 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
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
class MinerProtocol(Protocol):
    _rpc_cls: Type = None
    _web_cls: Type = None
    _ssh_cls: Type = None

    ip: str = None
    rpc: _rpc_cls = None
    web: _web_cls = None
    ssh: _ssh_cls = None

    make: MinerMake = None
    raw_model: MinerModelType = None
    firmware: MinerFirmware = None
    algo: type[MinerAlgoType] = GenericAlgo

    expected_hashboards: int = None
    expected_chips: int = None
    expected_fans: int = None

    data_locations: DataLocations = None

    supports_shutdown: bool = False
    supports_power_modes: bool = False
    supports_presets: bool = False
    supports_autotuning: bool = False

    api_ver: str = None
    fw_ver: str = None
    light: bool = None
    config: MinerConfig = None

    def __repr__(self):
        return f"{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 model(self) -> str:
        if self.raw_model is not None:
            model_data = [self.raw_model]
        elif self.make is not None:
            model_data = [self.make]
        else:
            model_data = ["Unknown"]
        if self.firmware is not None:
            model_data.append(f"({self.firmware})")
        return " ".join(model_data)

    @property
    def device_info(self) -> DeviceInfo:
        return DeviceInfo(
            make=self.make, model=self.raw_model, firmware=self.firmware, algo=self.algo
        )

    @property
    def api(self):
        return self.rpc

    async def check_light(self) -> bool:
        """Get the status of the fault light as a boolean.

        Returns:
            A boolean value representing the fault light status.
        """
        return await self.get_fault_light()

    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.
        """
        return False

    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.
        """
        return False

    async def get_config(self) -> MinerConfig:
        # Not a data gathering function, since this is used for configuration
        """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.
        """
        return MinerConfig()

    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.
        """
        return False

    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.
        """
        return False

    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

    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.
        """
        return False

    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.
        """
        return False

    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.
        """
        return False

    async def upgrade_firmware(
        self,
        *,
        file: str = None,
        url: str = None,
        version: str = None,
        keep_settings: bool = True,
    ) -> bool:
        """Upgrade the firmware of the miner.

        Parameters:
            file: The file path to the firmware to upgrade from. Must be a valid file path if provided.
            url: The URL to download the firmware from. Must be a valid URL if provided.
            version: The version of the firmware to upgrade to. If None, the version will be inferred from the file or URL.
            keep_settings: Whether to keep the current settings during the upgrade. Defaults to True.

        Returns:
            A boolean value of the success of the firmware upgrade.
        """
        return False

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

    async def get_mac(self) -> 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.
        """
        return await self._get_mac()

    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

    async def get_device_info(self) -> Optional[DeviceInfo]:
        """Get device information, including model, make, and firmware.

        Returns:
            A dataclass containing device information.
        """
        return self.device_info

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

        Returns:
            API version as a string.
        """
        return await self._get_api_ver()

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

        Returns:
            Firmware version as a string.
        """
        return await self._get_fw_ver()

    async def get_version(self) -> 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.
        """
        api_ver = await self.get_api_ver()
        fw_ver = await self.get_fw_ver()
        return api_ver, fw_ver

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

        Returns:
            A string representing the hostname of the miner.
        """
        return await self._get_hostname()

    async def get_hashrate(self) -> Optional[AlgoHashRate]:
        """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.
        """
        return await self._get_hashrate()

    async def get_hashboards(self) -> 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.
        """
        return await self._get_hashboards()

    async def get_env_temp(self) -> Optional[float]:
        """Get environment temp from the miner as a float.

        Returns:
            Environment temp of the miner as a float.
        """
        return await self._get_env_temp()

    async def get_wattage(self) -> Optional[int]:
        """Get wattage from the miner as an int.

        Returns:
            Wattage of the miner as an int.
        """
        return await self._get_wattage()

    async def get_voltage(self) -> Optional[float]:
        """Get output voltage of the PSU as a float.

        Returns:
            Output voltage of the PSU as an float.
        """
        return await self._get_voltage()

    async def get_wattage_limit(self) -> Optional[int]:
        """Get wattage limit from the miner as an int.

        Returns:
            Wattage limit of the miner as an int.
        """
        return await self._get_wattage_limit()

    async def get_fans(self) -> 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.
        """
        return await self._get_fans()

    async def get_fan_psu(self) -> Optional[int]:
        """Get PSU fan speed from the miner.

        Returns:
            PSU fan speed.
        """
        return await self._get_fan_psu()

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

        Returns:
            A list of error classes representing different errors.
        """
        return await self._get_errors()

    async def get_fault_light(self) -> 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.
        """
        return await self._get_fault_light()

    async def get_expected_hashrate(self) -> Optional[AlgoHashRate]:
        """Get the nominal hashrate from factory if available.

        Returns:
            A float value of nominal hashrate in TH/s.
        """
        return await self._get_expected_hashrate()

    async def is_mining(self) -> Optional[bool]:
        """Check whether the miner is mining.

        Returns:
            A boolean value representing if the miner is mining.
        """
        return await self._is_mining()

    async def get_uptime(self) -> Optional[int]:
        """Get the uptime of the miner in seconds.

        Returns:
            The uptime of the miner in seconds.
        """
        return await self._get_uptime()

    async def get_pools(self) -> List[PoolMetrics]:
        """Get the pools information from Miner.

        Returns:
            The pool information of the miner.
        """
        return await self._get_pools()

    async def _get_mac(self) -> Optional[str]:
        pass

    async def _get_api_ver(self) -> Optional[str]:
        pass

    async def _get_fw_ver(self) -> Optional[str]:
        pass

    async def _get_hostname(self) -> Optional[str]:
        pass

    async def _get_hashrate(self) -> Optional[AlgoHashRate]:
        pass

    async def _get_hashboards(self) -> List[HashBoard]:
        return []

    async def _get_env_temp(self) -> Optional[float]:
        pass

    async def _get_wattage(self) -> Optional[int]:
        pass

    async def _get_voltage(self) -> Optional[float]:
        pass

    async def _get_wattage_limit(self) -> Optional[int]:
        pass

    async def _get_fans(self) -> List[Fan]:
        return []

    async def _get_fan_psu(self) -> Optional[int]:
        pass

    async def _get_errors(self) -> List[MinerErrorData]:
        return []

    async def _get_fault_light(self) -> Optional[bool]:
        pass

    async def _get_expected_hashrate(self) -> Optional[AlgoHashRate]:
        pass

    async def _is_mining(self) -> Optional[bool]:
        pass

    async def _get_uptime(self) -> Optional[int]:
        pass

    async def _get_pools(self) -> List[PoolMetrics]:
        pass

    async def _get_data(
        self,
        allow_warning: bool,
        include: List[Union[str, DataOptions]] = None,
        exclude: List[Union[str, DataOptions]] = None,
    ) -> dict:
        # handle include
        if include is not None:
            include = [str(i) for i in include]
        else:
            # everything
            include = [str(enum_value.value) for enum_value in DataOptions]

        # handle exclude
        # prioritized over include, including x and excluding x will exclude x
        if exclude is not None:
            for item in exclude:
                if str(item) in include:
                    include.remove(str(item))

        rpc_multicommand = set()
        web_multicommand = set()
        # create multicommand
        for data_name in include:
            try:
                # get kwargs needed for the _get_xyz function
                fn_args = getattr(self.data_locations, data_name).kwargs

                # keep track of which RPC/Web commands need to be sent
                for arg in fn_args:
                    if isinstance(arg, RPCAPICommand):
                        rpc_multicommand.add(arg.cmd)
                    if isinstance(arg, WebAPICommand):
                        web_multicommand.add(arg.cmd)
            except KeyError as e:
                logger.error(type(e), e, data_name)
                continue

        # create tasks for all commands that need to be sent, or no-op with sleep(0) -> None
        if len(rpc_multicommand) > 0:
            rpc_command_task = asyncio.create_task(
                self.rpc.multicommand(*rpc_multicommand, allow_warning=allow_warning)
            )
        else:
            rpc_command_task = asyncio.create_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.create_task(asyncio.sleep(0))

        # make sure the tasks complete
        await asyncio.gather(rpc_command_task, web_command_task)

        # grab data out of the tasks
        web_command_data = web_command_task.result()
        if web_command_data is None:
            web_command_data = {}
        api_command_data = rpc_command_task.result()
        if api_command_data is None:
            api_command_data = {}

        miner_data = {}

        for data_name in include:
            try:
                fn_args = getattr(self.data_locations, data_name).kwargs
                args_to_send = {k.name: None for k in fn_args}
                for arg in fn_args:
                    try:
                        if isinstance(arg, RPCAPICommand):
                            if api_command_data.get("multicommand"):
                                args_to_send[arg.name] = api_command_data[arg.cmd][0]
                            else:
                                args_to_send[arg.name] = api_command_data
                        if isinstance(arg, WebAPICommand):
                            if web_command_data is not None:
                                if web_command_data.get("multicommand"):
                                    args_to_send[arg.name] = web_command_data[arg.cmd]
                                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
            try:
                function = getattr(self, getattr(self.data_locations, data_name).cmd)
                miner_data[data_name] = await function(**args_to_send)
            except Exception as e:
                raise APIError(
                    f"Failed to call {data_name} on {self} while getting data."
                ) from e
        return miner_data

    async def get_data(
        self,
        allow_warning: bool = False,
        include: List[Union[str, DataOptions]] = None,
        exclude: List[Union[str, DataOptions]] = 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),
            device_info=self.device_info,
            expected_chips=(
                self.expected_chips * self.expected_hashboards
                if self.expected_chips is not None
                else 0
            ),
            expected_hashboards=self.expected_hashboards,
            expected_fans=self.expected_fans,
            hashboards=[
                HashBoard(slot=i, expected_chips=self.expected_chips)
                for i in range(
                    self.expected_hashboards
                    if self.expected_hashboards is not None
                    else 0
                )
            ],
        )

        gathered_data = await self._get_data(
            allow_warning=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

check_light() async

Get the status of the fault light as a boolean.

Returns:

Type Description
bool

A boolean value representing the fault light status.

Source code in pyasic/miners/base.py
async def check_light(self) -> bool:
    """Get the status of the fault light as a boolean.

    Returns:
        A boolean value representing the fault light status.
    """
    return await self.get_fault_light()

fault_light_off() 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
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.
    """
    return False

fault_light_on() 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
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.
    """
    return False

get_api_ver() 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
async def get_api_ver(self) -> Optional[str]:
    """Get the API version of the miner and is as a string.

    Returns:
        API version as a string.
    """
    return await self._get_api_ver()

get_config() 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
async def get_config(self) -> MinerConfig:
    # Not a data gathering function, since this is used for configuration
    """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.
    """
    return MinerConfig()

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[Union[str, DataOptions]]

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

None
exclude List[Union[str, DataOptions]]

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
async def get_data(
    self,
    allow_warning: bool = False,
    include: List[Union[str, DataOptions]] = None,
    exclude: List[Union[str, DataOptions]] = 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),
        device_info=self.device_info,
        expected_chips=(
            self.expected_chips * self.expected_hashboards
            if self.expected_chips is not None
            else 0
        ),
        expected_hashboards=self.expected_hashboards,
        expected_fans=self.expected_fans,
        hashboards=[
            HashBoard(slot=i, expected_chips=self.expected_chips)
            for i in range(
                self.expected_hashboards
                if self.expected_hashboards is not None
                else 0
            )
        ],
    )

    gathered_data = await self._get_data(
        allow_warning=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_device_info() async

Get device information, including model, make, and firmware.

Returns:

Type Description
Optional[DeviceInfo]

A dataclass containing device information.

Source code in pyasic/miners/base.py
async def get_device_info(self) -> Optional[DeviceInfo]:
    """Get device information, including model, make, and firmware.

    Returns:
        A dataclass containing device information.
    """
    return self.device_info

get_env_temp() 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
async def get_env_temp(self) -> Optional[float]:
    """Get environment temp from the miner as a float.

    Returns:
        Environment temp of the miner as a float.
    """
    return await self._get_env_temp()

get_errors() 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
async def get_errors(self) -> List[MinerErrorData]:
    """Get a list of the errors the miner is experiencing.

    Returns:
        A list of error classes representing different errors.
    """
    return await self._get_errors()

get_expected_hashrate() async

Get the nominal hashrate from factory if available.

Returns:

Type Description
Optional[AlgoHashRate]

A float value of nominal hashrate in TH/s.

Source code in pyasic/miners/base.py
async def get_expected_hashrate(self) -> Optional[AlgoHashRate]:
    """Get the nominal hashrate from factory if available.

    Returns:
        A float value of nominal hashrate in TH/s.
    """
    return await self._get_expected_hashrate()

get_fan_psu() async

Get PSU fan speed from the miner.

Returns:

Type Description
Optional[int]

PSU fan speed.

Source code in pyasic/miners/base.py
async def get_fan_psu(self) -> Optional[int]:
    """Get PSU fan speed from the miner.

    Returns:
        PSU fan speed.
    """
    return await self._get_fan_psu()

get_fans() 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
async def get_fans(self) -> 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.
    """
    return await self._get_fans()

get_fault_light() 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
async def get_fault_light(self) -> 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.
    """
    return await self._get_fault_light()

get_fw_ver() 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
async def get_fw_ver(self) -> Optional[str]:
    """Get the firmware version of the miner and is as a string.

    Returns:
        Firmware version as a string.
    """
    return await self._get_fw_ver()

get_hashboards() 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
async def get_hashboards(self) -> 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.
    """
    return await self._get_hashboards()

get_hashrate() async

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

Returns:

Type Description
Optional[AlgoHashRate]

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

Source code in pyasic/miners/base.py
async def get_hashrate(self) -> Optional[AlgoHashRate]:
    """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.
    """
    return await self._get_hashrate()

get_hostname() 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
async def get_hostname(self) -> Optional[str]:
    """Get the hostname of the miner and return it as a string.

    Returns:
        A string representing the hostname of the miner.
    """
    return await self._get_hostname()

get_mac() 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
async def get_mac(self) -> 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.
    """
    return await self._get_mac()

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
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_pools() async

Get the pools information from Miner.

Returns:

Type Description
List[PoolMetrics]

The pool information of the miner.

Source code in pyasic/miners/base.py
async def get_pools(self) -> List[PoolMetrics]:
    """Get the pools information from Miner.

    Returns:
        The pool information of the miner.
    """
    return await self._get_pools()

get_uptime() 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
async def get_uptime(self) -> Optional[int]:
    """Get the uptime of the miner in seconds.

    Returns:
        The uptime of the miner in seconds.
    """
    return await self._get_uptime()

get_version() 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
async def get_version(self) -> 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.
    """
    api_ver = await self.get_api_ver()
    fw_ver = await self.get_fw_ver()
    return api_ver, fw_ver

get_voltage() async

Get output voltage of the PSU as a float.

Returns:

Type Description
Optional[float]

Output voltage of the PSU as an float.

Source code in pyasic/miners/base.py
async def get_voltage(self) -> Optional[float]:
    """Get output voltage of the PSU as a float.

    Returns:
        Output voltage of the PSU as an float.
    """
    return await self._get_voltage()

get_wattage() 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
async def get_wattage(self) -> Optional[int]:
    """Get wattage from the miner as an int.

    Returns:
        Wattage of the miner as an int.
    """
    return await self._get_wattage()

get_wattage_limit() 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
async def get_wattage_limit(self) -> Optional[int]:
    """Get wattage limit from the miner as an int.

    Returns:
        Wattage limit of the miner as an int.
    """
    return await self._get_wattage_limit()

is_mining() 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
async def is_mining(self) -> Optional[bool]:
    """Check whether the miner is mining.

    Returns:
        A boolean value representing if the miner is mining.
    """
    return await self._is_mining()

reboot() 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
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.
    """
    return False

restart_backend() 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
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.
    """
    return False

resume_mining() 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
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.
    """
    return False

send_config(config, user_suffix=None) 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
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) 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
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.
    """
    return False

stop_mining() 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
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.
    """
    return False

upgrade_firmware(*, file=None, url=None, version=None, keep_settings=True) async

Upgrade the firmware of the miner.

Parameters:

Name Type Description Default
file str

The file path to the firmware to upgrade from. Must be a valid file path if provided.

None
url str

The URL to download the firmware from. Must be a valid URL if provided.

None
version str

The version of the firmware to upgrade to. If None, the version will be inferred from the file or URL.

None
keep_settings bool

Whether to keep the current settings during the upgrade. Defaults to True.

True

Returns:

Type Description
bool

A boolean value of the success of the firmware upgrade.

Source code in pyasic/miners/base.py
async def upgrade_firmware(
    self,
    *,
    file: str = None,
    url: str = None,
    version: str = None,
    keep_settings: bool = True,
) -> bool:
    """Upgrade the firmware of the miner.

    Parameters:
        file: The file path to the firmware to upgrade from. Must be a valid file path if provided.
        url: The URL to download the firmware from. Must be a valid URL if provided.
        version: The version of the firmware to upgrade to. If None, the version will be inferred from the file or URL.
        keep_settings: Whether to keep the current settings during the upgrade. Defaults to True.

    Returns:
        A boolean value of the success of the firmware upgrade.
    """
    return False