Schnitzel / hass-miner

Controll your Bitcoin miner from Home Assistant
MIT License
53 stars 17 forks source link

Can't set power limit (S9, Braiins) #380

Open wilfredallyn opened 5 days ago

wilfredallyn commented 5 days ago

Version of the custom_component

1.1.14

Configuration

default_config:

frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

logger:
  default: info
  logs:
    custom_components.miner: debug

Describe the bug

When I use the slider in Home Assistant to set the power limit to 500w, the power will jump to 1400w and wipe out any other settings (e.g., pool info)

Steps

Debug log

2024-09-16 09:12:03.502 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S9 (BOS+): 192.168.1.145
2024-09-16 09:12:04.202 DEBUG (MainThread) [custom_components.miner.coordinator] Got data: MinerData(ip='192.168.1.145', datetime='2024-09-16T09:12:03.502567-04:00', timestamp=1726492323, device_info=DeviceInfo(make=<MinerMake.ANTMINER: 'AntMiner'>, model=<AntminerModels.S9: 'S9'>, firmware=<MinerFirmware.BRAIINS_OS: 'BOS+'>, algo=SHA256Algo), make='AntMiner', model='S9', firmware='BOS+', algo='SHA256', mac=[MAC], api_ver=None, fw_ver='21.04', hostname='miner-70eb6e', hashrate=13.958169809112167 TH/s, expected_hashrate=14.01 TH/s, expected_hashboards=3, expected_chips=189, expected_fans=2, percent_expected_chips=100, percent_expected_hashrate=100, percent_expected_wattage=0, temperature_avg=71, env_temp=None, wattage=0, wattage_limit=100, voltage=None, fans=[Fan(speed=2400), Fan(speed=2580)], fan_psu=None, hashboards=[HashBoard(slot=0, hashrate=4.606084842472842 TH/s, temp=69, chip_temp=84, chips=63, expected_chips=63, serial_number=None, missing=False, tuned=None, active=None, voltage=None), HashBoard(slot=1, hashrate=4.757578760278149 TH/s, temp=71, chip_temp=86, chips=63, expected_chips=63, serial_number=None, missing=False, tuned=None, active=None, voltage=None), HashBoard(slot=2, hashrate=4.594506206361177 TH/s, temp=72, chip_temp=87, chips=63, expected_chips=63, serial_number=None, missing=False, tuned=None, active=None, voltage=None)], total_chips=189, nominal=True, config=None, fault_light=None, errors=[], is_mining=True, uptime=None, efficiency=0, pools=[])
2024-09-16 09:12:04.202 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching miner-xxx data in 0.706 seconds (success: True)
2024-09-16 09:12:11.991 DEBUG (MainThread) [custom_components.miner.number] miner-xxx: setting power limit to 500.0.
2024-09-16 09:12:17.504 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: Unknown (BOS+): 192.168.1.145
2024-09-16 09:12:23.951 DEBUG (MainThread) [custom_components.miner.coordinator] Got data: MinerData(ip='192.168.1.145', datetime='2024-09-16T09:12:17.504827-04:00', timestamp=1726492337, device_info=DeviceInfo(make=None, model=None, firmware=<MinerFirmware.BRAIINS_OS: 'BOS+'>, algo=SHA256Algo), make=None, model=None, firmware='BOS+', algo='SHA256', mac=[MAC], api_ver=None, fw_ver='21.04', hostname='miner-70eb6e', hashrate=0.004581298449066667 TH/s, expected_hashrate=14.01 TH/s, expected_hashboards=3, expected_chips=0, expected_fans=2, percent_expected_chips=0, percent_expected_hashrate=0, percent_expected_wattage=0, temperature_avg=0, env_temp=None, wattage=0, wattage_limit=1420, voltage=None, fans=[Fan(speed=2760), Fan(speed=2940)], fan_psu=None, hashboards=[HashBoard(slot=0, hashrate=0.004581298449066667 TH/s, temp=0, chip_temp=0, chips=63, expected_chips=None, serial_number=None, missing=False, tuned=None, active=None, voltage=None), HashBoard(slot=1, hashrate=0.0 TH/s, temp=0, chip_temp=0, chips=63, expected_chips=None, serial_number=None, missing=False, tuned=None, active=None, voltage=None), HashBoard(slot=2, hashrate=0.0 TH/s, temp=0, chip_temp=0, chips=63, expected_chips=None, serial_number=None, missing=False, tuned=None, active=None, voltage=None)], total_chips=189, nominal=False, config=None, fault_light=None, errors=[], is_mining=True, uptime=None, efficiency=0, pools=[])
2024-09-16 09:12:23.951 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching miner-xxx data in 9.455 seconds (success: True)

It thinks it sets the power limit correctly to 500w without any error. Also, after setting the power limit, it doesn't know the make and model.

Before changing power:

After changing power:

Questions

I have some familiarity with the home assistant and pyasic codebases, so I can help debug if you point me to the code to look at. Thanks!

b-rowan commented 5 days ago

It's a problem with v1.1.14, it's seems like it's been having some issues. The config isn't being gathered properly from that miner, and so when you set it, everything is being reset to defaults.

Try with v1.1.15rc3 and see if it works any better.

wilfredallyn commented 4 days ago

I ran it with v1.1.15, and it did not fix the issue. Where in the code should I look to debug this?

b-rowan commented 4 days ago

The function used by pyasic to do this is set_power_limit, but for a BOSMiner S9 that uses get_config internally.

Best thing you could do likely is send the contents of /etc/bosminer.toml from the miner before updating the config. Also, make sure the miner is on the most recent version for S9s (22.08.1).

b-rowan commented 4 days ago

It should also say in the miner logs what the issue is, but it seems like a formatting issue with the config. Not sure what exactly the problem would be though, so knowing what key it doesn't like would help.