mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Clean up binary_sensor
This commit is contained in:
parent
63a27f1943
commit
4c538c718b
@ -61,11 +61,6 @@ class BinarySensorDevice(Entity):
|
|||||||
"""Return the state of the binary sensor."""
|
"""Return the state of the binary sensor."""
|
||||||
return STATE_ON if self.is_on else STATE_OFF
|
return STATE_ON if self.is_on else STATE_OFF
|
||||||
|
|
||||||
@property
|
|
||||||
def friendly_state(self):
|
|
||||||
"""Return the friendly state of the binary sensor."""
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sensor_class(self):
|
def sensor_class(self):
|
||||||
"""Return the class of this sensor, from SENSOR_CASSES."""
|
"""Return the class of this sensor, from SENSOR_CASSES."""
|
||||||
@ -74,6 +69,9 @@ class BinarySensorDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
"""Return device specific state attributes."""
|
"""Return device specific state attributes."""
|
||||||
return {
|
attr = {}
|
||||||
'sensor_class': self.sensor_class,
|
|
||||||
}
|
if self.sensor_class is not None:
|
||||||
|
attr['sensor_class'] = self.sensor_class
|
||||||
|
|
||||||
|
return attr
|
||||||
|
@ -31,8 +31,7 @@ class TestBinarySensor(unittest.TestCase):
|
|||||||
def test_attributes(self):
|
def test_attributes(self):
|
||||||
"""Test binary sensor attributes."""
|
"""Test binary sensor attributes."""
|
||||||
sensor = binary_sensor.BinarySensorDevice()
|
sensor = binary_sensor.BinarySensorDevice()
|
||||||
self.assertEqual({'sensor_class': None},
|
self.assertEqual({}, sensor.state_attributes)
|
||||||
sensor.state_attributes)
|
|
||||||
with mock.patch('homeassistant.components.binary_sensor.'
|
with mock.patch('homeassistant.components.binary_sensor.'
|
||||||
'BinarySensorDevice.sensor_class',
|
'BinarySensorDevice.sensor_class',
|
||||||
new='motion'):
|
new='motion'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user