-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S19 Stock Firmware does not respond to start / stop mining toggle switch. #424
Comments
Seems like the switch was toggling resume, but didn't log a shutdown? It doesn't use the SSH credentials, it sends to the web UI |
@b-rowan Whilst looking at the post data I saw the values for mode are: 0 = Normal This is the latest/last firmware for the S19, so really the integer values should be submitted in favour of string. BUT considering this is such a basic issue that you are already aware of I suspect we are dealing with a set of mode constants that are reused across all 'antminers' , is that correct? I really need to be able to switch between modes 0, 1, 3 for my automations in HA. Any ideas on how to resolve this would be great. |
Yeah pretty much. Here's a reference for the file that does this - https://github.com/UpstreamData/pyasic/blob/master/pyasic/config/mining/__init__.py It also is defaulting to using an int, so not sure if that's the specific issue, but I've tested this lots (wayyy too much actually lol), so idk what could be going wrong. |
@b-rowan How best for me to intercept/log the POST data being sent from HA/pyasic to my miner? Also is there supposed to be an exposed control in HA for setting the low power mode? Apart from sensors I only havea one control exposed , and that's the active toggle switch |
There is no exposed item for low power mode. Honestly it's easiest if you just install BraiinsOS on the miner, they have much less stupid on/off design, and you can set a power limit in addition to on/off. With regards to intercepting it, you pretty much need to use wireshark or something. |
@b-rowan The stock firmware with the three modes fits my use case, so hopefully I don't need to run BraiinsOS firmware with dev fee. Pyasic has the s19 stock firmware as supported so this should work out. It is also aware of the low power mode, so I should be able to get a control for that in HA. Any reason why a dropdown select is not offered for power mode? |
Mainly because I'm too stupid to know how to do that in home assistant...
I'm very aware of that, considering I wrote the thing. X19 has been a consistent problem on stock firmware, seems like they change stuff every so often that is just completely incompatible. |
@b-rowan You have a much broader perspective on this. I have a narrow focus on my S19 that is very unlikely to get any more firmware updates from antminer, it hasn't since 2022. So I think there is a solution here worth implementing, one that will stick. I will keep looking. Thanks. |
I agree, I just need to figure out how to get it into HASS in a nice way. |
Was hoping to inject a logger dump in pyasic directly to dump all POST data. Unfortunately the HAOS SSH environment seems to be restricted , even hiding things from me. I cant find the pyasic lib used by hass-miner. Do you know how to access it? Logging the HTTP coms between pyasic and miner should be easier than this right? |
Should be able to edit it in Pyasic uses httpx, so if you up the loglevel for that it might be useful, but HASS uses it too... |
Yeah I found the component, and can see it imports pyasic, but there is no trace of any python deps on the filesystem when I search. So cant get to httpx either. Maybe things are hidden because I am accessing via the I guess I will have to hook up a monitor and keyboard directly and try again, another day. |
@b-rowan
So this confirms that GET requests for status are working as expected. And that the correct miner-mode is being sent when attempting to toggle the active state. BUT we have a HTTP error when posting to It appears to be a timeout issue. Any idea what the problem is here? For comparison, here is the JSON payload sent via Antminer backed UI to
Taking about 13 seconds to respond with payload:
The only difference in POST payload is the order of params and that the boolean value for "bitmain-fan-ctrl" is lower case on backend UI post vs Capitalised on pyasic post. |
@b-rowan {"bitmain-fan-ctrl":False,"bitmain-fan-pwm":"100","miner-mode":0,"freq-level":"100","pools":[REDACTED]} This results in response
Changing back to lower case make the requests successful.
So it looks like pyasic antminer.py needs to be updated to send lower case boolean, at least for the S19. EDIT: Scrap that. I was debug logging the parameters var that appeared to be json in log but I realise now that it is just the format debug outputs when it converts the obj to string. The client Also tried order of params in the post payload - not the issue. |
I was gonna say, but good catch. This is a weird issue, it seriously seems like the miner is attempting to apply the change and failing, but usually it doesn't timeout like that. That being said, AFAIU on the web UI, it doesn't timeout take a while for the command to get sent and applied, so it's possible the timeout is just too short or something, but the miner settings should still update. |
You're doing enough work here inside a hass docker container, it might just be easier to run up Python on another machine, install pyasic, and test with that. The commands are pretty easy, basically get_miner into get_config into send_config. Can write a script if you need one. |
@b-rowan
Was hoping a simple debug log on the post data would point to the issue.... oh well. I might try and run pyasic and put the debug on httpx to see what the actual json payload looks like. Another day! |
I set up a command line script using effectively the same post method with Auth.Digest. The script works.
As you can see in this example, simply sending the I'm not sure what is going on with the hass-miner->pyasic post request for it to effectively do nothing. I can only guess it is something to do with timeouts or perhaps there is more than one request being fired off at the same time or too many requests too close to each other. It is hard to pin down that's for sure. Control of the miner through automation is the most valuable feature, so it's a shame it doesn't work with Antminer firmware. If this integration had a dropdown that could change mode and also serve as a readout for current active mode, it would be so perfect. I will most likely add this simple HTTP post script as a service in HA, hook up some switches/buttons, tie it into some automation and be done with it. Sorry I couldn't figure it out, I can only hope there is a clue in here somewhere that helps you find and fix the issue. |
No worries man, you did a lot more than I expect for most people when troubleshooting stuff like this. Thanks for all the help. Sadly I'm not really sure what the issue is here even after all that, but I will look into adding a dropdown, and maybe that will help. |
I found something really interesting while reworking some pyasic internals, namely that the values for the config were not initialized properly when setting sleep/normal mode. Not sure how I didn't catch this before, but should hopefully be out in the next major version once all my other changes get merged. Here's the changes (the ones in |
@b-rowan does this mean it will be possible to control sleep/normal/low power mode for stock Antminer firmware? If that is the case, it sounds awesome! |
No, not that specifically, it just means that the device will actually be able to shut down now. That being said however, I did sit down and spend some time today doing that part of the integration with a select dropdown, its on 1.1.19rc2 if anyone wants to try it out and lmk if it works 😉 ... |
Dropdown would be amazing. Is there a way to run a RC/pre release in HACS? Eager for this to replace my work around for setting miner mode using shell_command in (config yaml) and input buttons (helpers).
Dropdown would be so much tidier and give feedback on which mode is currently active. |
I think you just redownload with the allow prereleases option? Mine just shows pre-releases, I might have changed a setting a while ago... |
@b-rowan |
You might have to reistall the device? |
@b-rowan |
Ok, I think I fixed it after some extensive testing, it should allow you to set power mode in 1.1.19. |
@b-rowan I updated to the last release and the dropdown selection showed up for the power select for stock Antminer firmware, thank you! But the options are Normal, High and Low so it works to change between Normal which is also High and Low power mode, but seems that none of them are triggering the sleep mode. Is it possible to add a selection for sleep? |
Sleep mode is the active trigger, they have to be separate because they are handled different for different miners in pyasic. You can turn off the miner with the active switch, then turn them back on with the mode selector. |
First time trying this out on HA.
I am unable to start or stop mining using the toggle switch
switch.antminer_s19_active
. It has no effect either way.Here is the debug log when trying to Resume mining when the miner is in 'sleep mode'
Running the last available stock firmware
Antminer-S19-merge-release-20221227070716.bmu
I have confirmed that I am able to login via SSH and backend using same credentials passed to HA integration.
Any tricks to getting this working on stock firmware?
`
The text was updated successfully, but these errors were encountered: