mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 19:40:11 +00:00
Fix utility meter restore state (#66490)
* Address #63874
* avoid setting _last_period to None
* name is always set in discovery
* ValueError never happens only DecimalException
* async_tariff_change tracks state change - state machine will not pass a None
* test we only reset one utility_meter
* test corrupted restored state
* pretty sure _current_tariff doesn't change from init until here
* missing assert
* Revert "async_tariff_change tracks state change - state machine will not pass a None"
This reverts commit 24fc04a964.
* address review comment
* always a Decimal
This commit is contained in:
@@ -62,7 +62,12 @@ async def test_services(hass):
|
||||
"source": "sensor.energy",
|
||||
"cycle": "hourly",
|
||||
"tariffs": ["peak", "offpeak"],
|
||||
}
|
||||
},
|
||||
"energy_bill2": {
|
||||
"source": "sensor.energy",
|
||||
"cycle": "hourly",
|
||||
"tariffs": ["peak", "offpeak"],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +158,10 @@ async def test_services(hass):
|
||||
state = hass.states.get("sensor.energy_bill_offpeak")
|
||||
assert state.state == "0"
|
||||
|
||||
# meanwhile energy_bill2_peak accumulated all kWh
|
||||
state = hass.states.get("sensor.energy_bill2_peak")
|
||||
assert state.state == "4"
|
||||
|
||||
|
||||
async def test_cron(hass, legacy_patchable_time):
|
||||
"""Test cron pattern and offset fails."""
|
||||
|
||||
Reference in New Issue
Block a user