Make the Custom Component slower (Update Interval)

I found this custom component, GitHub - dannerph/homeassistant-smartmeter: custom component for home assistant to read IEC62056-21 meter values from e.g. IR-USB connection

It works, but the update interval is really fast.
Any ideas how to make this slower and just update it every 10 secs instead of every impulse that he receive?

Hope someone can help me customize the code to get update every 10 secs or something. Its really laggy, cause it has updates just every second or more

that is the file

"""Support for D0 smart meters."""
import asyncio
from homeassistant.core import callback
import logging
import serial_asyncio
import re

import voluptuous as vol

from homeassistant.const import CONF_HOST
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

DOMAIN = "smartmeter"
CONF_PORT = "port"
CONF_OBIS = "obis"

CONFIG_SCHEMA = vol.Schema(
        DOMAIN: vol.Schema(
                vol.Optional(CONF_PORT, default="/dev/ttyUSB0"): cv.string,
                vol.Optional(CONF_OBIS, default=[]): vol.All(
                    cv.ensure_list, vol.Length(min=1), [cv.string]

END_CHAR = b'!'

async def async_setup(hass, config):
    """Check connectivity and version of smartmeter."""
    port = config[DOMAIN][CONF_PORT]
    obis = config[DOMAIN][CONF_OBIS]
    meter = Meter(hass, port, obis)[DOMAIN] = meter

    # Wait for smartmeter setup complete (initial values loaded)
    if not await meter.setup():
        _LOGGER.error("Could not find a meter device at %s", port)
        return False

    # Load components
        discovery.async_load_platform(hass, "sensor", DOMAIN, {}, config)

    return True

class Meter():
    """Representation of a smartmeter connection."""

    def __init__(self, hass, port, list_of_sensors):
        """Initialize charging station connection."""

        self._list_of_sensors = list_of_sensors
        self._update_listeners = []
        self._hass = hass
        self._port = port
        self._values = {}
        self._units = {}
        self.device_name = "smartmeter"  # correct device name will be set in setup()
        self.device_id = "smartmeter_"  # correct device id will be set in setup()

        self.regex_data_set = re.compile(r"^(.+)\((.*)\)")
        self.regex_data_set_data = re.compile(r"^(.*)\*(.*)")

    def get_list_of_sensors(self):
        return self._list_of_sensors

    async def setup(self, loop=None):
        """Initialize smartmeter object."""

        # start serial connection
        loop = asyncio.get_event_loop() if loop is None else loop
        transport, protocol = await serial_asyncio.create_serial_connection(loop, D0Reader, self._port, baudrate=9600)
        return True

    def get_value(self, address):

        value = self._values.get(address, None)
        unit = self._units.get(address, None)
        return value, unit

    def hass_callback(self, data):
        """Handle component notification via callback."""

        # Analyse and preprocess received data blob
        for line in data.splitlines(True):

            first_match =
            if first_match:
                address =
                second_match =
                if second_match:
                    self._values[address] = float(
                    self._units[address] =
                    _LOGGER.debug("extracted %s with value %s with unit %s", address, self._values[address], self._units[address])

        # Inform entities about updated values
        for listener in self._update_listeners:

        _LOGGER.debug("Notifying %d listeners", len(self._update_listeners))

    def add_update_listener(self, listener):
        """Add a listener for update notifications."""

        # initial data is already loaded, thus update the component

class D0Reader(asyncio.Protocol):

    def __init__(self) -> None:
        self._data = ""

    def set_callback(self, callback):
        self._callback = callback

    def connection_made(self, transport):
        self.transport = transport
        _LOGGER.debug("port opened %s", transport)

    def data_received(self, data):

        # Reset buffer if new start byte received
        if START_CHAR in data:
            _LOGGER.debug("new start found")
            self._data = ""
        # Buffer content and fetch data
        # TODO: change data type to bytearray and convert to string afterwards
        self._data += data.decode("latin-1")

        # Callback if ending byte found(complete message received)
        if END_CHAR in data:
            _LOGGER.debug("end found, run callback")
            # TODO: check CRC

    def connection_lost(self, exc):
        _LOGGER.debug("serial connection closed: %s", exc)

that is

"""Support for smartmeter sensors."""
import logging

from homeassistant.helpers.entity import Entity

from . import DOMAIN

_LOGGER = logging.getLogger(__name__)

async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Set up the smart meter platform."""
    if discovery_info is None:

    smartmeter =[DOMAIN]

    obis = smartmeter.get_list_of_sensors()
    _LOGGER.debug("Setting up sensors: %s", repr(obis))

    sensors = []
    for sensor_obis in obis:
        sensors.append(MeterSensor(smartmeter, sensor_obis, "Verbrauch", "mdi:flash"))

class MeterSensor(Entity):
    """The entity class for smart meter sensors."""

    def __init__(self, smartmeter, obis, name, icon, device_class=None):
        """Initialize the smartmeter sensor."""
        self._smartmeter = smartmeter
        self._obis = obis
        self._name = name
        self._icon = icon
        self._unit = None
        self._device_class = device_class

        self._state = None
        self._attributes = {}

    def should_poll(self):
        """Deactivate polling. Data updated by smartmeter."""
        return False

    def unique_id(self):
        """Return the unique ID of the binary sensor."""
        return f"{self._smartmeter.device_id}_{self._obis}"

    def name(self):
        """Return the name of the device."""
        name = names.get(self._obis,"unknown")

        return f"{self._smartmeter.device_name} {name}"

    def device_class(self):
        """Return the class of this sensor."""
        return self._device_class

    def icon(self):
        """Icon to use in the frontend, if any."""
        return self._icon

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

    def unit_of_measurement(self):
        """Get the unit of measurement."""
        return self._unit

    def device_state_attributes(self):
        """Return the state attributes of the binary sensor."""
        return self._attributes

    async def async_update(self):
        """Get latest cached states from the device."""
        self._state, self._unit = self._smartmeter.get_value(self._obis)

    def update_callback(self):
        """Schedule a state update."""

    async def async_added_to_hass(self):
        """Add update callback after being added to hass."""

No one here who can help me? :confused:

It’s how it’s designed that it’s not polling the state but instead getting it from the device instantly when there is a change.
I would suggest you check with the author in this case.

The Author closed it, thats why i ask here. I mean the sourcecode can be viewed but i cant do it :frowning: I tried but not working

I tried now different things to change the polling but nothing works for me, need someone who knows more than me

Try add
SCAN_INTERVAL = timedelta(minutes=10)
_LOGGER = logging.getLogger(name)