zweckj / lamarzocco

Interact with your La Marzocco espresso machine
56 stars 2 forks source link

Failed setup #15

Closed TransientWolf closed 1 year ago

TransientWolf commented 1 year ago

Disconnected. Deleted and reinstalled integration. Finds the coffee machine but then when loading says Failed Setup. Checked LM cloud details are correct. Tried with both sets of client /secret details. Same error.

Log notes:

Logger: homeassistant.config_entries Source: config_entries.py:441 First occurred: 12:50:38 (2 occurrences) Last logged: 12:52:10

Config entry 'GS3 Coffee Machine' for lamarzocco integration not ready yet: ('Querying API failed. Error: %s', TimeoutError()); Retrying in background

zweckj commented 1 year ago

Are you on the stable channel or on pre-release?

TransientWolf commented 1 year ago

repo:zweckj/lamarzocco Get the same issue on both/either. Restored HA from a backup (moved from SD card to SSD) and noticed it didnt come back online after restoring. So removed the integration fully and deleted all the custom components. Reinstalled stable and it connects and finds the machine, it appears as a device but then says fails to setup. Tried with the alpha release and same issue (again fully removing the integration and installing clean). Nothing else changed!

zweckj commented 1 year ago

Stay on stable and enable debug logging please.

TransientWolf commented 1 year ago

As below. Looks like it is trying to connect to the machine via bluetooth and failing? I put the Pi into a new aluminium case with the SSD and it is in the loft so maybe too far away?)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/lamarzocco/coordinator.py", line 50, in _async_update_data await self._lm.hass_init() File "/config/custom_components/lamarzocco/lm_client.py", line 81, in hass_init await self.get_hass_bt_client() File "/config/custom_components/lamarzocco/lm_client.py", line 172, in get_hass_bt_client await self._lm_bluetooth.new_bleak_client_from_ble_device(ble_device) File "/usr/local/lib/python3.11/site-packages/lmcloud/lmbluetooth.py", line 104, in new_bleak_client_from_ble_device await self._client.connect() File "/usr/src/homeassistant/homeassistant/components/bluetooth/wrappers.py", line 292, in connect connected = await super().connect(kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/bleak/init.py", line 605, in connect return await self._backend.connect(kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 146, in connect async with async_timeout(timeout): File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in aexit raise TimeoutError from exc_val TimeoutError 2023-10-28 16:39:36.224 DEBUG (MainThread) [custom_components.lamarzocco.coordinator] Finished fetching La Marzocco API coordinator data in 11.188 seconds (success: False) 2023-10-28 16:39:56.394 DEBUG (MainThread) [custom_components.lamarzocco.coordinator] Update coordinator: Updating data 2023-10-28 16:39:56.395 DEBUG (MainThread) [custom_components.lamarzocco.lm_client] Initializing Cloud API. 2023-10-28 16:39:57.665 DEBUG (MainThread) [custom_components.lamarzocco.lm_client] Model name: GS3 MP 2023-10-28 16:39:57.665 DEBUG (MainThread) [custom_components.lamarzocco.lm_client] Found bluetooth adapters, initializing with bluetooth. 2023-10-28 16:39:57.665 DEBUG (MainThread) [custom_components.lamarzocco.lm_client] Connecting to machine with Bluetooth. 2023-10-28 16:40:07.668 ERROR (MainThread) [custom_components.lamarzocco.coordinator] 2023-10-28 16:40:07.669 DEBUG (MainThread) [custom_components.lamarzocco.coordinator] Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 209, in connect reply = await self._bus.call( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/dbus_fast/aio/message_bus.py", line 399, in call await future asyncio.exceptions.CancelledError

zweckj commented 1 year ago

yes, looks like timeouts. The alpha versions should fix this, but currently have other problems...

TransientWolf commented 1 year ago

Alpha 10, installed fresh, works. Error when putting in the IP address on setup though and won't continue with the setup. When IP address is left out during setup then it works and sets up and finds the device and entities. Temp updates are very slow, and response to switching on and off is very slow too, so assume everything is going through the cloud (which would make sense I guess with no IP address). Hope that's helpful and thanks for all your ongoing work - it is appreciated.

zweckj commented 1 year ago

@TransientWolf as you correctly explained, you're running cloud only mode now, that's why everyhing's slow. Sending commands will only get faster if you get in Bluetooth range though... Thanks for helping, I'm unfortunately completely reliant on feedback until my machine is fixed... If you want to help further, try setting it up again whilst putting in a local IP in alpha.11 and let me know any errors that it prints to your logs 😁

TransientWolf commented 1 year ago

Hi. Reinstalled with Alpha 11. Setup fine with IP address. Takes 23 seconds from turn on or turn off for the machine to respond. Logs confirm that 10 seconds after the request it logs “Failed to connect to machine with Bluetooth” then 10 seconds later “could not send command to Bluetooth device, even though initialized. Falling back to cloud”. And then 2-3 seconds later the machine responds. So seems to try to connect to Bluetooth for 10 seconds, then when it fails tries to send the command via Bluetooth for 10 seconds, then when it fails it falls back to cloud. Not sure if there is an ability to ignore Bluetooth and just use LAN or fallback to LAN or just go through cloud which I don’t think would be that slow if it wasn’t for the timeouts (x 2?) in the integration waiting for Bluetooth then sending the instruction. Hope that helps.

zweckj commented 1 year ago

Thanks, that's helpful information. Did you configure the integration from discovery or manually?

TransientWolf commented 1 year ago

From discovery using the integration.

zweckj commented 1 year ago

Try manual setup. Discovery happens based on Bluetooth, so if it was discovered through Bluetooth I am assuming your machine should be in Bluetooth reach in principle (at least that's what I'm doing at the moment)

TransientWolf commented 1 year ago

Deleted the device from the integration and then re-set it up manually using cloud login details and IP address. Same thing - tries bluetooth for 10 + 10 seconds and falls back to cloud. If that's what you meant by add manually! Other things I noticed if helpful are:

Thx

zweckj commented 1 year ago

the issues should be fixed in beta.1, beta.2 allows you to disable Bluetooth manually in the options flow (Configure integration page)

Dual-0 commented 1 year ago

I have installed beta.1 and the toggle is switching back to off when I switch it on. After 30 sek. it switches to on. Second issue is the target temp. Both boilers shows 131°C target.

zweckj commented 1 year ago

I have installed beta.1 and the toggle is switching back to off when I switch it on. After 30 sek. it switches to on. Second issue is the target temp. Both boilers shows 131°C target.

I will fix the target temp in the next update. Which toggle do you mean? Anything in the logs?

TransientWolf commented 1 year ago

Tried Beta 2. Target temp same issue and you have noted. Don't seem to have a toggle issues. Same bluetooth timeouts - didn't get any option to turn off Bluetooth either on discovery or setting up manually? Also when already installed if I click on the "Configure" option in the integration I get a pop up window with a tick box already ticked and highlighted blue, but no description for it or any further details. Let me know if you need anything else.

zweckj commented 1 year ago

I get a pop up window with a tick box already ticked and highlighted blue, but no description for it or any further details. Let me know if you need anything else.

That tick box is the option to disable Bluetooth. For the text to show you might need to clear your browser's cache.

TransientWolf commented 1 year ago

Hi. Cleared cache and also used another browser. No description. Box comes up ticked. If I untick it and save then same issue with bluetooth timeouts. If I go back into it then it is already ticked again without me doing anything.

Dual-0 commented 1 year ago

I have installed beta.1 and the toggle is switching back to off when I switch it on. After 30 sek. it switches to on. Second issue is the target temp. Both boilers shows 131°C target.

I will fix the target temp in the next update. Which toggle do you mean? Anything in the logs?

sorry for the wrong description I mean of course the normal on/off switch. Just the issue @TransientWolf described.

TransientWolf commented 1 year ago

Mine isn’t the on/off switch. This works fine in Beta 2 from what I can see. Just the configure [bluetooth] tick box that doesn’t seem to work.

zweckj commented 1 year ago

beta.3 should (hopefully) fix the display strings for the options flow (CONFIGURE) and the target temp for the coffee boiler. The options flow should đŸ€žalso actually do things now (if you untick, it should be unticked next time you open it)

sorry for the wrong description I mean of course the normal on/off switch.

That can happen. I assume you don't have Bluetooth next to your machine? Are you running cloud-only mode (no IP set as well)? I send the command to the machine and then check if the state change happened after 2 seconds. If your connection is slow and your machine did not actually turn on/off (and in cloud-only mode also report that state to the cloud) during those 2 seconds, the state will only be updated on the next scheduled update, which happens every 30 seconds.

TransientWolf commented 1 year ago

Updated to Beta 3. Coffee Boiler temp is now correct. Configure now shows "Bluetooth enabled" and allows me to untick. But when I then turn on or off the machine I still get 22/23 second delays and the same bluetooth timeouts in the logs. I uninstalled the device and re-setup but no change. Should I delete the integration and start clean?

zweckj commented 1 year ago

Updated to Beta 3. Coffee Boiler temp is now correct. Configure now shows "Bluetooth enabled" and allows me to untick. But when I then turn on or off the machine I still get 22/23 second delays and the same bluetooth timeouts in the logs. I uninstalled the device and re-setup but no change. Should I delete the integration and start clean?

No. If you untick Bluetooth does the integration reload automatically? If not, try reloading the integration manually.

Edit: No, it shouldn't have, but should reload automatically with beta.4 (as long as you actually changed a value during config)

TransientWolf commented 1 year ago

Ok. beta 3 reload I get initialising then Failed to set up beta 4 as soon as I turn off Bluetooth I get failed to setup with “Translation Error. The Intl string context variable “host” was not provided to the host
 “ and in the logs I get “Config entry 'GS3 MP' for lamarzocco integration could not authenticate: Authentication failed. Maybe one of your credential details was invalid or you changed your password.”

On the main integration page it then showed in red and asked me to reauthenticare. I clicked and it asked for login details again which I put in and then it setup again. But then went into configure and Bluetooth was rechecked - turn it off and it goes to failed setup again. Whatever the turn off Bluetooth is doing it is breaking the authentication?

Also if it helps the Bluetooth errors from the log shows:

Failed to connect to machine with Bluetooth: Failed to connect to machine with Bluetooth: [org.bluez.Error.Failed] Operation already in progress Failed to connect to machine with Bluetooth: [org.bluez.Error.Failed] br-connection-canceled

don’t think I sent that previously.

Hope that helps!

TransientWolf commented 1 year ago

Hey. Further weirdness!

I get the delay and failed to connect to Bluetooth when I toggle the Main switch in the integration or try and control the entity "Main" on/off switch directly. I have an entity button that also has the delay when I turn on.

BUT

I noticed this morning I have an automation that calls the Device (NOT the entity) to turn on and that works immediately - no delay. No bluetooth error. Not sure if that means it is using bluetooth or IP or cloud or what!? I don't know how HA decides what to use when you tell it to call the Device as a whole?

That may help or not!!

zweckj commented 1 year ago

Maybe beta.5 does better... I have no idea tbh what happens when you call the device directly either.

TransientWolf commented 1 year ago

Beta 5 all good. Reloads automatically after turning off bluetooth. Then immediate switch on and off. Brilliant - thanks so much!!