Schnitzel/hass-miner

error while add miner

Closed this issue · 15 comments

Error while add miner

Home Assistant 2023.6.1
Supervisor 2023.06.2
Operating System 10.2

Logger: custom_components.miner.config_flow
Source: custom_components/miner/config_flow.py:36
Integration: Miner (documentation, issues)
First occurred: 08:00:29 (6 occurrences)
Last logged: 08:06:17

Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/miner/config_flow.py", line 36, in validate_input
miner = await miner_factory.get_miner(miner_ip)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miners/miner_factory.py", line 96, in get_miner
new_model, new_api = await asyncio.wait_for(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
return fut.result()
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miners/miner_factory.py", line 271, in _get_miner_type
model = version["VERSION"][0]["Type"]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'Type'

This solution not help
#166

That should be fixed when we merge #39, it's an issue with a very old version of pyasic.

eek-nz commented

I have the identical first line issue and #166 was also not helpful. Is #39 merged yet? I'm too much of a noob to know.
My second line error is a little differnet:
File "/usr/local/lib/python3.11/site-packages/miners/miner_factory.py", line 154, in get_miner
if "BOSMiner" in api:
I am connecting to a BOS S19.
I've only had HASS-Miner installed for 2 days so it should be current. There are no updates outstanding on the HASS install.
Should I open it as a diffenet issue? I'm hopeful #39 isn't merged yet and it will resolve when it is.
No thread hijack intended but it appears to be the same issue.

If you're on the pre-release beta version, then yes, this is a bug. It'll be related to pyasic though it seems, likely not hass-miner itself. You can provide the whole trace back here and I'll see if I can solve it, or you can open a new issue for pyasic and I'll solve it there.

eek-nz commented

Sorry to be hopeless - How would I get a trace back? What I have I got from the logs, but it's only showing those couple of lines. I have that downloaded in a file. I reckon you're looking for something more pyasic specific.

Send whatever you can from that log, usually if you click the error log and click load full logs it will give you a full trackback.

eek-nz commented

Now I'm feeling bad about being both blind and thread hijacking. I see Traceback is right there in the logs. I just did a fresh one and the log output is:
Traceback (most recent call last):
File "/config/custom_components/miner/config_flow.py", line 36, in validate_input
miner = await miner_factory.get_miner(miner_ip)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miners/miner_factory.py", line 154, in get_miner
if "BOSMiner" in api:
^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

The miner is running BOS+ from SSD. I'm in NZ so my time zone is probably inconvenient.

No problem, we care more about getting problems fixed anyway, it's all still a beta so it's not super pertinent that everything be organized perfectly.

A little strange that error is coming up though, the package version for pyasic might need an update, as line 154 isn't inside the get_miner function, it's actually part of a mapping of miner types.

@Schnitzel latest version of pyasic is 0.37.6, can we pin to that for now?

Something is really outdated with your version of pyasic it seems now looking at it more closely. Maybe give uninstalling and reinstalling the whole HACS package a shot and see if that helps?

eek-nz commented

Sure. I've had HACS on a long time. Pretty sure there was an update I did last week. But I can give it a try. The only other thing in HACS is my Sonoff. I'm not using any of the Sonoff things in winter so it can break.

eek-nz commented

Took a minute to get HACS off. Got it off, checked I'm compliant to all reqs. Authorized it at Github, added the repo and installed. Ran through it all again. Error looks the same:

Logger: custom_components.miner.config_flow
Source: custom_components/miner/config_flow.py:36
Integration: Miner (documentation, issues)
First occurred: 3:33:13 PM (1 occurrences)
Last logged: 3:33:13 PM

Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/miner/config_flow.py", line 36, in validate_input
miner = await miner_factory.get_miner(miner_ip)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miners/miner_factory.py", line 154, in get_miner
if "BOSMiner" in api:
^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

Did a restart and checked again just to be sure. Same error.

Hmm. Maybe just have to wait until the pinned version gets updated then. I can't remember how HACS does dependency management or if it's possible to update it, but you could edit the manifest.json file for now to pin the right version if you want. Should be in custom components in your HASS root, you'd have to do it via SSH.

eek-nz commented

If the #39 thing hasn't happend yet, lets just wait till it has. No need to distract you if that might fix it anyway.
Thanks

If you're on the pre-release beta version, then yes, this is a bug. It'll be related to pyasic though it seems, likely not hass-miner itself. You can provide the whole trace back here and I'll see if I can solve it, or you can open a new issue for pyasic and I'll solve it there.

Great! Wasn't able to connect the miners with the stable release. Pre-release works for me 👍🏻

This has been addressed in v1.0.1.