Convert statsd, influx, splunk, and graphite to use state_as_number()

Fixes #1205
This commit is contained in:
Dan Smith committed 2016-02-12 01:45:25 +00:00
1 parent 3aa34deaa2
commit 4a2b956493
5 files changed
+30 -55

No files matched your search

+5 -14
View File
@@ -14,10 +14,8 @@ import requests
import homeassistant.util as util
from homeassistant.helpers import validate_config
from homeassistant.const import (EVENT_STATE_CHANGED, STATE_ON, STATE_OFF,
STATE_UNLOCKED, STATE_LOCKED, STATE_UNKNOWN)
from homeassistant.components.sun import (STATE_ABOVE_HORIZON,
STATE_BELOW_HORIZON)
from homeassistant.helpers import state as state_helper
from homeassistant.const import EVENT_STATE_CHANGED
_LOGGER = logging.getLogger(__name__)
@@ -64,17 +62,10 @@ def setup(hass, config):
if state is None:
return
if state.state in (STATE_ON, STATE_LOCKED, STATE_ABOVE_HORIZON):
_state = 1
elif state.state in (STATE_OFF, STATE_UNLOCKED, STATE_UNKNOWN,
STATE_BELOW_HORIZON):
_state = 0
else:
try:
_state = state_helper.state_as_number(state)
except ValueError:
_state = state.state
try:
_state = float(_state)
except ValueError:
pass
json_body = [
{