mirror of
https://github.com/home-assistant/core.git
synced 2025-11-06 01:19:29 +00:00
Refactor Riemann sum integral sensor to prepare for time based trigger (#113932)
* Refactor Integration sensor. * Use local simple function to verify the State is numeric. * Merge two methods to one. * Method renaming: _handle_state_change * Move async_write_ha_state to the caller. * Add comment on why attr_icon is set to None * Remove possible None type of State in validation methods. * Use a dict to map method name to method class. * Explain derived unit after integration. * Renaming to _multiply_unit_with_time and elaborate in docstring. * Set integral unit_of_measurement explicitly to None if source unit_of_measurement is None * One function for unit of measurement related steps. * Improve docstring of _multiply_unit_with_time Co-authored-by: Erik Montnemery <erik@montnemery.com> * Apply f-string suggestions from code review Co-authored-by: Erik Montnemery <erik@montnemery.com> * Be more clear in comment about removing the sensors icon default. * Apply suggestions from code review Co-authored-by: Diogo Gomes <diogogomes@gmail.com> * Update homeassistant/components/integration/sensor.py * Update homeassistant/components/integration/sensor.py * Update homeassistant/components/integration/sensor.py --------- Co-authored-by: Erik Montnemery <erik@montnemery.com> Co-authored-by: Diogo Gomes <diogogomes@gmail.com>
This commit is contained in:
@@ -563,7 +563,7 @@ async def test_units(hass: HomeAssistant) -> None:
|
||||
|
||||
# When source state goes to None / Unknown, expect an early exit without
|
||||
# changes to the state or unit_of_measurement
|
||||
hass.states.async_set(entity_id, None, None)
|
||||
hass.states.async_set(entity_id, None, {"unit_of_measurement": UnitOfPower.WATT})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
new_state = hass.states.get("sensor.integration")
|
||||
|
||||
Reference in New Issue
Block a user