legrego / homeassistant-elasticsearch

Publish Home-Assistant events to Elasticsearch
https://legrego.github.io/homeassistant-elasticsearch/
MIT License
145 stars 38 forks source link

NaN values are not supported #54

Closed joostvanmourik closed 4 years ago

joostvanmourik commented 5 years ago

Log Details (ERROR) Mon Mar 04 2019 13:44:13 GMT+0100 (Midden-Europese standaardtijd) Error publishing documents to Elasticsearch: ('5 document(s) failed to index.', [{'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'wbW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@1ee844c6; line: 1, column: 257]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_p1_power_solar', 'entity_id': 'sensor.toon_p1_power_solar', 'attributes': {'unit_of_measurement': 'Watt', 'friendly_name': 'Toon P1 Power Solar', 'icon': 'mdi:weather-sunny'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'wrW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@24ea5bba; line: 1, column: 245]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_power_use_cnt', 'entity_id': 'sensor.toon_power_use_cnt', 'attributes': {'unit_of_measurement': 'kWh', 'friendly_name': 'Toon Power Use Cnt', 'icon': 'mdi:flash'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'xLW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@292a954b; line: 1, column: 268]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_p1_power_solar_cnt', 'entity_id': 'sensor.toon_p1_power_solar_cnt', 'attributes': {'unit_of_measurement': 'kWh', 'friendly_name': 'Toon P1 Power Solar Cnt', 'icon': 'mdi:weather-sunny'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'ybW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@8ae6212; line: 1, column: 223]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_p1_heat', 'entity_id': 'sensor.toon_p1_heat', 'attributes': {'unit_of_measurement': '', 'friendly_name': 'Toon P1 Heat', 'icon': 'mdi:fire'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'yrW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@54bcc9b5; line: 1, column: 234]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_power_use', 'entity_id': 'sensor.toon_power_use', 'attributes': {'unit_of_measurement': 'Watt', 'friendly_name': 'Toon Power Use', 'icon': 'mdi:flash'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}]) Traceback (most recent call last): File "/config/custom_components/elastic/init.py", line 286, in do_publish bulk_response = bulk(self._gateway.get_client(), actions) File "/config/deps/lib/python3.7/site-packages/elasticsearch/helpers/init.py", line 257, in bulk for ok, item in streaming_bulk(client, actions, *args, *kwargs): File "/config/deps/lib/python3.7/site-packages/elasticsearch/helpers/init.py", line 192, in streaming_bulk raise_on_error, args, **kwargs) File "/config/deps/lib/python3.7/site-packages/elasticsearch/helpers/init.py", line 137, in _process_bulk_chunk raise BulkIndexError('%i document(s) failed to index.' % len(errors), errors) elasticsearch.helpers.BulkIndexError: ('5 document(s) failed to index.', [{'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'wbW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@1ee844c6; line: 1, column: 257]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_p1_power_solar', 'entity_id': 'sensor.toon_p1_power_solar', 'attributes': {'unit_of_measurement': 'Watt', 'friendly_name': 'Toon P1 Power Solar', 'icon': 'mdi:weather-sunny'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'wrW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@24ea5bba; line: 1, column: 245]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_power_use_cnt', 'entity_id': 'sensor.toon_power_use_cnt', 'attributes': {'unit_of_measurement': 'kWh', 'friendly_name': 'Toon Power Use Cnt', 'icon': 'mdi:flash'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'xLW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@292a954b; line: 1, column: 268]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_p1_power_solar_cnt', 'entity_id': 'sensor.toon_p1_power_solar_cnt', 'attributes': {'unit_of_measurement': 'kWh', 'friendly_name': 'Toon P1 Power Solar Cnt', 'icon': 'mdi:weather-sunny'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'ybW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@8ae6212; line: 1, column: 223]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_p1_heat', 'entity_id': 'sensor.toon_p1_heat', 'attributes': {'unit_of_measurement': '', 'friendly_name': 'Toon P1 Heat', 'icon': 'mdi:fire'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}, {'index': {'_index': 'hass-events-v2-000001', '_type': 'doc', '_id': 'yrW7SGkBaQlUzTS0rK9f', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason': 'failed to parse', 'caused_by': {'type': 'json_parse_exception', 'reason': "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@54bcc9b5; line: 1, column: 234]"}}, 'data': {'domain': 'sensor', 'object_id': 'toon_power_use', 'entity_id': 'sensor.toon_power_use', 'attributes': {'unit_of_measurement': 'Watt', 'friendly_name': 'Toon Power Use', 'icon': 'mdi:flash'}, '@timestamp': datetime.datetime(2019, 3, 4, 13, 44, 12, 732634), 'value': nan}}}])

Do you have any idea ?

joostvanmourik commented 5 years ago

Tried this https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-malformed.html

But now i have this warning Error publishing documents to Elasticsearch: ('116 document(s) failed to index.', [{'index': {'_index': 'hassjvm-v2', '_type': 'doc', '_id': 'JrX9SGkBaQlUzTS0P9kg', 'status': 400, 'error': {'type': 'illegal_argument_exception',

jakommo commented 5 years ago

Hi @joostvanmourik , can you post the whole exception you get now, it looks like it has been truncated after the 'illegal_argument_exception', part. It would also be nice if you could use code blocks / markdown to make your posts more readable.

joostvanmourik commented 5 years ago

Had a couple devices with "Nan" Excluded everything and now it seems to work, just like to write the values of 2 charts to elastic. Thanx

legrego commented 5 years ago

@joostvanmourik, I've updated the issue description to match the underlying problem. Thanks for the report!