Skip to content
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

Integration seems broken under HA 2024.9.2 #374

Closed
gmint opened this issue Sep 17, 2024 · 37 comments · Fixed by #375
Closed

Integration seems broken under HA 2024.9.2 #374

gmint opened this issue Sep 17, 2024 · 37 comments · Fixed by #375

Comments

@gmint
Copy link

gmint commented Sep 17, 2024

Under HA 2024.9.2 I am able to add the integration and add miners (two S19s running BOS 24.0.3.1) but there are no entities available. I had this problem in a previous version and I was going to report it but removing and re-adding the integration and the devices resolved the issue. However, as of 2024.9.2 (running on VirtualBox) this no longer works and the integration seems to be non-functional.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

This is on v1.1.14? Anything in the logs?

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Sorry, yes, I tried under 1.1.14 and 1.1.14rc1. Here's what I've got from the logs:

Logger: homeassistant.helpers.entity_platform
Source: helpers/entity_platform.py:415
First occurred: 11:20:41 AM (15 occurrences)
Last logged: 11:38:19 AM

miner raises exception ConfigEntryNotReady in forwarded platform sensor; Instead raise ConfigEntryNotReady before calling async_forward_entry_setups
miner raises exception ConfigEntryNotReady in forwarded platform switch; Instead raise ConfigEntryNotReady before calling async_forward_entry_setups
miner raises exception ConfigEntryNotReady in forwarded platform number; Instead raise ConfigEntryNotReady before calling async_forward_entry_setups

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Alright, config entry timing again. Ill see what I can do about this, but this specific issue is pretty annoying since it doesnt seem to be well documented where im supposed to raise that error when the miner doesn't respond...

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Is there anything I can do to workaround? I'm having this issue on one HA install, but it doesn't seem to be happening on my other install. Just trying to make your life a little easier if possible.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Is there anything I can do to workaround? I'm having this issue on one HA install, but it doesn't seem to be happening on my other install. Just trying to make your life a little easier if possible.

Not really, its likely this will happen on multiple versions, and im not sure the exact circumstances that cause it. I'm looking into it, as others have raised this issue as well, just a bit difficult for me to emulate HASS without just spinning up an instance.

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Understood. I feel your pain. I tried my hand at developing an integration and I ultimately quit because I got no help from the HA devs (and they were actually quite rude).

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Understood. I feel your pain. I tried my hand at developing an integration and I ultimately quit because I got no help from the HA devs (and they were actually quite rude).

Yeah, I've asked about a couple things in the discord and not gotten any response. Quite disappointing, as HASS is a cool system.

For reference, here is the docs on how to do this "properly" - https://developers.home-assistant.io/docs/integration_setup_failures/#handling-offline-or-unavailable-devices-and-services

And the implementation in this repo -

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Miner from a config entry."""
miner_ip = entry.data[CONF_IP]
miner = await pyasic.get_miner(miner_ip)
if miner is None:
raise ConfigEntryNotReady("Miner could not be found.")
m_coordinator = MinerCoordinator(hass, entry)
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = m_coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
await async_setup_services(hass)
return True

From the docs -

Raise the ConfigEntryNotReady exception from async_setup_entry in the integration's __init__.py, and Home Assistant will automatically take care of retrying set up later.

Here, we have the async_setup_entry function in __init__py and it is raising ConfigEntryNotReady.

Log reports -

raise ConfigEntryNotReady before calling async_forward_entry_setups

This is irrelevant, as you can see above this is raised way before async_forward_entry_setup.

TL;DR: repo does EXACTLY as the documentation says, and it doesn't work?

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

From what I can see, it might be some weird conflict between DataUpdateCoordinator and the __init__.py async_setup_entry seems like they should be combined somehow?

https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Fixed with a PR I think, I'm going to release a rc version for testing.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Try v1.1.15rc1

@gmint
Copy link
Author

gmint commented Sep 17, 2024

It looks to be retrying automatically now but I'm now getting:

Failed Setup, will retry: Unknown error

This time I'm not really seeing anything in the logs.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

It looks to be retrying automatically now but I'm now getting:

Failed Setup, will retry: Unknown error

This time I'm not really seeing anything in the logs.

Ok, that's a good sign, it's raising a valid error now, that's from the coordinator. Something is happening that it can't identify...

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Debugging fix coming for that

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Let me know, happy to help however I can.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Try with v1.1.15rc2, debugging info should be improved. You can also put the integration into debug mode.

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Here's what I got when I removed and added back one of my miners:

2024-09-17 14:13:36.999 ERROR (MainThread) [homeassistant.components.mqtt.client] Failed to connect to MQTT server due to exception: [Errno -5] Name has no usable address
2024-09-17 14:13:53.323 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.152
2024-09-17 14:13:53.654 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer2 data in 0.356 seconds (success: False)
2024-09-17 14:13:53.725 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:13:53.963 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.261 seconds (success: False)
2024-09-17 14:14:14.086 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:14:14.224 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.152
2024-09-17 14:14:14.305 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.242 seconds (success: False)
2024-09-17 14:14:14.443 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer2 data in 0.281 seconds (success: False)
2024-09-17 14:14:54.563 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:14:54.623 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.152
2024-09-17 14:14:54.843 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.322 seconds (success: False)
2024-09-17 14:14:54.845 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer2 data in 0.249 seconds (success: False)
2024-09-17 14:16:15.114 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:16:15.298 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.152
2024-09-17 14:16:15.365 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.277 seconds (success: False)
2024-09-17 14:16:15.528 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer2 data in 0.258 seconds (success: False)
2024-09-17 14:17:18.222 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:17:18.443 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.249 seconds (success: False)
2024-09-17 14:17:23.863 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:17:24.096 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.263 seconds (success: False)

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Bumped to RC3 with explicit logging.exception call...

@gmint
Copy link
Author

gmint commented Sep 17, 2024

I think this will help you:

value = getattr(self, field_name)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 840, in __getattribute__
raise AttributeError(
AttributeError: '_id' is set to None, not 'id'
2024-09-17 14:31:03.352 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.279 seconds (success: False)
2024-09-17 14:31:03.558 ERROR (MainThread) [custom_components.miner.coordinator] '_id' is set to None, not 'id'
Traceback (most recent call last):
File "/config/custom_components/miner/coordinator.py", line 85, in _async_update_data
miner_data = await self.miner.get_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/miners/base.py", line 535, in get_data
gathered_data = await self._get_data(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/miners/base.py", line 460, in _get_data
await asyncio.gather(rpc_command_task, web_command_task)
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 88, in multicommand
result[cmd] = await tasks[cmd]
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 202, in get_cooling_state
return await self.send_command(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 114, in send_command
return (await endpoint(message, metadata=metadata)).to_pydict()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 1756, in to_pydict
output[cased_name] = value.to_pydict(casing, include_default_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 1717, in to_pydict
value = getattr(self, field_name)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 840, in __getattribute__
raise AttributeError(
AttributeError: '_id' is set to None, not 'id'
2024-09-17 14:31:03.560 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer2 data in 0.285 seconds (success: False)
2024-09-17 14:32:23.621 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.151
2024-09-17 14:32:23.836 ERROR (MainThread) [custom_components.miner.coordinator] '_id' is set to None, not 'id'
Traceback (most recent call last):
File "/config/custom_components/miner/coordinator.py", line 85, in _async_update_data
miner_data = await self.miner.get_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/miners/base.py", line 535, in get_data
gathered_data = await self._get_data(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/miners/base.py", line 460, in _get_data
await asyncio.gather(rpc_command_task, web_command_task)
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 88, in multicommand
result[cmd] = await tasks[cmd]
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 202, in get_cooling_state
return await self.send_command(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 114, in send_command
return (await endpoint(message, metadata=metadata)).to_pydict()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 1756, in to_pydict
output[cased_name] = value.to_pydict(casing, include_default_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 1717, in to_pydict
value = getattr(self, field_name)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 840, in __getattribute__
raise AttributeError(
AttributeError: '_id' is set to None, not 'id'
2024-09-17 14:32:23.838 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer1 data in 0.243 seconds (success: False)
2024-09-17 14:32:24.022 DEBUG (MainThread) [custom_components.miner.coordinator] Found miner: S19 (BOS+): 10.0.1.152
2024-09-17 14:32:24.247 ERROR (MainThread) [custom_components.miner.coordinator] '_id' is set to None, not 'id'
Traceback (most recent call last):
File "/config/custom_components/miner/coordinator.py", line 85, in _async_update_data
miner_data = await self.miner.get_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/miners/base.py", line 535, in get_data
gathered_data = await self._get_data(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/miners/base.py", line 460, in _get_data
await asyncio.gather(rpc_command_task, web_command_task)
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 88, in multicommand
result[cmd] = await tasks[cmd]
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 202, in get_cooling_state
return await self.send_command(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyasic/web/braiins_os/boser.py", line 114, in send_command
return (await endpoint(message, metadata=metadata)).to_pydict()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 1756, in to_pydict
output[cased_name] = value.to_pydict(casing, include_default_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 1717, in to_pydict
value = getattr(self, field_name)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/betterproto/__init__.py", line 840, in __getattribute__
raise AttributeError(
AttributeError: '_id' is set to None, not 'id'
2024-09-17 14:32:24.248 DEBUG (MainThread) [custom_components.miner.coordinator] Finished fetching antminer2 data in 0.257 seconds (success: False)```

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Betterproto. I hate GRPC lol.

This will have to be fixed in pyasic, Ill see what I can do.

@gmint
Copy link
Author

gmint commented Sep 17, 2024

That is something I'm not familiar with personally. But thanks for looking into this!

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

That is something I'm not familiar with personally. But thanks for looking into this!

GRPC is the communication protocol used by recent version of BOS+ for their API. Not sure where that error is coming from, but its being raised here in betterproto -

https://github.com/danielgtaylor/python-betterproto/blob/8d25c96cea597b9555e1ba3736b0b287cd3172ce/src/betterproto/__init__.py#L840-L844

I may just need to re-compile the proto files for BOS.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Can you try updating your miners actually? Possible the compiled files in pyasic are TOO new for your miner...

@gmint
Copy link
Author

gmint commented Sep 17, 2024

I actually did that in the process of trying to fix this, I'm now on 24.08.1-plus

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

I actually did that in the process of trying to fix this, I'm now on 24.08.1-plus

Ok, ill have to re-compile them then I suppose.

@gmint
Copy link
Author

gmint commented Sep 17, 2024

BTW, I should mention that your integration is really awesome. I use it to turn on my bitcoin miners only when my solar panels are making enough energy to not take from the grid so mining is still profitable.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

BTW, I should mention that your integration is really awesome. I use it to turn on my bitcoin miners only when my solar panels are making enough energy to not take from the grid so mining is still profitable.

Thanks, although not entirely my integration, as I just maintain it. Was a great idea on the part of @Schnitzel.

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Either way, it's really useful. I also use it to control my bitcoin miner that heats my hot tub...

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Either way, it's really useful. I also use it to control my bitcoin miner that heats my hot tub...

Thats pretty awesome. I'm never sure how many people are doing projects like this, but we need to see more of this stuff in the industry. The more people find use for bitcoin mining the more innovation we get in the home mining space.

@gmint
Copy link
Author

gmint commented Sep 17, 2024

I agree. Honestly, this project was great to find because I also use my miners to heat my business during the winter. Previously I was just doing it with a shell script and some TCP commands, but this is way better because I can use the status to turn on and off my external fans (the built in ones are too loud).

@itsFrankenSense
Copy link

Hey there, same issue on my end setting up for the first time with a S19.
Would downgrading BOS to an older version rectify in the meantime - if so, do we know what version works?

Thanks

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 17, 2024

Not sure of a working version, I can look and see if I can figure out what version it was compiled for, but I don't think there are any indicators in the sources...

I would try 24.04 or 24.06 maybe?

@gmint
Copy link
Author

gmint commented Sep 17, 2024

Just FYI, I was on BOS 24.0.3.1 when I was initially experiencing this issue.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 18, 2024

Ok, issue was with betterproto 2.0.0b7, I have pinned it in pyasic now. Technically the BOS+ proto files aren't following proper GRPC protocol now, the oneof values should always have a value, but whatever. Works with 2.0.0b6.

This should be fixed with v1.1.15rc4, let me know if that works and ill move it from pre to latest.

@gmint
Copy link
Author

gmint commented Sep 18, 2024

Ok, it's working on rc4! One small note which isn't particularly consequential but I did have to restart my miners and toggle the active switch once or twice to seemingly get things in sync and functioning. When I added the device, it showed as on in HA, but the device was not running and seemed to be in some sort of stuck state until I restarted. No idea if this is related to the integration or not, but I thought I would mention it.

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 18, 2024

Possibly a pyasic bug, but at least it's less concerning haha

@gmint
Copy link
Author

gmint commented Sep 18, 2024

I agree 100%! Thanks again for your great work!

@b-rowan
Copy link
Collaborator

b-rowan commented Sep 18, 2024

Ok, fixed in v1.1.15 on stable. Thanks for all your help!

@b-rowan b-rowan closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants