Custom_component and custom_platform Camera

okay, i want to overhaul the camera component and make a custom_platform for it.
but not in the acutal code, i want to utilize the custom_component and custom_platform features.

i started by simply copying the exiting

  • __init__.py hxxps://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/camera/__init__.py
  • _mjpeg.py hxxps://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/camera/mjpeg.py

and saved them like this:

.homeassistant:
±–custom_components
| |
| —ccamera
| ------mymjpeg.py (renamed -mjpeg.py)
| ------__init__.py (i just renamed the DOMAIN to: ‘ccamera’)

then i added the following entry to my configuration.yaml:

ccamera:

  • platform: mymjpeg
    mjpeg_url: ‘EXAMPLE_URL’

no errors launching just homeassistant. however once i open the frontend and want to see the camera, the following error occurs:

AttributeError: ‘EntityComponent’ object has no attribute ‘get_entity’ in __init__.py line 368

everything works just fine using the original build-in components like this:

camera:

  • platform: mjpeg
    mjpeg_url: ‘EXAMPLE_URL’

ALSO: in -mymjpeg.py, line 20 imports from the built-in component rather the custom one ‘ccamera’. trying to change it results in ‘no module found’.

any help appreciated. =)

I believe get_entity was introduced in 0.62. Do you have 0.62 installed, or do you have an older version installed and then download the camera component from github?

1 Like

Jesus, yes that was indeed the problem. Also the in order to import classes from custom_components, the line needs to be changed to:

from custom_components.ccamera import MyClass

instead of the more obvious approach:

from homeassistant.custom_components.ccamera import MyClass

Thank you very much =)