Timer as Platform for own Integration

Hey all,
I’m currently working on an integration to sync the Voice PE Timers with HomeAssistant - Therefor I want to reuse the Timer Helpers which are already integrated into HA.
Sadly I couldn’t manage to integrate them as a platform since there are missing some platform specific functions:

2025-01-05 14:47:23.826 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Testi Integration for timer
Traceback (most recent call last):
  File "/workspaces/voice-timer-sync/homeassistant/config_entries.py", line 640, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'homeassistant.components.timer' has no attribute 'async_setup_entry'

I could manually add them, but since I don’t want to mess with HA Core code I wondered if I’m missing out something.

Here is my code (really quick and dirty because of testing purposes):

init.py

"""Example Load Platform integration."""

from __future__ import annotations

from homeassistant.core import HomeAssistant, Event
from homeassistant.helpers.typing import ConfigType
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import DeviceRegistry as dr
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.device_registry import async_get
from homeassistant.const import Platform

DOMAIN = "testi"
PLATFORMS = [Platform.NUMBER, "timer"]

CONFIG_SCHEMA = cv.platform_only_config_schema(DOMAIN)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up testi from a config entry."""
    device_registry = async_get(hass)
    device_registry.async_get_or_create(
        config_entry_id=entry.entry_id,
        identifiers={(DOMAIN, "testi_main")},
        name="Testi Control Panel",
        manufacturer="Testi Integration",
        model="Timer Controller",
    )

    # Data that you want to share with your platforms
    hass.data[DOMAIN] = {"entities": entry.data.get("entities", [])}

    async def handle_add_timer(event: Event):
        """Handle timer event."""
        timer_id = event.data.get("id", "default_id")
        timer_name = event.data.get("name", "Default Name")
        hass.data[DOMAIN]["entities"].append({"id": timer_id, "name": timer_name})
        hass.config_entries.async_update_entry(
            entry, data={"entities": hass.data[DOMAIN]["entities"]}
        )

    hass.bus.async_listen("add_timer", handle_add_timer)

    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Unload a config entry."""
    return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

timer.py

"""Platform for timer integration."""

from __future__ import annotations

from homeassistant.components.timer import Timer
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.entity import DeviceInfo
from . import DOMAIN


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up the timer platform."""
    entity = ExampleTimer(config_entry)
    async_add_entities([entity])

    # Save the actual entity ID to config entry data
    entities = list(config_entry.data.get("entities", []))
    entities.append(entity.unique_id)
    hass.config_entries.async_update_entry(config_entry, data={"entities": entities})


class ExampleTimer(Timer):
    """Representation of a Timer."""

    def __init__(self, config_entry: ConfigEntry) -> None:
        """Initialize the timer."""
        super().__init__({"duration": "00:00:00", "restore": True})
        self._attr_unique_id = "example_timer_1"
        self._attr_device_info = DeviceInfo(
            identifiers={(DOMAIN, "testi_main")},
            name="Testi Control Panel",
            manufacturer="Testi Integration",
            model="Timer Controller",
        )

    @property
    def name(self) -> str:
        """Return the name of the timer."""
        return "Example Timer"

manifest.json

{
  "domain": "testi",
  "name": "Testi",
  "codeowners": [
    "@howlingcoder"
  ],
  "config_flow": true,
  "dependencies": [],
  "documentation": "https://www.home-assistant.io/integrations/testi",
  "homekit": {},
  "iot_class": "local_polling",
  "requirements": [],
  "ssdp": [],
  "zeroconf": []
}

  • Is there maybe a way to inherit and extend this within my integration? How would I then register that as a platform in HA?

Would really appreciate any input (or ideas how can I do this better, since this is my first integration)

Have a great day!
Max