mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Add Compressor, Inside Unit and Energy Output fields to Weheat (#129632)
This commit is contained in:
parent
0ba32e1d3a
commit
feca7c28cf
@ -27,6 +27,12 @@
|
|||||||
},
|
},
|
||||||
"electricity_used": {
|
"electricity_used": {
|
||||||
"default": "mdi:flash"
|
"default": "mdi:flash"
|
||||||
|
},
|
||||||
|
"compressor_rpm": {
|
||||||
|
"default": "mdi:fan"
|
||||||
|
},
|
||||||
|
"compressor_percentage": {
|
||||||
|
"default": "mdi:fan"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,13 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import UnitOfEnergy, UnitOfPower, UnitOfTemperature
|
from homeassistant.const import (
|
||||||
|
PERCENTAGE,
|
||||||
|
REVOLUTIONS_PER_MINUTE,
|
||||||
|
UnitOfEnergy,
|
||||||
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
@ -142,6 +148,28 @@ SENSORS = [
|
|||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
value_fn=lambda status: status.energy_total,
|
value_fn=lambda status: status.energy_total,
|
||||||
),
|
),
|
||||||
|
WeHeatSensorEntityDescription(
|
||||||
|
translation_key="energy_output",
|
||||||
|
key="energy_output",
|
||||||
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
value_fn=lambda status: status.energy_output,
|
||||||
|
),
|
||||||
|
WeHeatSensorEntityDescription(
|
||||||
|
translation_key="compressor_rpm",
|
||||||
|
key="compressor_rpm",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||||
|
value_fn=lambda status: status.compressor_rpm,
|
||||||
|
),
|
||||||
|
WeHeatSensorEntityDescription(
|
||||||
|
translation_key="compressor_percentage",
|
||||||
|
key="compressor_percentage",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
value_fn=lambda status: status.compressor_percentage,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,6 +84,15 @@
|
|||||||
},
|
},
|
||||||
"electricity_used": {
|
"electricity_used": {
|
||||||
"name": "Electricity used"
|
"name": "Electricity used"
|
||||||
|
},
|
||||||
|
"energy_output": {
|
||||||
|
"name": "Total energy output"
|
||||||
|
},
|
||||||
|
"compressor_rpm": {
|
||||||
|
"name": "Compressor speed"
|
||||||
|
},
|
||||||
|
"compressor_percentage": {
|
||||||
|
"name": "Compressor usage"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,9 @@ def mock_weheat_heat_pump_instance() -> MagicMock:
|
|||||||
mock_heat_pump_instance.cop = 4.5
|
mock_heat_pump_instance.cop = 4.5
|
||||||
mock_heat_pump_instance.heat_pump_state = HeatPump.State.HEATING
|
mock_heat_pump_instance.heat_pump_state = HeatPump.State.HEATING
|
||||||
mock_heat_pump_instance.energy_total = 12345
|
mock_heat_pump_instance.energy_total = 12345
|
||||||
|
mock_heat_pump_instance.energy_output = 56789
|
||||||
|
mock_heat_pump_instance.compressor_rpm = 4500
|
||||||
|
mock_heat_pump_instance.compressor_percentage = 100
|
||||||
|
|
||||||
return mock_heat_pump_instance
|
return mock_heat_pump_instance
|
||||||
|
|
||||||
|
@ -123,6 +123,106 @@
|
|||||||
'state': '33',
|
'state': '33',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_all_entities[sensor.test_model_compressor_speed-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'sensor.test_model_compressor_speed',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': None,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Compressor speed',
|
||||||
|
'platform': 'weheat',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'compressor_rpm',
|
||||||
|
'unique_id': '0000-1111-2222-3333_compressor_rpm',
|
||||||
|
'unit_of_measurement': 'rpm',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.test_model_compressor_speed-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'friendly_name': 'Test Model Compressor speed',
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
'unit_of_measurement': 'rpm',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.test_model_compressor_speed',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '4500',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.test_model_compressor_usage-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'sensor.test_model_compressor_usage',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': None,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Compressor usage',
|
||||||
|
'platform': 'weheat',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'compressor_percentage',
|
||||||
|
'unique_id': '0000-1111-2222-3333_compressor_percentage',
|
||||||
|
'unit_of_measurement': '%',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.test_model_compressor_usage-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'friendly_name': 'Test Model Compressor usage',
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
'unit_of_measurement': '%',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.test_model_compressor_usage',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '100',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_all_entities[sensor.test_model_cop-entry]
|
# name: test_all_entities[sensor.test_model_cop-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
@ -604,6 +704,57 @@
|
|||||||
'state': '21',
|
'state': '21',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_all_entities[sensor.test_model_total_energy_output-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'sensor.test_model_total_energy_output',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Total energy output',
|
||||||
|
'platform': 'weheat',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'energy_output',
|
||||||
|
'unique_id': '0000-1111-2222-3333_energy_output',
|
||||||
|
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_all_entities[sensor.test_model_total_energy_output-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'energy',
|
||||||
|
'friendly_name': 'Test Model Total energy output',
|
||||||
|
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
|
||||||
|
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.test_model_total_energy_output',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '56789',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_all_entities[sensor.test_model_water_inlet_temperature-entry]
|
# name: test_all_entities[sensor.test_model_water_inlet_temperature-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
@ -34,7 +34,7 @@ async def test_all_entities(
|
|||||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(("has_dhw", "nr_of_entities"), [(False, 12), (True, 14)])
|
@pytest.mark.parametrize(("has_dhw", "nr_of_entities"), [(False, 15), (True, 17)])
|
||||||
async def test_create_entities(
|
async def test_create_entities(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_weheat_discover: AsyncMock,
|
mock_weheat_discover: AsyncMock,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user