Add tests for Shelly binary_sensor platform (#82367)

* Add tests for Shelly binary_sensor platform

* Rename create to register for
This commit is contained in:
Shay Levy 2022-11-19 18:07:02 +02:00 committed by GitHub
parent e028516939
commit ea98f0e9e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 238 additions and 44 deletions

View file

@ -268,10 +268,8 @@ class RestBinarySensor(ShellyRestAttributeEntity, BinarySensorEntity):
entity_description: RestBinarySensorDescription
@property
def is_on(self) -> bool | None:
def is_on(self) -> bool:
"""Return true if REST sensor state is on."""
if self.attribute_value is None:
return None
return bool(self.attribute_value)
@ -281,10 +279,8 @@ class RpcBinarySensor(ShellyRpcAttributeEntity, BinarySensorEntity):
entity_description: RpcBinarySensorDescription
@property
def is_on(self) -> bool | None:
def is_on(self) -> bool:
"""Return true if RPC sensor state is on."""
if self.attribute_value is None:
return None
return bool(self.attribute_value)
@ -308,7 +304,7 @@ class RpcSleepingBinarySensor(ShellySleepingRpcAttributeEntity, BinarySensorEnti
entity_description: RpcBinarySensorDescription
@property
def is_on(self) -> bool | None:
def is_on(self) -> bool:
"""Return true if RPC sensor state is on."""
if self.coordinator.device.initialized:
return bool(self.attribute_value)