Populate measurement state field for HA states like home/not_home (#9833)
This commit is contained in:
1 parent
b548116f9b
commit
fb32cc39e1
2 files changed
+71
-92
No files matched your search
@@ -145,11 +145,16 @@ def setup(hass, config):
|
||||
(whitelist_d and state.domain not in whitelist_d):
|
||||
return
|
||||
|
||||
_state = float(state_helper.state_as_number(state))
|
||||
_state_key = "value"
|
||||
_include_state = _include_value = False
|
||||
|
||||
_state_as_value = float(state.state)
|
||||
_include_value = True
|
||||
except ValueError:
|
||||
_state = state.state
|
||||
_state_key = "state"
|
||||
try:
|
||||
_state_as_value = float(state_helper.state_as_number(state))
|
||||
_include_state = _include_value = True
|
||||
except ValueError:
|
||||
_include_state = True
|
||||
|
||||
include_uom = True
|
||||
measurement = component_config.get(state.entity_id).get(
|
||||
@@ -176,10 +181,13 @@ def setup(hass, config):
|
||||
},
|
||||
'time': event.time_fired,
|
||||
'fields': {
|
||||
_state_key: _state,
|
||||
}
|
||||
}
|
||||
]
|
||||
if _include_state:
|
||||
json_body[0]['fields']['state'] = state.state
|
||||
if _include_value:
|
||||
json_body[0]['fields']['value'] = _state_as_value
|
||||
|
||||
for key, value in state.attributes.items():
|
||||
if key in tags_attributes:
|
||||
|
||||
Reference in new issue
Block a user