Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def post(self, request, entity_id):

new_state = data.get('state')

if not new_state:
if new_state is None:
return self.json_message('No state specified', HTTP_BAD_REQUEST)

attributes = data.get('attributes')
Expand Down
17 changes: 17 additions & 0 deletions tests/components/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ def test_api_state_change_with_bad_data(hass, mock_api_client):
assert resp.status == 400


# pylint: disable=invalid-name
@asyncio.coroutine
def test_api_state_change_to_zero_value(hass, mock_api_client):
"""Test if changing a state to a zero value is possible."""
resp = yield from mock_api_client.post(
const.URL_API_STATES_ENTITY.format("test_entity.with_zero_state"),
json={'state': 0})

assert resp.status == 201

resp = yield from mock_api_client.post(
const.URL_API_STATES_ENTITY.format("test_entity.with_zero_state"),
json={'state': 0.})

assert resp.status == 200


# pylint: disable=invalid-name
@asyncio.coroutine
def test_api_state_change_push(hass, mock_api_client):
Expand Down