github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/doc/content/en/docs/plugins/cgminer/bitmine.md (about)

     1  
     2  ---
     3  title: "Bitmine"
     4  linkTitle: "bitmine"
     5  date: 2021-10-20
     6  description: >
     7  
     8  ---
     9  
    10  Working with Bitmine Antminer ASIC devices.
    11  
    12  Supported devices:
    13  * S9
    14  * S7
    15  * L3
    16  * L3
    17  * D3
    18  * T9
    19  
    20  ### JavaScript Properties
    21  
    22  ----------------
    23  
    24  ### Miner Base Entity
    25  
    26  ```javascript
    27  // Constant with the unique device ID
    28  const ENTITY_ID;
    29  ```
    30  
    31  ```javascript
    32  const result = Miner
    33      .stats()
    34      .devs()
    35      .summary()
    36      .pools()
    37      .addPool(url)
    38      .version()
    39      .enable(poolId)
    40      .disable(poolId)
    41      .delete(poolId)
    42      .switchPool(poolId)
    43      .restart();
    44  ```
    45  
    46  |  Property  | Description  |
    47  |-------------|---------|
    48  | result |    Type: Object (Result)   |
    49  
    50  |  Property  | Description  |
    51  |-------------|---------|
    52  | stats |   Type: Method, statistics    |
    53  | devs |   Type: Method, statistics    |
    54  | summary |   Type: Method, statistics    |
    55  | pools |   Type: Method, server list   |
    56  | addPool |   Type: Method, add server   |
    57  | version |   Type: Method, firmware version  |
    58  | enable |   Type: Method, enable server  |
    59  | disable |   Type: Method, disable server  |
    60  | delete |   Type: Method, delete server  |
    61  | switchPool |   Type: Method, switch server  |
    62  | restart |   Type: Method, soft device restart  |
    63  
    64  ----------------
    65  
    66  ### Result Object
    67  
    68  ```javascript
    69  const result = {
    70    error: false,
    71    errMessage: "",
    72    result: ""
    73  };
    74  ``` 
    75  |  Property  | Description  |
    76  |-------------|---------|
    77  | error |    Type: boolean, error indicator   |
    78  | errMessage |   Type: string, human-readable error message  |
    79  | result | Type: string, JSON object in string format, if the request is completed without errors |
    80  
    81  ----------------
    82  
    83  ### entityAction Function
    84  
    85  ```javascript
    86  entityAction = (entityId, actionName, args) => {
    87  }
    88  ```
    89  | Property  | Description  |
    90  |-------------|---------|
    91  | entityId |    Type: string, ID of the entity sending the message   |
    92  | actionName |   Type: string, name of the action, in uppercase without the '/' symbol  |
    93  | args | Type: map[string]any |
    94  
    95  ----------------
    96  
    97  ### EntityStateParams Object
    98  
    99  ```javascript
   100  const entityStateParams = {
   101    "new_state": "",
   102    "attribute_values": {},
   103    "settings_value": {},
   104    "storage_save": true
   105  };
   106  ``` 
   107  |  Property  | Description  |
   108  |-------------|---------|
   109  | new_state |    Type: *string, name of the new state   |
   110  | attribute_values |   Type: Object, new state of the entity's attributes |
   111  | settings_value | Type: Object, new state of the entity's settings |
   112  | storage_save | Type: boolean, indicator to save the new state to the database |
   113  
   114  ----------------
   115  
   116  ### Code Example
   117  
   118  ```coffeescript
   119  # cgminer
   120  # ##################################
   121  
   122  ifError =(res)->
   123    return !res || res.error || res.Error
   124  
   125  checkStatus =(args)->
   126    stats = Miner.stats()
   127    if ifError(stats)
   128      EntitySetState ENTITY_ID,
   129        'new_state': 'ERROR'
   130      return
   131    p = JSON.parse(stats.result)
   132    print p
   133  
   134  checkSum =(args)->
   135    summary = Miner.summary()
   136    if ifError(summary)
   137      EntitySetState ENTITY_ID,
   138        'new_state': 'ERROR'
   139      return
   140    p = JSON.parse(summary.result)
   141    print p
   142  
   143  entityAction = (entityId, actionName, args)->
   144    switch actionName
   145      when 'CHECK' then checkStatus(args)
   146      when 'SUM' then checkSum(args)
   147  ```