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

UniFi Protect 4.0 causes ValueError: 'IMAGE' is not a valid DoorbellMessageType #117274

Closed
aurelmarius opened this issue May 11, 2024 · 14 comments · Fixed by #119256
Closed

UniFi Protect 4.0 causes ValueError: 'IMAGE' is not a valid DoorbellMessageType #117274

aurelmarius opened this issue May 11, 2024 · 14 comments · Fixed by #119256

Comments

@aurelmarius
Copy link

The problem

Hi, I know that EA versions of Unifi are not fully supported, but maybe this will be fixed... In the latest version of Protect, Ubiquity introduced the ability to set images on Doorbell Pro G4 instead of text message, and if i choose a image the Protect Integration will fail to start:
ValueError: 'IMAGE' is not a valid DoorbellMessageType

What version of Home Assistant Core has the issue?

core-2024.5.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Unifi Protect

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifiprotect/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:575
First occurred: May 10, 2024 at 9:36:42 PM (3 occurrences)
Last logged: 12:02:56 AM

Error setting up entry Aurel Popesti for unifiprotect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/unifiprotect/__init__.py", line 72, in async_setup_entry
    bootstrap = await protect.get_bootstrap()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 1132, in get_bootstrap
    return Bootstrap.from_unifi_dict(**data, api=self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 127, in from_unifi_dict
    data = cls.unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/bootstrap.py", line 224, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 376, in unifi_dict_to_dict
    data[key] = cls._clean_protect_obj_dict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 318, in _clean_protect_obj_dict
    items[key] = cls._clean_protect_obj(value, klass, api)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 296, in _clean_protect_obj
    return klass.unifi_dict_to_dict(data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/devices.py", line 985, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 1005, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 866, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 362, in unifi_dict_to_dict
    data[key] = cls._clean_protect_obj(data[key], unifi_objs[key], api)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 296, in _clean_protect_obj
    return klass.unifi_dict_to_dict(data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/devices.py", line 504, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 355, in unifi_dict_to_dict
    data[key] = convert_unifi_data(data[key], cls.__fields__[key])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/utils.py", line 251, in convert_unifi_data
    return type_(value)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 744, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 1158, in __new__
    raise ve_exc
ValueError: 'IMAGE' is not a valid DoorbellMessageType

Additional information

No response

@home-assistant
Copy link

Hey there @AngellusMortis, @bdraco, mind taking a look at this issue as it has been labeled with an integration (unifiprotect) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of unifiprotect can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign unifiprotect Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


unifiprotect documentation
unifiprotect source
(message by IssueLinks)

@TheJulianJES
Copy link
Member

Thanks for the report!
EA versions are indeed not supported by the HA integration. But as Protect 4.0.x will become a GA release eventually, I'll open this issue back up for now to help with tracking this and avoid other duplicate issues.

@TheJulianJES TheJulianJES reopened this May 19, 2024
@TheJulianJES TheJulianJES changed the title Unifi Protect ValueError: 'IMAGE' is not a valid DoorbellMessageType UniFi Protect 4.0 causes ValueError: 'IMAGE' is not a valid DoorbellMessageType May 19, 2024
@mike1627
Copy link

Same issue with me but I'm on the Release Candidate version of Protect 4.0.21. If I go into my G4 Pro doorbell settings and remove the custom image, switching it back to text, then reload the integration all seems well. Once the integration is running it doesn't seem to care if I switch my doorbell back to the custom image.

@andonevris
Copy link

andonevris commented May 28, 2024

4.0.21 went on general release today. Is it safe to update?

EDIT: Answering my own question. Went from 3.0.26 to 4.0.21 no issues

@Cyrelion
Copy link

Protect 4 is released, don't activate a own image because this will break the integration until you switch back to the build in picture or normal text

@thenoid
Copy link

thenoid commented May 30, 2024

Darn, I just updated to the officially released 4.x so I could have the pedro pedro pedro raccoon on my doorbell. I guess I've got to wait.

@blindguynar
Copy link

blindguynar commented May 30, 2024

I looked at this briefly earlier today when my integration stopped working.

I don’t think the error is actually in the integration, but rather the python protect api library supporting the integration is throwing the exception. pyunifiprotect i think was it’s name. i read several comments in that repo indicating it might be updated to handle the chg already. I didn’t specifically validate it, but saw IMAGE was a valid msg type now in that api library and comments specific to doorbell images. likely it’ll get released inn an upcoming ha release.

there is a way to pull in the python library into ha prior to official release and even run the integration as a custom component if a chg is made here, but i’d just wait on it. I’ve been without doorbell animations for nearly two years so couple more weeks isn’t gonna hurt.

i also think once the integration is running you can chg the doorbell image and unless ha or the integration restarts it seems to function normally.

@thenoid
Copy link

thenoid commented May 30, 2024

Does look like the upstream pyunifiprotect library in on 6.0.1 and supports the IMAGE type but HA is importing 5.1.2.

@bdraco
Copy link
Member

bdraco commented May 30, 2024

Here is a summary of the current state of affairs:

#117100 (comment)

@blindguynar
Copy link

With that BSL i'm not even sure a new owner can take over right? that poison pill is towards HA basically doesn't allow any changes related to HA. This integration is gonna have to die maybe. Unless he grants a new MIT license to a new owner. What a carrot!!!

@thenoid
Copy link

thenoid commented May 31, 2024

With that BSL i'm not even sure a new owner can take over right? that poison pill is towards HA basically doesn't allow any changes related to HA. This integration is gonna have to die maybe. Unless he grants a new MIT license to a new owner. What a carrot!!!

They can fork the code, up until the BSL license change, and provide the code updates.

The big headache though is, you have to update the code in a way that isn't a copy/paste from the other project.....but there are only so many ways to write an if statement. So it can turn into a pissing contest...even more than it already did. Sucks that it's the community that suffers. :(

@mike1627
Copy link

Like I said in a previous comment, this integration is still functional in it's current state with Unifi Protect 4. I had issues with the integration failing to start but that was traced back to a custom image on my G4 Pro doorbell. I simply have to revert the doorbell image back to the default and then restart the integration to fix the issue. Once the integration is running I am able to go back to a custom image on my doorbell and all works fine. I use this integration mainly for custom Alexa TTS messages, like when one of my cameras detects a person my Alexa can alert me "There is someone in the back yard" and I havent had any issues with that with Unifi Protect 4.

@blindguynar
Copy link

blindguynar commented May 31, 2024

Like I said in a previous comment, this integration is still functional in it's current state with Unifi Protect 4. I had issues with the integration failing to start but that was traced back to a custom image on my G4 Pro doorbell. I simply have to revert the doorbell image back to the default and then restart the integration to fix the issue. Once the integration is running I am able to go back to a custom image on my doorbell and all works fine. I use this integration mainly for custom Alexa TTS messages, like when one of my cameras detects a person my Alexa can alert me "There is someone in the back yard" and I havent had any issues with that with Unifi Protect 4.

With that BSL i'm not even sure a new owner can take over right? that poison pill is towards HA basically doesn't allow any changes related to HA. This integration is gonna have to die maybe. Unless he grants a new MIT license to a new owner. What a carrot!!!

They can fork the code, up until the BSL license change, and provide the code updates.

The big headache though is, you have to update the code in a way that isn't a copy/paste from the other project.....but there are only so many ways to write an if statement. So it can turn into a pissing contest...even more than it already did. Sucks that it's the community that suffers. :(

This is kind of what i was referring to actually, i'm betting the owner of the BSL license will likely continually wage complaints against the new maintainers.

i only use it for doorbell notifications so i might just run a diy sensor on the mechanical doorbell chime. I just see a rough road for awhile on this integration.

If i were a python guy i'd offer to help on the integration, but alias i'm just an old school C programmer.

@dangbird
Copy link

dangbird commented Jun 6, 2024

Have the same setup, and happy to verify/test as needed. Confirmed removing the custom GIF/JPG on the G4 Doorbell Pro allows the integration to run.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants