Handle state unknown if last state is missing in Shelly (#86813)
Shelly - handle state unknown if last state is missing
This commit is contained in:
parent
50c2992f36
commit
803cd8d9a3
11 changed files with 170 additions and 38 deletions
|
@ -93,12 +93,15 @@ class BlockSleepingNumber(ShellySleepingBlockAttributeEntity, NumberEntity):
|
|||
entity_description: BlockNumberDescription
|
||||
|
||||
@property
|
||||
def native_value(self) -> float:
|
||||
def native_value(self) -> float | None:
|
||||
"""Return value of number."""
|
||||
if self.block is not None:
|
||||
return cast(float, self.attribute_value)
|
||||
|
||||
return cast(float, self.last_state)
|
||||
if self.last_state is None:
|
||||
return None
|
||||
|
||||
return cast(float, self.last_state.state)
|
||||
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set value."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue