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
 29
 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
class BaseMiner(ABC):
    def __init__(self, ip: str, *args, **kwargs) -> None:
        # interfaces
        self.api = None
        self.web = None

        # 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)

    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="root",
                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

    async def _get_data(self, allow_warning: bool, data_to_get: list = None) -> dict:
        if not data_to_get:
            # everything
            data_to_get = [
                "mac",
                "model",
                "api_ver",
                "fw_ver",
                "hostname",
                "hashrate",
                "nominal_hashrate",
                "hashboards",
                "env_temp",
                "wattage",
                "wattage_limit",
                "fans",
                "fan_psu",
                "errors",
                "fault_light",
                "pools",
            ]
        api_multicommand = []
        web_multicommand = []
        for data_name in data_to_get:
            try:
                fn_args = self.data_locations[data_name]["kwargs"]
                for arg_name in fn_args:
                    if fn_args[arg_name].get("api"):
                        api_multicommand.append(fn_args[arg_name]["api"])
                    if fn_args[arg_name].get("web"):
                        web_multicommand.append(fn_args[arg_name]["web"])
            except KeyError as e:
                print(e, data_name)
                continue

        api_multicommand = list(set(api_multicommand))
        _web_multicommand = web_multicommand
        for item in web_multicommand:
            if item not in _web_multicommand:
                _web_multicommand.append(item)
        web_multicommand = _web_multicommand
        if len(api_multicommand) > 0:
            api_command_data = await self.api.multicommand(
                *api_multicommand, allow_warning=allow_warning
            )
        else:
            api_command_data = {}
        if len(web_multicommand) > 0:
            web_command_data = await self.web.multicommand(
                *web_multicommand, allow_warning=allow_warning
            )
        else:
            web_command_data = {}

        miner_data = {}

        for data_name in data_to_get:
            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:
                    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.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 (KeyError, IndexError):
                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_2_url"]
                        miner_data["pool_2_user"] = pools_data[1]["pool_2_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, data_to_get: 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.
            data_to_get: Names of data items you want to gather. Defaults to all data.

        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, data_to_get=data_to_get)
        for item in gathered_data:
            if gathered_data[item] is not None:
                setattr(data, item, gathered_data[item])

        return data

fault_light_off() async abstractmethod

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
115
116
117
118
119
120
121
122
@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() async abstractmethod

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
106
107
108
109
110
111
112
113
@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) async abstractmethod

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
213
214
215
216
217
218
219
220
@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() async abstractmethod

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
124
125
126
127
128
129
130
131
132
@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, data_to_get=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
data_to_get list

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

None

Returns:

Type Description
MinerData

A MinerData instance containing data from the miner.

Source code in pyasic/miners/base.py
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
async def get_data(
    self, allow_warning: bool = False, data_to_get: 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.
        data_to_get: Names of data items you want to gather. Defaults to all data.

    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, data_to_get=data_to_get)
    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) async abstractmethod

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
267
268
269
270
271
272
273
274
@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) async abstractmethod

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
321
322
323
324
325
326
327
328
@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) async abstractmethod

Get PSU fan speed from the miner.

Returns:

Type Description
Optional[int]

PSU fan speed.

Source code in pyasic/miners/base.py
303
304
305
306
307
308
309
310
@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) async abstractmethod

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
294
295
296
297
298
299
300
301
@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) async abstractmethod

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
330
331
332
333
334
335
336
337
@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) async abstractmethod

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
222
223
224
225
226
227
228
229
@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) async abstractmethod

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
258
259
260
261
262
263
264
265
@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) async abstractmethod

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
249
250
251
252
253
254
255
256
@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) async abstractmethod

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
240
241
242
243
244
245
246
247
@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) async abstractmethod

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
196
197
198
199
200
201
202
203
@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
205
206
207
208
209
210
211
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) async abstractmethod

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
339
340
341
342
343
344
345
346
@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) async abstractmethod

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
312
313
314
315
316
317
318
319
@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_version(*args, **kwargs) async abstractmethod

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
231
232
233
234
235
236
237
238
@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) async abstractmethod

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
276
277
278
279
280
281
282
283
@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) async abstractmethod

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
285
286
287
288
289
290
291
292
@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

reboot() async abstractmethod

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
134
135
136
137
138
139
140
141
@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() async abstractmethod

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
143
144
145
146
147
148
149
150
@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() async abstractmethod

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
171
172
173
174
175
176
177
178
@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) async abstractmethod

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
152
153
154
155
156
157
158
159
160
@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) async abstractmethod

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
180
181
182
183
184
185
186
187
188
189
190
@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() async abstractmethod

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
162
163
164
165
166
167
168
169
@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