forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add websocket API command for Z-Wave network status (home-assistant#2…
…5066) * Add websocket API command for Z-Wave network status * lint * Add callback decorator * Remove state_str, fix lint
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Web socket API for Z-Wave.""" | ||
|
||
import logging | ||
|
||
import voluptuous as vol | ||
|
||
from homeassistant.components import websocket_api | ||
from homeassistant.core import callback | ||
|
||
from .const import DATA_NETWORK | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
TYPE = 'type' | ||
ID = 'id' | ||
|
||
|
||
@websocket_api.require_admin | ||
@websocket_api.websocket_command({ | ||
vol.Required(TYPE): 'zwave/network_status' | ||
}) | ||
def websocket_network_status(hass, connection, msg): | ||
"""Get Z-Wave network status.""" | ||
network = hass.data[DATA_NETWORK] | ||
connection.send_result(msg[ID], { | ||
'state': network.state, | ||
}) | ||
|
||
|
||
@callback | ||
def async_load_websocket_api(hass): | ||
"""Set up the web socket API.""" | ||
websocket_api.async_register_command(hass, websocket_network_status) |