Remove modbus create_issue from init (#113510)
Create_issue only in check_config.
This commit is contained in:
parent
1ff049cc66
commit
a9fb34d9c2
3 changed files with 41 additions and 44 deletions
|
@ -29,7 +29,6 @@ from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity, ToggleEntity
|
from homeassistant.helpers.entity import Entity, ToggleEntity
|
||||||
from homeassistant.helpers.event import async_call_later, async_track_time_interval
|
from homeassistant.helpers.event import async_call_later, async_track_time_interval
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
@ -46,7 +45,6 @@ from .const import (
|
||||||
CONF_DATA_TYPE,
|
CONF_DATA_TYPE,
|
||||||
CONF_DEVICE_ADDRESS,
|
CONF_DEVICE_ADDRESS,
|
||||||
CONF_INPUT_TYPE,
|
CONF_INPUT_TYPE,
|
||||||
CONF_LAZY_ERROR,
|
|
||||||
CONF_MAX_VALUE,
|
CONF_MAX_VALUE,
|
||||||
CONF_MIN_VALUE,
|
CONF_MIN_VALUE,
|
||||||
CONF_NAN_VALUE,
|
CONF_NAN_VALUE,
|
||||||
|
@ -63,7 +61,6 @@ from .const import (
|
||||||
CONF_VIRTUAL_COUNT,
|
CONF_VIRTUAL_COUNT,
|
||||||
CONF_WRITE_TYPE,
|
CONF_WRITE_TYPE,
|
||||||
CONF_ZERO_SUPPRESS,
|
CONF_ZERO_SUPPRESS,
|
||||||
MODBUS_DOMAIN,
|
|
||||||
SIGNAL_START_ENTITY,
|
SIGNAL_START_ENTITY,
|
||||||
SIGNAL_STOP_ENTITY,
|
SIGNAL_STOP_ENTITY,
|
||||||
DataType,
|
DataType,
|
||||||
|
@ -82,25 +79,6 @@ class BasePlatform(Entity):
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the Modbus binary sensor."""
|
"""Initialize the Modbus binary sensor."""
|
||||||
|
|
||||||
if CONF_LAZY_ERROR in entry:
|
|
||||||
async_create_issue(
|
|
||||||
hass,
|
|
||||||
MODBUS_DOMAIN,
|
|
||||||
"removed_lazy_error_count",
|
|
||||||
breaks_in_ha_version="2024.7.0",
|
|
||||||
is_fixable=False,
|
|
||||||
severity=IssueSeverity.WARNING,
|
|
||||||
translation_key="removed_lazy_error_count",
|
|
||||||
translation_placeholders={
|
|
||||||
"config_key": "lazy_error_count",
|
|
||||||
"integration": MODBUS_DOMAIN,
|
|
||||||
"url": "https://www.home-assistant.io/integrations/modbus",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"`lazy_error_count`: is deprecated and will be removed in version 2024.7"
|
|
||||||
)
|
|
||||||
|
|
||||||
self._hub = hub
|
self._hub = hub
|
||||||
self._slave = entry.get(CONF_SLAVE) or entry.get(CONF_DEVICE_ADDRESS, 0)
|
self._slave = entry.get(CONF_SLAVE) or entry.get(CONF_DEVICE_ADDRESS, 0)
|
||||||
self._address = int(entry[CONF_ADDRESS])
|
self._address = int(entry[CONF_ADDRESS])
|
||||||
|
|
|
@ -34,7 +34,6 @@ import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
|
||||||
from homeassistant.helpers.reload import async_setup_reload_service
|
from homeassistant.helpers.reload import async_setup_reload_service
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ from .const import (
|
||||||
CONF_BYTESIZE,
|
CONF_BYTESIZE,
|
||||||
CONF_MSG_WAIT,
|
CONF_MSG_WAIT,
|
||||||
CONF_PARITY,
|
CONF_PARITY,
|
||||||
CONF_RETRIES,
|
|
||||||
CONF_STOPBITS,
|
CONF_STOPBITS,
|
||||||
DEFAULT_HUB,
|
DEFAULT_HUB,
|
||||||
MODBUS_DOMAIN as DOMAIN,
|
MODBUS_DOMAIN as DOMAIN,
|
||||||
|
@ -257,26 +255,6 @@ class ModbusHub:
|
||||||
def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
|
def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
|
||||||
"""Initialize the Modbus hub."""
|
"""Initialize the Modbus hub."""
|
||||||
|
|
||||||
if CONF_RETRIES in client_config:
|
|
||||||
async_create_issue(
|
|
||||||
hass,
|
|
||||||
DOMAIN,
|
|
||||||
"deprecated_retries",
|
|
||||||
breaks_in_ha_version="2024.7.0",
|
|
||||||
is_fixable=False,
|
|
||||||
severity=IssueSeverity.WARNING,
|
|
||||||
translation_key="deprecated_retries",
|
|
||||||
translation_placeholders={
|
|
||||||
"config_key": "retries",
|
|
||||||
"integration": DOMAIN,
|
|
||||||
"url": "https://www.home-assistant.io/integrations/modbus",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"`retries`: is deprecated and will be removed in version 2024.7"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
client_config[CONF_RETRIES] = 3
|
|
||||||
# generic configuration
|
# generic configuration
|
||||||
self._client: AsyncModbusSerialClient | AsyncModbusTcpClient | AsyncModbusUdpClient | None = None
|
self._client: AsyncModbusSerialClient | AsyncModbusTcpClient | AsyncModbusUdpClient | None = None
|
||||||
self._async_cancel_listener: Callable[[], None] | None = None
|
self._async_cancel_listener: Callable[[], None] | None = None
|
||||||
|
|
|
@ -35,6 +35,8 @@ from .const import (
|
||||||
CONF_HVAC_MODE_REGISTER,
|
CONF_HVAC_MODE_REGISTER,
|
||||||
CONF_HVAC_ONOFF_REGISTER,
|
CONF_HVAC_ONOFF_REGISTER,
|
||||||
CONF_INPUT_TYPE,
|
CONF_INPUT_TYPE,
|
||||||
|
CONF_LAZY_ERROR,
|
||||||
|
CONF_RETRIES,
|
||||||
CONF_SLAVE_COUNT,
|
CONF_SLAVE_COUNT,
|
||||||
CONF_SWAP,
|
CONF_SWAP,
|
||||||
CONF_SWAP_BYTE,
|
CONF_SWAP_BYTE,
|
||||||
|
@ -304,6 +306,27 @@ def validate_modbus(
|
||||||
hub_name_inx: int,
|
hub_name_inx: int,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Validate modbus entries."""
|
"""Validate modbus entries."""
|
||||||
|
if CONF_RETRIES in hub:
|
||||||
|
async_create_issue(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
"deprecated_retries",
|
||||||
|
breaks_in_ha_version="2024.7.0",
|
||||||
|
is_fixable=False,
|
||||||
|
severity=IssueSeverity.WARNING,
|
||||||
|
translation_key="deprecated_retries",
|
||||||
|
translation_placeholders={
|
||||||
|
"config_key": "retries",
|
||||||
|
"integration": DOMAIN,
|
||||||
|
"url": "https://www.home-assistant.io/integrations/modbus",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"`retries`: is deprecated and will be removed in version 2024.7"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
hub[CONF_RETRIES] = 3
|
||||||
|
|
||||||
host: str = (
|
host: str = (
|
||||||
hub[CONF_PORT]
|
hub[CONF_PORT]
|
||||||
if hub[CONF_TYPE] == SERIAL
|
if hub[CONF_TYPE] == SERIAL
|
||||||
|
@ -352,6 +375,24 @@ def validate_entity(
|
||||||
ent_addr: set[str],
|
ent_addr: set[str],
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Validate entity."""
|
"""Validate entity."""
|
||||||
|
if CONF_LAZY_ERROR in entity:
|
||||||
|
async_create_issue(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
"removed_lazy_error_count",
|
||||||
|
breaks_in_ha_version="2024.7.0",
|
||||||
|
is_fixable=False,
|
||||||
|
severity=IssueSeverity.WARNING,
|
||||||
|
translation_key="removed_lazy_error_count",
|
||||||
|
translation_placeholders={
|
||||||
|
"config_key": "lazy_error_count",
|
||||||
|
"integration": DOMAIN,
|
||||||
|
"url": "https://www.home-assistant.io/integrations/modbus",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"`lazy_error_count`: is deprecated and will be removed in version 2024.7"
|
||||||
|
)
|
||||||
name = f"{component}.{entity[CONF_NAME]}"
|
name = f"{component}.{entity[CONF_NAME]}"
|
||||||
addr = f"{hub_name}{entity[CONF_ADDRESS]}"
|
addr = f"{hub_name}{entity[CONF_ADDRESS]}"
|
||||||
scan_interval = entity.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
|
scan_interval = entity.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue