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