Use HA constants for Rfxtrx units (#40562)
* Add more units and device classes * Battery level is a value beteen 0 and 9 where 9 indicate full Actual 0 battery can't occur since since then we would get to signal * Adjust tests * Add wind direction and adjust rain rate * Adjust data types to be None rather than empty string * Set counter values to count unit * Forgotten unit
This commit is contained in:
1 parent
b6aa29012e
commit
0fbeb3bf7b
3 files changed
+53
-33
No files matched your search
@@ -87,7 +87,7 @@ async def test_one_sensor_no_datatype(hass, rfxtrx):
|
||||
assert state
|
||||
assert state.state == "unknown"
|
||||
assert state.attributes.get("friendly_name") == f"{base_name} Humidity status"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||
|
||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
||||
assert state
|
||||
@@ -164,7 +164,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||
state = hass.states.get(f"{base_id}_humidity_status")
|
||||
assert state
|
||||
assert state.state == "normal"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||
|
||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
||||
assert state
|
||||
@@ -178,7 +178,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||
|
||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
||||
assert state
|
||||
assert state.state == "90"
|
||||
assert state.state == "100"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
|
||||
# 2
|
||||
@@ -193,7 +193,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||
state = hass.states.get(f"{base_id}_humidity_status")
|
||||
assert state
|
||||
assert state.state == "normal"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||
|
||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
||||
assert state
|
||||
@@ -207,7 +207,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||
|
||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
||||
assert state
|
||||
assert state.state == "90"
|
||||
assert state.state == "100"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
|
||||
# 1 Update
|
||||
@@ -222,7 +222,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||
state = hass.states.get(f"{base_id}_humidity_status")
|
||||
assert state
|
||||
assert state.state == "normal"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ""
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||
|
||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
||||
assert state
|
||||
@@ -236,7 +236,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||
|
||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
||||
assert state
|
||||
assert state.state == "90"
|
||||
assert state.state == "100"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
|
||||
assert len(hass.states.async_all()) == 10
|
||||
|
||||
Reference in new issue
Block a user