Use core constants for modbus (#46388)
parent
b85ecc0bd2
commit
c75e63dc95
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_METHOD,
|
CONF_METHOD,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
CONF_OFFSET,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_SLAVE,
|
CONF_SLAVE,
|
||||||
|
@ -46,7 +47,6 @@ from .const import (
|
||||||
CONF_INPUT_TYPE,
|
CONF_INPUT_TYPE,
|
||||||
CONF_MAX_TEMP,
|
CONF_MAX_TEMP,
|
||||||
CONF_MIN_TEMP,
|
CONF_MIN_TEMP,
|
||||||
CONF_OFFSET,
|
|
||||||
CONF_PARITY,
|
CONF_PARITY,
|
||||||
CONF_PRECISION,
|
CONF_PRECISION,
|
||||||
CONF_REGISTER,
|
CONF_REGISTER,
|
||||||
|
@ -257,7 +257,6 @@ class ModbusHub:
|
||||||
|
|
||||||
def __init__(self, client_config):
|
def __init__(self, client_config):
|
||||||
"""Initialize the Modbus hub."""
|
"""Initialize the Modbus hub."""
|
||||||
|
|
||||||
# generic configuration
|
# generic configuration
|
||||||
self._client = None
|
self._client = None
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
|
|
|
@ -10,13 +10,12 @@ from homeassistant.components.binary_sensor import (
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_DEVICE_CLASS, CONF_NAME, CONF_SLAVE
|
from homeassistant.const import CONF_ADDRESS, CONF_DEVICE_CLASS, CONF_NAME, CONF_SLAVE
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CALL_TYPE_COIL,
|
CALL_TYPE_COIL,
|
||||||
CALL_TYPE_DISCRETE,
|
CALL_TYPE_DISCRETE,
|
||||||
CONF_ADDRESS,
|
|
||||||
CONF_COILS,
|
CONF_COILS,
|
||||||
CONF_HUB,
|
CONF_HUB,
|
||||||
CONF_INPUT_TYPE,
|
CONF_INPUT_TYPE,
|
||||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.climate.const import (
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_TEMPERATURE,
|
ATTR_TEMPERATURE,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
CONF_OFFSET,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_SLAVE,
|
CONF_SLAVE,
|
||||||
CONF_STRUCTURE,
|
CONF_STRUCTURE,
|
||||||
|
@ -39,7 +40,6 @@ from .const import (
|
||||||
CONF_DATA_TYPE,
|
CONF_DATA_TYPE,
|
||||||
CONF_MAX_TEMP,
|
CONF_MAX_TEMP,
|
||||||
CONF_MIN_TEMP,
|
CONF_MIN_TEMP,
|
||||||
CONF_OFFSET,
|
|
||||||
CONF_PRECISION,
|
CONF_PRECISION,
|
||||||
CONF_SCALE,
|
CONF_SCALE,
|
||||||
CONF_STEP,
|
CONF_STEP,
|
||||||
|
@ -146,7 +146,6 @@ class ModbusThermostat(ClimateEntity):
|
||||||
|
|
||||||
False if entity pushes its state to HA.
|
False if entity pushes its state to HA.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Handle polling directly in this entity
|
# Handle polling directly in this entity
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ CONF_REVERSE_ORDER = "reverse_order"
|
||||||
CONF_SCALE = "scale"
|
CONF_SCALE = "scale"
|
||||||
CONF_COUNT = "count"
|
CONF_COUNT = "count"
|
||||||
CONF_PRECISION = "precision"
|
CONF_PRECISION = "precision"
|
||||||
CONF_OFFSET = "offset"
|
|
||||||
CONF_COILS = "coils"
|
CONF_COILS = "coils"
|
||||||
|
|
||||||
# integration names
|
# integration names
|
||||||
|
@ -51,7 +50,6 @@ DEFAULT_SCAN_INTERVAL = 15 # seconds
|
||||||
# binary_sensor.py
|
# binary_sensor.py
|
||||||
CONF_INPUTS = "inputs"
|
CONF_INPUTS = "inputs"
|
||||||
CONF_INPUT_TYPE = "input_type"
|
CONF_INPUT_TYPE = "input_type"
|
||||||
CONF_ADDRESS = "address"
|
|
||||||
|
|
||||||
# sensor.py
|
# sensor.py
|
||||||
# CONF_DATA_TYPE = "data_type"
|
# CONF_DATA_TYPE = "data_type"
|
||||||
|
|
|
@ -148,7 +148,6 @@ class ModbusCover(CoverEntity, RestoreEntity):
|
||||||
|
|
||||||
False if entity pushes its state to HA.
|
False if entity pushes its state to HA.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Handle polling directly in this entity
|
# Handle polling directly in this entity
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,6 @@ class ModbusRegisterSwitch(ModbusBaseSwitch, SwitchEntity):
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Set switch on."""
|
"""Set switch on."""
|
||||||
|
|
||||||
# Only holding register is writable
|
# Only holding register is writable
|
||||||
if self._register_type == CALL_TYPE_REGISTER_HOLDING:
|
if self._register_type == CALL_TYPE_REGISTER_HOLDING:
|
||||||
self._write_register(self._command_on)
|
self._write_register(self._command_on)
|
||||||
|
@ -209,7 +208,6 @@ class ModbusRegisterSwitch(ModbusBaseSwitch, SwitchEntity):
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Set switch off."""
|
"""Set switch off."""
|
||||||
|
|
||||||
# Only holding register is writable
|
# Only holding register is writable
|
||||||
if self._register_type == CALL_TYPE_REGISTER_HOLDING:
|
if self._register_type == CALL_TYPE_REGISTER_HOLDING:
|
||||||
self._write_register(self._command_off)
|
self._write_register(self._command_off)
|
||||||
|
|
|
@ -46,7 +46,6 @@ async def setup_base_test(
|
||||||
scan_interval,
|
scan_interval,
|
||||||
):
|
):
|
||||||
"""Run setup device for given config."""
|
"""Run setup device for given config."""
|
||||||
|
|
||||||
# Full sensor configuration
|
# Full sensor configuration
|
||||||
config = {
|
config = {
|
||||||
entity_domain: {
|
entity_domain: {
|
||||||
|
@ -79,7 +78,6 @@ async def run_base_read_test(
|
||||||
now,
|
now,
|
||||||
):
|
):
|
||||||
"""Run test for given config."""
|
"""Run test for given config."""
|
||||||
|
|
||||||
# Setup inputs for the sensor
|
# Setup inputs for the sensor
|
||||||
read_result = ReadResult(register_words)
|
read_result = ReadResult(register_words)
|
||||||
if register_type == CALL_TYPE_COIL:
|
if register_type == CALL_TYPE_COIL:
|
||||||
|
|
|
@ -7,11 +7,10 @@ from homeassistant.components.binary_sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.components.modbus.const import (
|
from homeassistant.components.modbus.const import (
|
||||||
CALL_TYPE_COIL,
|
CALL_TYPE_COIL,
|
||||||
CALL_TYPE_DISCRETE,
|
CALL_TYPE_DISCRETE,
|
||||||
CONF_ADDRESS,
|
|
||||||
CONF_INPUT_TYPE,
|
CONF_INPUT_TYPE,
|
||||||
CONF_INPUTS,
|
CONF_INPUTS,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_NAME, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_ADDRESS, CONF_NAME, STATE_OFF, STATE_ON
|
||||||
|
|
||||||
from .conftest import run_base_read_test, setup_base_test
|
from .conftest import run_base_read_test, setup_base_test
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ from homeassistant.components.modbus.const import (
|
||||||
CALL_TYPE_REGISTER_INPUT,
|
CALL_TYPE_REGISTER_INPUT,
|
||||||
CONF_COUNT,
|
CONF_COUNT,
|
||||||
CONF_DATA_TYPE,
|
CONF_DATA_TYPE,
|
||||||
CONF_OFFSET,
|
|
||||||
CONF_PRECISION,
|
CONF_PRECISION,
|
||||||
CONF_REGISTER,
|
CONF_REGISTER,
|
||||||
CONF_REGISTER_TYPE,
|
CONF_REGISTER_TYPE,
|
||||||
|
@ -21,7 +20,7 @@ from homeassistant.components.modbus.const import (
|
||||||
DATA_TYPE_UINT,
|
DATA_TYPE_UINT,
|
||||||
)
|
)
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME, CONF_OFFSET
|
||||||
|
|
||||||
from .conftest import run_base_read_test, setup_base_test
|
from .conftest import run_base_read_test, setup_base_test
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue