Skip to content

Commit

Permalink
Allow modbus "scale" to be negative. (#109965)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Feb 8, 2024
1 parent 168657b commit 55f1065
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/components/modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
]
),
vol.Optional(CONF_STRUCTURE): cv.string,
vol.Optional(CONF_SCALE, default=1): cv.positive_float,
vol.Optional(CONF_SCALE, default=1): vol.Coerce(float),
vol.Optional(CONF_OFFSET, default=0): vol.Coerce(float),
vol.Optional(CONF_PRECISION): cv.positive_int,
vol.Optional(
Expand Down
10 changes: 10 additions & 0 deletions tests/components/modbus/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,16 @@ async def test_config_wrong_struct_sensor(
False,
"112594",
),
(
{
CONF_DATA_TYPE: DataType.INT16,
CONF_SCALE: -1,
CONF_OFFSET: 0,
},
[0x000A],
False,
"-10",
),
],
)
async def test_all_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> None:
Expand Down

0 comments on commit 55f1065

Please sign in to comment.