Self coded Integration will not found in config/custom_components

Hallo I have a problem.
If I follow the guide of Home Assistant how I setup a own Integration. This Integration will not be found.
I try it in different cases in the configuration.yaml file.
sensor:

  • (- platform: “mte”)

or
only

  • mte:

the error is every time the same. I do not understand wats going wrong.


Configuration warnings

Platform error 'sensor' from integration 'mte' - Integration 'mte' not found.

here is the file structure

my codes are the same like the one of the following link :
example-custom-config/custom_components/example_load_platform/README.md at master · home-assistant/example-custom-config (github.com)

the only difference is, I had rename the Integration and hence the Domain in ‘mte’

I hope someone can help me …
It seemes like I have the wrong file structure.

thanks in advanced

Katha

Yaml doesn’t include bullet points. Could that be your problem.

2 Likes

Did you update the manifest as well?
Please make your whole code available.

:rofl::rofl::rofl:

Here my files:

init.py


"""Example of a custom component."""
from __future__ import annotations

from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType

# The domain of your component. Should be equal to the name of your component.
DOMAIN = 'mte'


def setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """code."""
    # Data that you want to share with your platforms
    hass.data[DOMAIN] = {
        'temperature': 23
    }

    hass.helpers.discovery.load_platform('sensor', DOMAIN, {}, config)

    # Return boolean to indicate that initialization was successfully.
    return True

manifest.json

    "domain": "mte",
    "name": "mte",
    "codeowners": [],
    "dependencies": [],
    "iot_class": "local_polling",
    "requirements": [],
    "version": "0.1.0"
  }

sensor.py

"""Platform for sensor integration."""
from __future__ import annotations

from homeassistant.components.sensor import SensorEntity
from homeassistant.const import TEMP_CELSIUS
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from . import DOMAIN


def setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None
) -> None:
    """Set up the sensor platform."""
    # We only want this platform to be set up via discovery.
    if discovery_info is None:
        return
    add_entities([ExampleSensor()])


class ExampleSensor(SensorEntity):
    """Representation of a sensor."""

    def __init__(self) -> None:
        """Initialize the sensor."""
        self._state = None

    @property
    def name(self) -> str:
        """Return the name of the sensor."""
        return 'Example Temperature'

    @property
    def state(self):
        """Return the state of the sensor."""
        return self._state

    @property
    def unit_of_measurement(self) -> str:
        """Return the unit of measurement."""
        return TEMP_CELSIUS

    def update(self) -> None:
        """Fetch new state data for the sensor.

        This is the only method that should fetch new data for Home Assistant.
        """
        self._state = self.hass.data[DOMAIN]['temperature']

and for the nice guy who means I use bullet points in Yaml the snip of my
configuration.yaml file :wink:

type or paste code herehomeassistant:
  packages: !include_dir_named 

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include templates.yaml

http:
  server_port: 443
  ssl_certificate: 
  ssl_key: 
  use_x_forwarded_for: true
  trusted_proxies:
    - 

logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug

mte:

And you assume I can speak German because…? :wink:

Sorry … english … no problem … :slight_smile: I posted my Code … every File which is relevant, I think so. Only the configuration.yaml there I hide something in the http.: - part.