mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add Homee sensor tests (#137200)
This commit is contained in:
parent
487a4ac5c4
commit
88b444fa5b
@ -49,3 +49,12 @@ def build_mock_node(file: str) -> AsyncMock:
|
|||||||
mock_node.get_attribute_by_type = attribute_by_type
|
mock_node.get_attribute_by_type = attribute_by_type
|
||||||
|
|
||||||
return mock_node
|
return mock_node
|
||||||
|
|
||||||
|
|
||||||
|
async def async_update_attribute_value(
|
||||||
|
hass: HomeAssistant, attribute: AsyncMock, value: float
|
||||||
|
) -> None:
|
||||||
|
"""Set the current_value of an attribute and notify hass."""
|
||||||
|
attribute.current_value = value
|
||||||
|
attribute.add_on_changed_listener.call_args_list[0][0][0](attribute)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
715
tests/components/homee/fixtures/sensors.json
Normal file
715
tests/components/homee/fixtures/sensors.json
Normal file
@ -0,0 +1,715 @@
|
|||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Test MultiSensor",
|
||||||
|
"profile": 4010,
|
||||||
|
"image": "default",
|
||||||
|
"favorite": 0,
|
||||||
|
"order": 20,
|
||||||
|
"protocol": 1,
|
||||||
|
"routing": 0,
|
||||||
|
"state": 1,
|
||||||
|
"state_changed": 1709379826,
|
||||||
|
"added": 1676199446,
|
||||||
|
"history": 1,
|
||||||
|
"cube_type": 1,
|
||||||
|
"note": "",
|
||||||
|
"services": 5,
|
||||||
|
"phonetic_name": "",
|
||||||
|
"owner": 2,
|
||||||
|
"security": 0,
|
||||||
|
"attributes": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 1,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 200000,
|
||||||
|
"current_value": 555.591,
|
||||||
|
"target_value": 555.591,
|
||||||
|
"last_value": 555.586,
|
||||||
|
"unit": "kWh",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 4,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175270,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 2,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 200000,
|
||||||
|
"current_value": 1730.812,
|
||||||
|
"target_value": 1730.812,
|
||||||
|
"last_value": 1730.679,
|
||||||
|
"unit": "kWh",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 4,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175270,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 100.0,
|
||||||
|
"target_value": 100.0,
|
||||||
|
"last_value": 100.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 8,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1709982926,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 100.0,
|
||||||
|
"target_value": 100.0,
|
||||||
|
"last_value": 100.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 8,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1709982926,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 1,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 65000,
|
||||||
|
"current_value": 175.0,
|
||||||
|
"target_value": 175.0,
|
||||||
|
"last_value": 66.0,
|
||||||
|
"unit": "lx",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 11,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1709982926,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 2,
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 7.0,
|
||||||
|
"target_value": 7.0,
|
||||||
|
"last_value": 8.0,
|
||||||
|
"unit": "klx",
|
||||||
|
"step_value": 0.5,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 11,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1700056686,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 1,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 70,
|
||||||
|
"current_value": 0.249,
|
||||||
|
"target_value": 0.249,
|
||||||
|
"last_value": 0.249,
|
||||||
|
"unit": "A",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 193,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 2,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 70,
|
||||||
|
"current_value": 0.812,
|
||||||
|
"target_value": 0.812,
|
||||||
|
"last_value": 0.252,
|
||||||
|
"unit": "A",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 193,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 70.0,
|
||||||
|
"target_value": 0.0,
|
||||||
|
"last_value": 0.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 18,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1711796633,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 500,
|
||||||
|
"current_value": 500.0,
|
||||||
|
"target_value": 500.0,
|
||||||
|
"last_value": 500.0,
|
||||||
|
"unit": "lx",
|
||||||
|
"step_value": 2.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 301,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1700056347,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": -40,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 44.12,
|
||||||
|
"target_value": 44.12,
|
||||||
|
"last_value": 44.27,
|
||||||
|
"unit": "°C",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 92,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694176210,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 4095,
|
||||||
|
"current_value": 2000.0,
|
||||||
|
"target_value": 0.0,
|
||||||
|
"last_value": 1800.0,
|
||||||
|
"unit": "1/min",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 103,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736106312,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 13,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 47.0,
|
||||||
|
"target_value": 47.0,
|
||||||
|
"last_value": 47.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 96,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736106312,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 14,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": -64,
|
||||||
|
"maximum": 63,
|
||||||
|
"current_value": 18.0,
|
||||||
|
"target_value": 18.0,
|
||||||
|
"last_value": 18.0,
|
||||||
|
"unit": "°C",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 98,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736106312,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 15,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 4095,
|
||||||
|
"current_value": 0.0,
|
||||||
|
"target_value": 0.0,
|
||||||
|
"last_value": 0.0,
|
||||||
|
"unit": "1/min",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 102,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736106312,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 16,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 99999,
|
||||||
|
"current_value": 2490.0,
|
||||||
|
"target_value": 2490.0,
|
||||||
|
"last_value": 2516.0,
|
||||||
|
"unit": "L",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 22,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1735964135,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 17,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 4,
|
||||||
|
"current_value": 4.0,
|
||||||
|
"target_value": 4.0,
|
||||||
|
"last_value": 4.0,
|
||||||
|
"unit": "n/a",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 33,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1735964135,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 18,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 196605,
|
||||||
|
"current_value": 5478.0,
|
||||||
|
"target_value": 5478.0,
|
||||||
|
"last_value": 5478.0,
|
||||||
|
"unit": "h",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 104,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736105231,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 19,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 33.0,
|
||||||
|
"target_value": 33.0,
|
||||||
|
"last_value": 32.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 95,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736106312,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 20,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": -64,
|
||||||
|
"maximum": 63,
|
||||||
|
"current_value": 17.0,
|
||||||
|
"target_value": 17.0,
|
||||||
|
"last_value": 17.0,
|
||||||
|
"unit": "°C",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 97,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1736106312,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 21,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 0.0,
|
||||||
|
"target_value": 0.0,
|
||||||
|
"last_value": 0.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 15,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694176210,
|
||||||
|
"changed_by": 2,
|
||||||
|
"changed_by_id": 2,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 22,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 100,
|
||||||
|
"current_value": 51.0,
|
||||||
|
"target_value": 51.0,
|
||||||
|
"last_value": 51.0,
|
||||||
|
"unit": "%",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 7,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1709982925,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 23,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": -50,
|
||||||
|
"maximum": 125,
|
||||||
|
"current_value": 20.3,
|
||||||
|
"target_value": 20.3,
|
||||||
|
"last_value": 20.3,
|
||||||
|
"unit": "°C",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 5,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1709982925,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 24,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 600000,
|
||||||
|
"current_value": 3657.822,
|
||||||
|
"target_value": 3657.822,
|
||||||
|
"last_value": 3657.377,
|
||||||
|
"unit": "kWh",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 240,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 25,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 200,
|
||||||
|
"current_value": 2.223,
|
||||||
|
"target_value": 2.223,
|
||||||
|
"last_value": 2.21,
|
||||||
|
"unit": "A",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 272,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 26,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 80000,
|
||||||
|
"current_value": 195.384,
|
||||||
|
"target_value": 195.384,
|
||||||
|
"last_value": 248.412,
|
||||||
|
"unit": "W",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 239,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694176076,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 27,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 420,
|
||||||
|
"current_value": 239.823,
|
||||||
|
"target_value": 239.823,
|
||||||
|
"last_value": 235.775,
|
||||||
|
"unit": "V",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 51,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 28,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 4,
|
||||||
|
"current_value": 0.0,
|
||||||
|
"target_value": 0.0,
|
||||||
|
"last_value": 3.0,
|
||||||
|
"unit": "n/a",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 135,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1687175680,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 29,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 15,
|
||||||
|
"current_value": 6.0,
|
||||||
|
"target_value": 6.0,
|
||||||
|
"last_value": 6.0,
|
||||||
|
"unit": "",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 173,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1709982926,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 30,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 1,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 420,
|
||||||
|
"current_value": 239.823,
|
||||||
|
"target_value": 239.823,
|
||||||
|
"last_value": 239.559,
|
||||||
|
"unit": "V",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 195,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 31,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 2,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 420,
|
||||||
|
"current_value": 236.867,
|
||||||
|
"target_value": 236.867,
|
||||||
|
"last_value": 237.634,
|
||||||
|
"unit": "V",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 195,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1694175269,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 32,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 25,
|
||||||
|
"current_value": 2.0,
|
||||||
|
"target_value": 2.0,
|
||||||
|
"last_value": 2.5,
|
||||||
|
"unit": "m/s",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 146,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1700056836,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 33,
|
||||||
|
"node_id": 1,
|
||||||
|
"instance": 0,
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 2,
|
||||||
|
"current_value": 0.0,
|
||||||
|
"target_value": 0.0,
|
||||||
|
"last_value": 2.0,
|
||||||
|
"unit": "n/a",
|
||||||
|
"step_value": 1.0,
|
||||||
|
"editable": 0,
|
||||||
|
"type": 10,
|
||||||
|
"state": 1,
|
||||||
|
"last_changed": 1687175680,
|
||||||
|
"changed_by": 1,
|
||||||
|
"changed_by_id": 0,
|
||||||
|
"based_on": 1,
|
||||||
|
"data": "",
|
||||||
|
"name": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1811
tests/components/homee/snapshots/test_sensor.ambr
Normal file
1811
tests/components/homee/snapshots/test_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
124
tests/components/homee/test_sensor.py
Normal file
124
tests/components/homee/test_sensor.py
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
"""Test homee sensors."""
|
||||||
|
|
||||||
|
from datetime import timedelta
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
|
from homeassistant.components.homee.const import (
|
||||||
|
OPEN_CLOSE_MAP,
|
||||||
|
OPEN_CLOSE_MAP_REVERSED,
|
||||||
|
WINDOW_MAP,
|
||||||
|
WINDOW_MAP_REVERSED,
|
||||||
|
)
|
||||||
|
from homeassistant.const import LIGHT_LUX
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
|
from . import async_update_attribute_value, build_mock_node, setup_integration
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||||
|
|
||||||
|
|
||||||
|
async def test_up_down_values(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_homee: MagicMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test values for up/down sensor."""
|
||||||
|
mock_homee.nodes = [build_mock_node("sensors.json")]
|
||||||
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
|
assert hass.states.get("sensor.test_multisensor_state").state == OPEN_CLOSE_MAP[0]
|
||||||
|
|
||||||
|
attribute = mock_homee.nodes[0].attributes[27]
|
||||||
|
for i in range(1, 5):
|
||||||
|
await async_update_attribute_value(hass, attribute, i)
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.test_multisensor_state").state == OPEN_CLOSE_MAP[i]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test reversed up/down sensor
|
||||||
|
attribute.is_reversed = True
|
||||||
|
for i in range(5):
|
||||||
|
await async_update_attribute_value(hass, attribute, i)
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.test_multisensor_state").state
|
||||||
|
== OPEN_CLOSE_MAP_REVERSED[i]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_window_position(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_homee: MagicMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test values for window handle position."""
|
||||||
|
mock_homee.nodes = [build_mock_node("sensors.json")]
|
||||||
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.test_multisensor_window_position").state
|
||||||
|
== WINDOW_MAP[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
attribute = mock_homee.nodes[0].attributes[32]
|
||||||
|
for i in range(1, 3):
|
||||||
|
await async_update_attribute_value(hass, attribute, i)
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.test_multisensor_window_position").state
|
||||||
|
== WINDOW_MAP[i]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test reversed window handle.
|
||||||
|
attribute.is_reversed = True
|
||||||
|
for i in range(3):
|
||||||
|
await async_update_attribute_value(hass, attribute, i)
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.test_multisensor_window_position").state
|
||||||
|
== WINDOW_MAP_REVERSED[i]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_brightness_sensor(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_homee: MagicMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test brightness sensor's lx & klx units and naming of multi-instance sensors."""
|
||||||
|
mock_homee.nodes = [build_mock_node("sensors.json")]
|
||||||
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
|
sensor_state = hass.states.get("sensor.test_multisensor_illuminance_1")
|
||||||
|
assert sensor_state.state == "175.0"
|
||||||
|
assert sensor_state.attributes["unit_of_measurement"] == LIGHT_LUX
|
||||||
|
assert sensor_state.attributes["friendly_name"] == "Test MultiSensor Illuminance 1"
|
||||||
|
|
||||||
|
# Sensor with Homee unit klx
|
||||||
|
sensor_state = hass.states.get("sensor.test_multisensor_illuminance_2")
|
||||||
|
assert sensor_state.state == "7000.0"
|
||||||
|
assert sensor_state.attributes["unit_of_measurement"] == LIGHT_LUX
|
||||||
|
assert sensor_state.attributes["friendly_name"] == "Test MultiSensor Illuminance 2"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_sensor_snapshot(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_homee: MagicMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
freezer: FrozenDateTimeFactory,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> None:
|
||||||
|
"""Test the multisensor snapshot."""
|
||||||
|
mock_homee.nodes = [build_mock_node("sensors.json")]
|
||||||
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
entity_registry.async_update_entity(
|
||||||
|
"sensor.test_multisensor_node_state", disabled_by=None
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
freezer.tick(timedelta(seconds=30))
|
||||||
|
async_fire_time_changed(hass)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
Loading…
x
Reference in New Issue
Block a user