Add SmartThings sensor support for Three Axis (#21841)
* Add support for Three Axis to sensor platform * Changes per review feedback. * Remove unnecessary KeyError except * Fix lint issue in line wrapping
This commit is contained in:
1 parent
c927cd9c14
commit
5ace55ea8d
2 files changed
+83
-9
No files matched your search
@@ -11,7 +11,8 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.components.smartthings import sensor
|
||||
from homeassistant.components.smartthings.const import (
|
||||
DOMAIN, SIGNAL_SMARTTHINGS_UPDATE)
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT
|
||||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT, STATE_UNKNOWN)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
from .conftest import setup_platform
|
||||
@@ -34,7 +35,7 @@ async def test_async_setup_platform():
|
||||
|
||||
|
||||
async def test_entity_state(hass, device_factory):
|
||||
"""Tests the state attributes properly match the light types."""
|
||||
"""Tests the state attributes properly match the sensor types."""
|
||||
device = device_factory('Sensor 1', [Capability.battery],
|
||||
{Attribute.battery: 100})
|
||||
await setup_platform(hass, SENSOR_DOMAIN, devices=[device])
|
||||
@@ -45,6 +46,38 @@ async def test_entity_state(hass, device_factory):
|
||||
device.label + " Battery"
|
||||
|
||||
|
||||
async def test_entity_three_axis_state(hass, device_factory):
|
||||
"""Tests the state attributes properly match the three axis types."""
|
||||
device = device_factory('Three Axis', [Capability.three_axis],
|
||||
{Attribute.three_axis: [100, 75, 25]})
|
||||
await setup_platform(hass, SENSOR_DOMAIN, devices=[device])
|
||||
state = hass.states.get('sensor.three_axis_x_coordinate')
|
||||
assert state.state == '100'
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] ==\
|
||||
device.label + " X Coordinate"
|
||||
state = hass.states.get('sensor.three_axis_y_coordinate')
|
||||
assert state.state == '75'
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] ==\
|
||||
device.label + " Y Coordinate"
|
||||
state = hass.states.get('sensor.three_axis_z_coordinate')
|
||||
assert state.state == '25'
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] ==\
|
||||
device.label + " Z Coordinate"
|
||||
|
||||
|
||||
async def test_entity_three_axis_invalid_state(hass, device_factory):
|
||||
"""Tests the state attributes properly match the three axis types."""
|
||||
device = device_factory('Three Axis', [Capability.three_axis],
|
||||
{Attribute.three_axis: []})
|
||||
await setup_platform(hass, SENSOR_DOMAIN, devices=[device])
|
||||
state = hass.states.get('sensor.three_axis_x_coordinate')
|
||||
assert state.state == STATE_UNKNOWN
|
||||
state = hass.states.get('sensor.three_axis_y_coordinate')
|
||||
assert state.state == STATE_UNKNOWN
|
||||
state = hass.states.get('sensor.three_axis_z_coordinate')
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_entity_and_device_attributes(hass, device_factory):
|
||||
"""Test the attributes of the entity are correct."""
|
||||
# Arrange
|
||||
|
||||
Reference in new issue
Block a user