Skip to content

Commit

Permalink
Allow modbus negative min/max value. (#109995)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored and frenck committed Feb 9, 2024
1 parent 49e5709 commit a18918b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@
vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string,
vol.Exclusive(CONF_VIRTUAL_COUNT, "vir_sen_count"): cv.positive_int,
vol.Exclusive(CONF_SLAVE_COUNT, "vir_sen_count"): cv.positive_int,
vol.Optional(CONF_MIN_VALUE): cv.positive_float,
vol.Optional(CONF_MAX_VALUE): cv.positive_float,
vol.Optional(CONF_MIN_VALUE): vol.Coerce(float),
vol.Optional(CONF_MAX_VALUE): vol.Coerce(float),
vol.Optional(CONF_NAN_VALUE): nan_validator,
vol.Optional(CONF_ZERO_SUPPRESS): cv.positive_float,
}
Expand Down
22 changes: 22 additions & 0 deletions tests/components/modbus/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@
}
]
},
{
CONF_SENSORS: [
{
CONF_NAME: TEST_ENTITY_NAME,
CONF_ADDRESS: 51,
CONF_DATA_TYPE: DataType.INT16,
CONF_MIN_VALUE: 1,
CONF_MAX_VALUE: 3,
}
]
},
{
CONF_SENSORS: [
{
CONF_NAME: TEST_ENTITY_NAME,
CONF_ADDRESS: 51,
CONF_DATA_TYPE: DataType.INT16,
CONF_MIN_VALUE: -3,
CONF_MAX_VALUE: -1,
}
]
},
],
)
async def test_config_sensor(hass: HomeAssistant, mock_modbus) -> None:
Expand Down

0 comments on commit a18918b

Please sign in to comment.