sca075 / mqtt_vacuum_camera

Camera Integration for Home Assistant to export and render all Vacuums connected via MQTT( including Valetudo Hypfer and RE(rand256)) Maps.
Apache License 2.0
105 stars 7 forks source link

🚨⚠️ Attention: Migrating from Valetudo to MQTT Vacuum Camera ⚠️🚨 #190

Closed sca075 closed 5 months ago

sca075 commented 5 months ago

Checklist

The problem

As per discussion #187 we opened the PR #189. We will, with the next release automatically move the Valetudo Vacuum Camera to MQTT Vacuum Camera. The scope of this excise is to avoid to our users the pain to re-setup all from scratch generating also new entities that could cause problems with scripts or automations. We will of course generate a complete description / procedure / documentation of how this is going to work and possible manuals steps to do the same what this code will do. The procedure will not backup your configuration (a full backup of your setup must be done prior to run this). I start to write this as per I feel important to warn you that this procedure will be tested and re-tested but we don't want you to risk to broke out your configs, so every measure will be take in count releasing / documenting this changes.

What version of an integration has described problem?

none

What was the last working version of an integration?

2024.06.3 is the current stable one!

What vacuum model do you have problems with?

all

Please firmware installed on your Vacuum.

all

What type of platform you use?

ARM (Raspberry Pi, Odroid, etc.) > 4GB

What version of Home Assistant do you use?

2024.6.x

What type of installation are you running?

Home Assistant OS

Camera's settings.

We don't want to lose any setting. All will be as it before change only the Camera Domain.

Logs or Errors shown in the HA snapshots (please enable the Debug Mode)

No response

Additional information

"We either make ourselves miserable, or we make ourself strong. The amount of work is the same." C.Castaneda Dissipate someone, we are still here and we will grow ;)

sca075 commented 5 months ago

@rohankapoorcom , @gunjambi and @tjorim if you have the possibility that it works on your environments it would be really appreciated. Under HASIO environment it looks woking from the test I've done till now. The beta release 2024.06.4b1 would ensure the transfer of domain and platform without to louse the entry, the scope is to do not change anything in the HA enviroment. Warning, is that I didn't test it on a Core instance of Home Assistant, so if you have one, would be nice of you all works smoothly also there. It is possible to download it via HACS as usual.

gunjambi commented 5 months ago

Seems to work on a new HomeAssistant version.

Initially I installed the release zip from https://github.com/sca075/mqtt_vacuum_camera/releases/tag/2024.06.4b1 to my HA Docker setup.

Upon first boot, this caused error with PIL installation:

2024-06-15 19:35:36.660 ERROR (SyncWorker_0) [homeassistant.util.package] Unable to install package pillow==10.3.0: ERROR: Cannot install pillow==10.3.0 because these package versions have conflicting dependencies.

I was running HomeAssistant 2023.12.4 which uses (if i'm reading this right https://github.com/home-assistant/core/blob/2023.12.4/requirements_all.txt) Pillow==10.1.0.

Since Pillow is already installed on HomeAssistant, I tried removing the Pillow requirement from the manifest. This caused other problems:

Setup failed for custom integration 'valetudo_vacuum_camera': Unable to import component: No module named 'homeassistant.util.hass_dict'

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 251, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 814, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/valetudo_vacuum_camera/__init__.py", line 18, in <module>
    from .common import (
  File "/config/custom_components/valetudo_vacuum_camera/common.py", line 19, in <module>
    from .hass_types import GET_MQTT_DATA
  File "/config/custom_components/valetudo_vacuum_camera/hass_types.py", line 8, in <module>
    from homeassistant.util.hass_dict import HassKey
ModuleNotFoundError: No module named 'homeassistant.util.hass_dict'

After upgrading first to HomeAssistant 2024.6.2 and trying again there I got no errors. I got the reboot prompt, accepted, waited for HA to reboot and there were no errors in logs. Camera has not lost settings. TL;DR: Seems to work.

rohankapoorcom commented 5 months ago

@gunjambi any version of 2024.06.x requires Home Assistant 2024.6 now due to some breaking changes in how data is accessed. I ended up upgrading from 2023.12 myself last week for the same reason.

@sca075 i will have some time to test tomorrow and will let you know. I run both docker and core instances so should be able to test both.

sca075 commented 5 months ago

Thanks to @rohankapoorcom we found a potential issue in the migration process. Therefore we are going to release a beta 2 as soon I can confirm the migration process once again. Usage of core exposed functions instead of our own one, would be better, although I can't found on the docs the functions we need to modify the required data for the entires. Anyhow as per os.getcwd() can create issues it will be replaced with hass.config.path(). Will also implement a logic to determine if the procedure fails to modify the data, so that the procedure abort before the new camera is setup.

sca075 commented 5 months ago

@rohankapoorcom just released the 2024.04.4b2. If at your convenience you could confirm the issue with the paths is resolved would be really appreciated.

sca075 commented 5 months ago

Thanks @rohankapoorcom the init.py was modified and now we should be able to run the migration on all supported environments. As soon the 2024.06.4 will be released this issue will be automatically closed.

Once again thanks @gunjambi and @rohankapoorcom for the cooperation.

tomlut commented 5 months ago

2024.064.b2 is working fine here too. HA OS 12.4, core-2024.6.3