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

Errors after server maintenance #40

Closed
aidenmitchell opened this issue Jul 31, 2024 · 33 comments · Fixed by #41
Closed

Errors after server maintenance #40

aidenmitchell opened this issue Jul 31, 2024 · 33 comments · Fixed by #41

Comments

@aidenmitchell
Copy link

Looks like something broke after their most recent server maintenance. I can't find any more helpful logs.

image

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 167, in async_setup_component
    result = await _async_setup_component(hass, domain, config)
  File "/usr/src/homeassistant/homeassistant/setup.py", line 449, in _async_setup_component
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 451, in <genexpr>
    create_eager_task(
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 734, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/mila/__init__.py", line 19, in async_setup_entry
    coordinator = MilaUpdateCoordinator(hass, entry)
  File "/config/custom_components/mila/update_coordinator.py", line 37, in __init__
    self._api = MilaApi(MilaConfigEntryAuth(hass, config_entry, MilaOauthImplementation(hass, config_entry)))
@vsaintloup
Copy link

Glad I found your opened issue, same issue here, I tried deleting the integration, restarting and re-adding it with no success.

@jtwete01
Copy link

jtwete01 commented Aug 3, 2024

I am experiencing the same

@timkrull
Copy link

timkrull commented Aug 3, 2024

Same here

@agravel
Copy link

agravel commented Aug 4, 2024

+1

@Kelinni
Copy link

Kelinni commented Aug 5, 2024

+1. I use my milas temperatures to handle equalizing the house with a helper's statical range between my basement mila and upstairs mila and enable my hvac fan based on these to decrease the delta. Plz fix <3

@zemerick1
Copy link

Using milasdk and the example script the following is observed:

<<< {"errors":[{"message":"Validation error (FieldUndefined@[owner/appliances/smartModes]) : Field 'smartModes' in type 'Appliance' is undefined","locations":[{"line":27,"column":7}],"extensions":{"classification":"ValidationError"}}]}
Traceback (most recent call last):
  File "C:\Users\Zak\Documents\Code\milasdk\lib\site-packages\milasdk\api.py", line 62, in _execute
    return await session.execute(document, variable_values)
  File "C:\Users\Zak\Documents\Code\milasdk\lib\site-packages\gql\client.py", line 1639, in execute
    raise TransportQueryError(
gql.transport.exceptions.TransportQueryError: {'message': "Validation error (FieldUndefined@[owner/appliances/smartModes]) : Field 'smartModes' in type 'Appliance' is undefined", 'locations': [{'line': 27, 'column': 7}], 'extensions': {'classification': 'ValidationError'}}

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "c:\Users\Zak\Documents\Code\milasdk\main.py", line 36, in <module>
    loop.run_until_complete(main())
  File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "c:\Users\Zak\Documents\Code\milasdk\main.py", line 32, in main
    await update(api)
  File "c:\Users\Zak\Documents\Code\milasdk\main.py", line 16, in update
    r = await api.get_appliances()
  File "C:\Users\Zak\Documents\Code\milasdk\lib\site-packages\milasdk\api.py", line 126, in get_appliances
    result = await self._execute(query)
  File "C:\Users\Zak\Documents\Code\milasdk\lib\site-packages\milasdk\api.py", line 78, in _execute
    raise MilaError("Transport reported query error") from ex
milasdk.exceptions.MilaError: Transport reported query error

@zemerick1
Copy link

Until author has fixed it correctly for the API change if you navigate to the site-packages directory and edit milasdk/gql/queries.py
https://github.com/simbaja/milasdk/blob/master/milasdk/gql/queries.py

Comment out lines 31-40

        ds.Appliance.smartModes.select(
            ds.SmartModes.quiet.select(ds.QuietMode.isEnabled),
            ds.SmartModes.housekeeper.select(ds.HousekeeperMode.isEnabled),
            ds.SmartModes.quarantine.select(ds.QuarantineMode.isEnabled),
            ds.SmartModes.sleep.select(ds.SleepMode.isEnabled),
            ds.SmartModes.turndown.select(ds.TurndownMode.isEnabled),
            ds.SmartModes.whitenoise.select(ds.WhitenoiseMode.isEnabled),
            ds.SmartModes.powerSaver.select(ds.PowerSaverMode.isEnabled),
            ds.SmartModes.childLock.select(ds.ChildLockMode.isEnabled)
        ),

If you're using Home Assistant in a docker container you must be in the container before you edit the file at:

/usr/local/lib/python3.12/site-packages/milasdk/gql

After which you will need to restart Home Assistant.

@itbeemer
Copy link

itbeemer commented Aug 6, 2024

+1

@dadcoachengineer
Copy link

Excellent debugging @zemerick1

Thank you!

@marcthespot0
Copy link

marcthespot0 commented Aug 7, 2024

Until author has fixed it correctly for the API change if you navigate to the site-packages directory and edit milasdk/gql/queries.py https://github.com/simbaja/milasdk/blob/master/milasdk/gql/queries.py

Comment out lines 31-40

        ds.Appliance.smartModes.select(
            ds.SmartModes.quiet.select(ds.QuietMode.isEnabled),
            ds.SmartModes.housekeeper.select(ds.HousekeeperMode.isEnabled),
            ds.SmartModes.quarantine.select(ds.QuarantineMode.isEnabled),
            ds.SmartModes.sleep.select(ds.SleepMode.isEnabled),
            ds.SmartModes.turndown.select(ds.TurndownMode.isEnabled),
            ds.SmartModes.whitenoise.select(ds.WhitenoiseMode.isEnabled),
            ds.SmartModes.powerSaver.select(ds.PowerSaverMode.isEnabled),
            ds.SmartModes.childLock.select(ds.ChildLockMode.isEnabled)
        ),

If you're using Home Assistant in a docker container you must be in the container before you edit the file at:

/usr/local/lib/python3.12/site-packages/milasdk/gql

After which you will need to restart Home Assistant.

I don't seem to have the location /usr/local/lib/python3.12/site-packages/milasdk/gql but it is referenced in the error my logs. I have the Home Assistant Green. Any help would be appreciated. On what location I can find this file to edit.

@dadcoachengineer
Copy link

Until author has fixed it correctly for the API change if you navigate to the site-packages directory and edit milasdk/gql/queries.py https://github.com/simbaja/milasdk/blob/master/milasdk/gql/queries.py
Comment out lines 31-40

        ds.Appliance.smartModes.select(
            ds.SmartModes.quiet.select(ds.QuietMode.isEnabled),
            ds.SmartModes.housekeeper.select(ds.HousekeeperMode.isEnabled),
            ds.SmartModes.quarantine.select(ds.QuarantineMode.isEnabled),
            ds.SmartModes.sleep.select(ds.SleepMode.isEnabled),
            ds.SmartModes.turndown.select(ds.TurndownMode.isEnabled),
            ds.SmartModes.whitenoise.select(ds.WhitenoiseMode.isEnabled),
            ds.SmartModes.powerSaver.select(ds.PowerSaverMode.isEnabled),
            ds.SmartModes.childLock.select(ds.ChildLockMode.isEnabled)
        ),

If you're using Home Assistant in a docker container you must be in the container before you edit the file at:

/usr/local/lib/python3.12/site-packages/milasdk/gql

After which you will need to restart Home Assistant.

I don't seem to have the location /usr/local/lib/python3.12/site-packages/milasdk/gql but it is referenced in the error my logs. I have the Home Assistant Green. Any help would be appreciated. On what location I can find this file to edit.

If you are running HAOS, you will need to get a bash shell on the homeassistant container.

If you have the 'Advanced SSH & Web Terminal" add-on installed you can run the following docker command:

exec -it homeassistant bash

Then you should be able to use vi to edit /usr/local/lib/python3.12/site-packages/milasdk/gql/queries.py

@marcthespot0
Copy link

Until author has fixed it correctly for the API change if you navigate to the site-packages directory and edit milasdk/gql/queries.py https://github.com/simbaja/milasdk/blob/master/milasdk/gql/queries.py
Comment out lines 31-40

        ds.Appliance.smartModes.select(
            ds.SmartModes.quiet.select(ds.QuietMode.isEnabled),
            ds.SmartModes.housekeeper.select(ds.HousekeeperMode.isEnabled),
            ds.SmartModes.quarantine.select(ds.QuarantineMode.isEnabled),
            ds.SmartModes.sleep.select(ds.SleepMode.isEnabled),
            ds.SmartModes.turndown.select(ds.TurndownMode.isEnabled),
            ds.SmartModes.whitenoise.select(ds.WhitenoiseMode.isEnabled),
            ds.SmartModes.powerSaver.select(ds.PowerSaverMode.isEnabled),
            ds.SmartModes.childLock.select(ds.ChildLockMode.isEnabled)
        ),

If you're using Home Assistant in a docker container you must be in the container before you edit the file at:

/usr/local/lib/python3.12/site-packages/milasdk/gql

After which you will need to restart Home Assistant.

I don't seem to have the location /usr/local/lib/python3.12/site-packages/milasdk/gql but it is referenced in the error my logs. I have the Home Assistant Green. Any help would be appreciated. On what location I can find this file to edit.

If you are running HAOS, you will need to get a bash shell on the homeassistant container.

If you have the 'Advanced SSH & Web Terminal" add-on installed you can run the following docker command:

exec -it homeassistant bash

Then you should be able to use vi to edit /usr/local/lib/python3.12/site-packages/milasdk/gql/queries.py

image I don't have that path

@TomBrien
Copy link

TomBrien commented Aug 8, 2024

you need to run docker exec -it homeassistant bash first to get into the homeassistant container

@Kelinni
Copy link

Kelinni commented Aug 8, 2024

docker exec -it homeassistant bash by @TomBrien

This is fire! as someone who works in a tehcnical world and knows what docker is but doesn't have much experience this is the comment that solved my final blockage!

A massive and huge thanks to @zemerick1 for doing the heavy liften and exceptional debugging!

For anyone else trying to make sense of all the previous (really honestly amazing comments and help) but having a hard time and just need basic instructions here is what I did:

  1. Using the "Advanced SSH & Web Terminal" addon in my HomeAssistant I openned terminal in HA. (you need to turn protected mode off if you havent already. Feel free to turn it back on after. I know i did)
  2. enter into docker with docker exec -it homeassistant bash (this won't work if you have protected mode on and using the addon)
  3. Navigate to the mila directory where the queries file is located cd /usr/local/lib/python3.12/site-packages/milasdk/gql
  4. Make a backup cp queries.py queries.py.bak because it's a good idea
  5. You're going to use vi to edit the queries.py file. In case you haven't used vi before follow the next set of steps. The final result should look like below.
  6. Once done the vi editting restart HomeAssistant.

Vi cheat sheet

  1. open the queries.py file with vi vi queries.py
  2. Press the letter i on your keyboard to enter into insert mode
  3. Use the arrow keys on your keyboard to navigate to lines 31-40 as shown below "Appliance.smartModes.select" is what I looked for.
  4. At the beginning of each of each line press # to add a hash symbol (the comment symbol for python)
  5. When all the lines (iuncluding the final ")," have the # at the beginning press esc on your keyboard then type :wq to write and quite vi. (if you do something bad in the file you can always start this over again by pressing esc a couple times then type :q! to force quit vi without saving your changes.

Final result
Screenshot 2024-08-08 154633

@TomBrien
Copy link

TomBrien commented Aug 8, 2024

You should know that if you're running HAOS, the package will likely get reinstalled on HA updates and these changes will need repeating

@marcthespot0
Copy link

If I am on home assistant core is there away to find this file?

@marcthespot0
Copy link

If I am on home assistant core is there away to find this file?

any suggestions since my HA does not use docker?

@Kelinni
Copy link

Kelinni commented Aug 14, 2024

If I am on home assistant core is there away to find this file?

any suggestions since my HA does not use docker?

I'm far from an expert, but since HAOS is just a managed docker instance, i would assume that HA Core is what is running inside. So just follow my steps starting at number 3. cd /usr/local/lib/python3.12/site-packages/milasdk/gql

@gaillal
Copy link

gaillal commented Aug 15, 2024

If I am on home assistant core is there away to find this file?

any suggestions since my HA does not use docker?

I'm far from an expert, but since HAOS is just a managed docker instance, i would assume that HA Core is what is running inside. So just follow my steps starting at number 3. cd /usr/local/lib/python3.12/site-packages/milasdk/gql

Unfortunately the folder pythons3.12 does not exist on HA core running on a green box. Any ideas where the access the file to be updated. Thanks.

@gaillal
Copy link

gaillal commented Aug 15, 2024

If I am on home assistant core is there away to find this file?

Did you find a solution?

@marcthespot0
Copy link

If I am on home assistant core is there away to find this file?

Did you find a solution?

I did not, I am in the same boat as you. I do not have python3.12 under /usr/local/lib, and there is no docker containers running on HASS Core.

@zemerick1
Copy link

zemerick1 commented Aug 15, 2024

If I am on home assistant core is there away to find this file?

Did you find a solution?

I did not, I am in the same boat as you. I do not have python3.12 under /usr/local/lib, and there is no docker containers running on HASS Core.

3.12 is the version of python the box is running. Use python -V or python3 -V to find the version you are using then navigate to that folder. ie: /usr/local/lib/pythonX.YY/site-packages/

@marcthespot0
Copy link

image I don't even have the Python folders.

@gaillal
Copy link

gaillal commented Aug 15, 2024

image I don't even have the Python folders.

Same issue here. The lib folder only contains two files and no folder.

diosdog added a commit to diosdog/milasdk that referenced this issue Aug 16, 2024
Possible temporary solution for sanghviharshit/ha-mila#40
@gaillal
Copy link

gaillal commented Aug 22, 2024

UPDATE: I found it. You need to open the docker environment INSIDE home assistant when running HA Core. Ensure Advanced Mode is enabled in your profile and turn off protection mode for the SSH addon. Then via ssh run the following:

docker exec -it homeassistant /bin/bash

If you go back to /usr/local/lib/ you will find the python3.12 directory and the relevant subdirectories.

This seems to be applicable to instance of Home Assistant running in a docker container, but doesn’t address the issue experienced running HA on a green box for example…

@omar-merhebi
Copy link

UPDATE: I found it. You need to open the docker environment INSIDE home assistant when running HA Core. Ensure Advanced Mode is enabled in your profile and turn off protection mode for the SSH addon. Then via ssh run the following:
docker exec -it homeassistant /bin/bash
If you go back to /usr/local/lib/ you will find the python3.12 directory and the relevant subdirectories.

This seems to be applicable to instance of Home Assistant running in a docker container, but doesn’t address the issue experienced running HA on a green box for example…

I am running HA on an NUC not using docker. From what I was understanding home assistant uses docker containers with HAOS to manage environments.

@gaillal
Copy link

gaillal commented Aug 23, 2024

I am running HA on an NUC not using docker. From what I was understanding home assistant uses docker containers with HAOS to manage environments.

Thanks for the feedback. I’ve previously tried to run the discussed docker command, but received the error below. On the other hand, I may not be running the command correctly…

Screenshot 2024-08-22 185435

@marcthespot0
Copy link

I am running HA on an NUC not using docker. From what I was understanding home assistant uses docker containers with HAOS to manage environments.

Thanks for the feedback. I’ve previously tried to run the discussed docker command, but received the error below. On the other hand, I may not be running the command correctly…

Screenshot 2024-08-22 185435

any luck figuring this out?

@TomBrien
Copy link

TomBrien commented Aug 27, 2024

As I got tired of commenting out the lines on every update and this project seems to sadly be dead. I have forked the python package and made the changes so the integration can point to that library instead.

THIS IS DONE WITH NO INTENTION OF SUPPORT OR UPDATES. If it breaks, it breaks.

To switch to using this. In configuration/custom_components/mila/manifest.json change "milasdk==0.4.4", to "milasdklite==0.0.2",. Then restart Home Assistant.

@vsaintloup
Copy link

@TomBrien works like a charm — great idea, thank you!

@gaillal
Copy link

gaillal commented Aug 27, 2024

@TomBrien thank you!

@DSteiNeuro
Copy link

@TomBrien Thank you!
Took a couple of reloads but did the trick!

@M0LTE
Copy link
Contributor

M0LTE commented Sep 22, 2024

PRs done, action required from @simbaja and then @sanghviharshit to close this.

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.