1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Replace modbus number_validator by HA standard (#108939)

This commit is contained in:
jan iversen
2024-01-27 16:39:33 +01:00
committed by GitHub
parent 858fb1fa37
commit 3cc5ffaa4b
6 changed files with 43 additions and 68 deletions

View File

@@ -357,7 +357,7 @@ async def test_config_wrong_struct_sensor(
},
[7],
False,
"34.0000",
"34",
),
(
{
@@ -379,7 +379,7 @@ async def test_config_wrong_struct_sensor(
},
[9],
False,
"18.5",
"18",
),
(
{
@@ -390,7 +390,7 @@ async def test_config_wrong_struct_sensor(
},
[1],
False,
"2.40",
"2",
),
(
{
@@ -401,7 +401,7 @@ async def test_config_wrong_struct_sensor(
},
[2],
False,
"-8.3",
"-8",
),
(
{
@@ -445,7 +445,7 @@ async def test_config_wrong_struct_sensor(
},
[0x89AB, 0xCDEF, 0x0123, 0x4567],
False,
"9920249030613615975",
"9920249030613616640",
),
(
{
@@ -456,7 +456,7 @@ async def test_config_wrong_struct_sensor(
},
[0x0123, 0x4567, 0x89AB, 0xCDEF],
False,
"163971058432973793",
"163971058432973792",
),
(
{
@@ -676,7 +676,7 @@ async def test_config_wrong_struct_sensor(
},
[0x00AB, 0xCDEF],
False,
"112593.75",
"112594",
),
(
{
@@ -686,7 +686,7 @@ async def test_config_wrong_struct_sensor(
},
[0x00AB, 0xCDEF],
False,
"112593.75",
"112594",
),
],
)
@@ -727,7 +727,7 @@ async def test_all_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> None:
int.from_bytes(struct.pack(">f", float("nan"))[2:4]),
],
False,
["34899771392", "0"],
["34899771392.0", "0.0"],
),
(
{
@@ -742,7 +742,7 @@ async def test_all_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> None:
int.from_bytes(struct.pack(">f", float("nan"))[2:4]),
],
False,
["34899771392", "0"],
["34899771392.0", "0.0"],
),
(
{
@@ -937,7 +937,7 @@ async def test_virtual_sensor(
},
[0x0102, 0x0304, 0x0506, 0x0708],
False,
[str(0x0708050603040102)],
[str(0x0708050603040100)],
),
(
{
@@ -970,7 +970,7 @@ async def test_virtual_sensor(
},
[0x0102, 0x0304, 0x0506, 0x0708, 0x0901, 0x0902, 0x0903, 0x0904],
False,
[str(0x0708050603040102), str(0x0904090309020901)],
[str(0x0708050603040100), str(0x0904090309020900)],
),
(
{
@@ -1035,10 +1035,10 @@ async def test_virtual_sensor(
],
False,
[
str(0x0604060306020601),
str(0x0704070307020701),
str(0x0804080308020801),
str(0x0904090309020901),
str(0x0604060306020600),
str(0x0704070307020700),
str(0x0804080308020800),
str(0x0904090309020900),
],
),
],
@@ -1202,7 +1202,7 @@ async def test_unpack_ok(hass: HomeAssistant, mock_do_cycle, expected) -> None:
0x0000,
0x000A,
],
"0,10",
"0,10.00",
),
(
{