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.
"""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
"""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
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:
Sorry … english … no problem … I posted my Code … every File which is relevant, I think so. Only the configuration.yaml there I hide something in the http.: - part.