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:
parent
4dbd9b21b7
commit
b211a1faa7
4 changed files with 27 additions and 16 deletions
|
@ -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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue